Per Entertaste in Gebäude rein & raus...

Wichtiger Hinweis: Bitte ändert nicht manuell die Schriftfarbe auf schwarz sondern belasst es bei der Standardeinstellung. Somit tragt ihr dazu bei dass euer Text auch bei Verwendung unseren dunklen Forenstils noch lesbar ist!

Tipp: Ihr wollt längere Codeausschnitte oder Logfiles bereitstellen? Benutzt unseren eigenen PasteBin-Dienst Link
  • Guten Tag liebe Community...


    Die frage steht eigentlich schon in der Überschrift...


    Wie kann ich das hinkriegen,dass ich per Entertaste Gebäude betrete & verlasse?


    Derzeit sieht es so aus:


    if(strcmp(cmdtext, "/enter", true) ==0)
    {
    if(IsPlayerInRangeOfPoint(playerid,3.0,-2424.8130,337.2221,37.0019))
    {
    SetPlayerPos(playerid,271.884979,306.631988,999.148437);
    SetPlayerInterior(playerid,2);
    return 1;
    }
    if(IsPlayerInRangeOfPoint(playerid,3.0,-1883.1982,865.5228,35.1719)) //Zip
    {
    SetPlayerPos(playerid,161.391006,-93.159156,1001.804687);
    SetPlayerInterior(playerid,18);
    return 1;

    }
    else
    if(IsPlayerInRangeOfPoint(playerid,3.0,-2026.4840,-101.0355,35.1641)) //Fahrschule
    {
    SetPlayerPos(playerid,-2029.798339,-106.675910,1035.171875);
    SetPlayerInterior(playerid,3);
    return 1;
    }
    else
    if(IsPlayerInRangeOfPoint(playerid,3.0,-2765.5942,375.7597,6.3359)) //Arbeitsamt
    {
    SetPlayerPos(playerid,384.808624,173.804992,1008.382812);
    SetPlayerInterior(playerid,3);
    return 1;
    }
    else
    if(IsPlayerInRangeOfPoint(playerid,3.0,-2442.7295,753.9190,35.1719)) //24/7 Eingang
    {
    SetPlayerPos(playerid,6.091179,-29.271898,1003.549438);
    SetPlayerInterior(playerid,10);
    return 1;
    }
    else
    if(IsPlayerInRangeOfPoint(playerid,3.0,-2650.0889,376.1048,6.1563)) //Bank groß
    {
    SetPlayerPos(playerid,833.269775,10.588416,1004.179687);
    SetPlayerInterior(playerid,3);
    return 1;
    }
    else
    if(IsPlayerInRangeOfPoint(playerid,3.0,-1816.4424,617.5515,35.1719)) //Clucking
    {
    SetPlayerPos(playerid,369.579528,-4.487291,1001.858886);
    SetPlayerInterior(playerid,9);
    return 1;
    }
    else
    if(IsPlayerInRangeOfPoint(playerid,3.0,1319.2622,1250.9506,10.8203)||IsPlayerInRangeOfPoint(playerid,3.0,1685.6200,-2334.0400,13.5469)||IsPlayerInRangeOfPoint(playerid,3.0,-1262.1936,40.0042,14.1392)) //Flughafen
    {
    SetPlayerPos(playerid,-1827.147338,7.207417,1061.143554);
    SetPlayerInterior(playerid,14);
    return 1;
    }
    else
    SendClientMessage(playerid,ROT,"Hier befindet sich kein Eingang!");
    return 1;

    }
    if(strcmp(cmdtext, "/exit", true) ==0)
    {
    if(IsPlayerInRangeOfPoint(playerid,3.0,271.884979,306.631988,999.148437))//Hotel
    {
    SetPlayerPos(playerid,-2424.8130,337.2221,37.0019);
    SetPlayerInterior(playerid,0);
    return 1;
    }
    if(IsPlayerInRangeOfPoint(playerid,3.0,161.391006,-93.159156,1001.804687)) //Zip
    {
    SetPlayerPos(playerid,-1883.1982,865.5228,35.1719);
    SetPlayerInterior(playerid,0);
    return 1;
    }
    else
    if(IsPlayerInRangeOfPoint(playerid,3.0,-2029.798339,-106.675910,1035.171875)) //Fahrschule
    {
    SetPlayerPos(playerid,-2026.4840,-101.0355,35.1641);
    SetPlayerInterior(playerid,0);
    return 1;
    }
    else
    if(IsPlayerInRangeOfPoint(playerid,3.0,384.808624,173.804992,1008.382812)) //Arbeitsamt
    {
    SetPlayerPos(playerid,-2765.5942,375.7597,6.3359);
    SetPlayerInterior(playerid,0);
    return 1;
    }
    else
    if(IsPlayerInRangeOfPoint(playerid,3.0,6.091179,-29.271898,1003.549438)) //24/7 Eingang
    {
    SetPlayerPos(playerid,-2442.7295,753.9190,35.1719);
    SetPlayerInterior(playerid,0);
    return 1;
    }
    else
    if(IsPlayerInRangeOfPoint(playerid,3.0,833.269775,10.588416,1004.179687)) //Bank groß
    {
    SetPlayerPos(playerid,-2650.0889,376.1048,6.1563);
    SetPlayerInterior(playerid,0);
    return 1;
    }
    else
    if(IsPlayerInRangeOfPoint(playerid,3.0,369.579528,-4.487291,1001.858886)) //Clucking
    {
    SetPlayerPos(playerid,-1816.4424,617.5515,35.1719);
    SetPlayerInterior(playerid,0);
    return 1;
    }
    else
    SendClientMessage(playerid,ROT,"Hier befindet sich kein Ausgang!");
    return 1;


    }

  • public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
    {
    if(!IsPlayerInAnyVehicle(playerid))
    {
    if(PRESSED(KEY_SPRINT))
    {
    if(IsPlayerInRangeOfPoint(playerid, Radius, x,y,z))
    {
    SetPlayerPos(playerid, x, y,z);
    }
    }
    return 1;
    }


    das wär mit der sprint taste

  • Also, erstmal die ganzen IsPlayerInRangeOfPoint's in ein Public packen:
    Oben im Script due Publics definieren:

    forward InteriorEnter(playerid);
    forward InteriorExit(playerid);


    Dann die Publics schreiben:

    public InteriorEnter(playerid)
    {
    if(IsPlayerInRangeOfPoint(playerid,3.0,-2424.8130,337.2221,37.0019))
    {
    SetPlayerPos(playerid,271.884979,306.631988,999.148437);
    SetPlayerInterior(playerid,2);
    return 1;
    }
    if(IsPlayerInRangeOfPoint(playerid,3.0,-1883.1982,865.5228,35.1719)) //Zip
    {
    SetPlayerPos(playerid,161.391006,-93.159156,1001.804687);
    SetPlayerInterior(playerid,18);
    return 1;

    }
    else
    if(IsPlayerInRangeOfPoint(playerid,3.0,-2026.4840,-101.0355,35.1641)) //Fahrschule
    {
    SetPlayerPos(playerid,-2029.798339,-106.675910,1035.171875);
    SetPlayerInterior(playerid,3);
    return 1;
    }
    else
    if(IsPlayerInRangeOfPoint(playerid,3.0,-2765.5942,375.7597,6.3359)) //Arbeitsamt
    {
    SetPlayerPos(playerid,384.808624,173.804992,1008.382812);
    SetPlayerInterior(playerid,3);
    return 1;
    }
    else
    if(IsPlayerInRangeOfPoint(playerid,3.0,-2442.7295,753.9190,35.1719)) //24/7 Eingang
    {
    SetPlayerPos(playerid,6.091179,-29.271898,1003.549438);
    SetPlayerInterior(playerid,10);
    return 1;
    }
    else
    if(IsPlayerInRangeOfPoint(playerid,3.0,-2650.0889,376.1048,6.1563)) //Bank groß
    {
    SetPlayerPos(playerid,833.269775,10.588416,1004.179687);
    SetPlayerInterior(playerid,3);
    return 1;
    }
    else
    if(IsPlayerInRangeOfPoint(playerid,3.0,-1816.4424,617.5515,35.1719)) //Clucking
    {
    SetPlayerPos(playerid,369.579528,-4.487291,1001.858886);
    SetPlayerInterior(playerid,9);
    return 1;
    }
    else
    if(IsPlayerInRangeOfPoint(playerid,3.0,1319.2622,1250.9506,10.8203)||IsPlayerInRangeOfPoint(playerid,3.0,1685.6200,-2334.0400,13.5469)||IsPlayerInRangeOfPoint(playerid,3.0,-1262.1936,40.0042,14.1392)) //Flughafen
    {
    SetPlayerPos(playerid,-1827.147338,7.207417,1061.143554);
    SetPlayerInterior(playerid,14);
    return 1;
    }
    else
    SendClientMessage(playerid,ROT,"Hier befindet sich kein Eingang!");
    return 1;

    }
    public InteriorExit(playerid)
    {
    if(IsPlayerInRangeOfPoint(playerid,3.0,271.884979,306.631988,999.148437))//Hotel
    {
    SetPlayerPos(playerid,-2424.8130,337.2221,37.0019);
    SetPlayerInterior(playerid,0);
    return 1;
    }
    if(IsPlayerInRangeOfPoint(playerid,3.0,161.391006,-93.159156,1001.804687)) //Zip
    {
    SetPlayerPos(playerid,-1883.1982,865.5228,35.1719);
    SetPlayerInterior(playerid,0);
    return 1;
    }
    else
    if(IsPlayerInRangeOfPoint(playerid,3.0,-2029.798339,-106.675910,1035.171875)) //Fahrschule
    {
    SetPlayerPos(playerid,-2026.4840,-101.0355,35.1641);
    SetPlayerInterior(playerid,0);
    return 1;
    }
    else
    if(IsPlayerInRangeOfPoint(playerid,3.0,384.808624,173.804992,1008.382812)) //Arbeitsamt
    {
    SetPlayerPos(playerid,-2765.5942,375.7597,6.3359);
    SetPlayerInterior(playerid,0);
    return 1;
    }
    else
    if(IsPlayerInRangeOfPoint(playerid,3.0,6.091179,-29.271898,1003.549438)) //24/7 Eingang
    {
    SetPlayerPos(playerid,-2442.7295,753.9190,35.1719);
    SetPlayerInterior(playerid,0);
    return 1;
    }
    else
    if(IsPlayerInRangeOfPoint(playerid,3.0,833.269775,10.588416,1004.179687)) //Bank groß
    {
    SetPlayerPos(playerid,-2650.0889,376.1048,6.1563);
    SetPlayerInterior(playerid,0);
    return 1;
    }
    else
    if(IsPlayerInRangeOfPoint(playerid,3.0,369.579528,-4.487291,1001.858886)) //Clucking
    {
    SetPlayerPos(playerid,-1816.4424,617.5515,35.1719);
    SetPlayerInterior(playerid,0);
    return 1;
    }
    else
    SendClientMessage(playerid,ROT,"Hier befindet sich kein Ausgang!");
    return 1;


    }


    Und letztendlich den Rest mit den Tasten unter OnPlayerKeyStateChange:

    if((newkeys & KEY_SECONDARY_ATTACK) && !(IsPlayerInAnyVehicle(playerid)))
    {
    if(GetPlayerInterior(playerid) == 0) InteriorEnter(playerid);
    else InteriorExit(playerid);
    }

    Code ist aus dem Stegreif, sollte was nicht funktionieren, bescheid sagen.

  • ja aber wer ändert seine Tastatureinstellung bei GTA?


    back2topic:



    native SendCommand(commandtext[])
    ; //muss noch in header rein sonst gehts ned oder die a_npc.inc includieren
    if((newkeys && KEY_SECONDARY_ATTACK) && (GetPlayerState(playerid) ==
    PLAYER_STATE_ONFOOT))
    {
    SendCommand("/enter");
    }


    Wobei der playerstate eigentlich schon beim entercmd abgefragt werden sollte