SA-MP Forums Archive
/enter, /exit - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: /enter, /exit (/showthread.php?tid=325086)



/enter, /exit - Dripac - 11.03.2012

I remember i saw something like this,

you can use CallRemoteFunction for /enter and /exit so people can enter buildings by pressing the enter key

can someone give me the code? +rep


Re: /enter, /exit - jameskmonger - 11.03.2012

What do you mean?


Re: /enter, /exit - JJB562 - 11.03.2012

Here's an example:

pawn Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    if(newkeys & KEYNUMBERHERE) // Get The key from here https://sampwiki.blast.hk/wiki/GetPlayerKeys
    {
        if(IsPlayerInRangeOfPoint(playerid, RANGE, POS-X, POS-Y, POS-Z)) // Here if you don't know how to use IsPlayerInRangeOfPoint https://sampwiki.blast.hk/wiki/IsPlayerInRangeOfPoint
        {
            SetPlayerPos(playerid, Pos-X, POS-Y, POS-Z); // Here if you need help with SetPlayerPos https://sampwiki.blast.hk/wiki/SetPlayerPos
            SetPlayerInterior(playerid, InteriorNumberHere); // Here if you need help with SetPlayerInterior https://sampwiki.blast.hk/wiki/SetPlayerInterior
        }
    }
    return 1;
}



Re: /enter, /exit - Dripac - 11.03.2012

Alright i got that what i wanted, but it doesn't work, it compiles but doesn't work in-game, whats wrong?

pawn Код:
if(newkeys & 16)
    {
        CallLocalFunction("OnPlayerCommandText", "is", playerid, "/enter");
        CallLocalFunction("OnPlayerCommandText", "is", playerid, "/exit");
    }



Re: /enter, /exit - JJB562 - 11.03.2012

Try This.

pawn Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    if(newkeys & 16)
    {
        CallLocalFunction("OnPlayerCommandText", "is", "/enter");
        CallLocalFunction("OnPlayerCommandText", "is", "/exit");
    }
    return 1;
}
EDITED: I edited the script, now try this ONE.


Re: /enter, /exit - jameskmonger - 11.03.2012

Try this:
pawn Код:
if(newkeys & 16)
    {
        SendClientMessage(playerid, -1, "test");
        CallLocalFunction("OnPlayerCommandText", "is", playerid, "/enter");
        CallLocalFunction("OnPlayerCommandText", "is", playerid, "/exit");
    }
Do you get the message "test"?


Re: /enter, /exit - Dripac - 11.03.2012

Nah, it doesn't show the message, also doesn't work if i add return 1;


Re: /enter, /exit - JJB562 - 11.03.2012

Funny.. I have this same method to enter buildings, but I don't make it CallLocalFunction. I do it how I showed you on my first post. Why not just do it with SetPlayerPos, and SetPlayerInterior...


Re: /enter, /exit - IceCube! - 12.03.2012

Umm, If the test isnt called the Key your searchin for is wrong OR there is somthing wrong with the code above that. Please post any code that comes before the calling of this key.


Re: /enter, /exit - Dripac - 12.03.2012

pawn Код:
new newcar = GetPlayerVehicleID(playerid);
    if(newkeys & KEY_SPRINT)
    {
        if(gPlayerUsingLoopingAnim[playerid] == 1)
        {
            gPlayerUsingLoopingAnim[playerid] = 0;
            ApplyAnimation(playerid, "CARRY", "crry_prtial", 4.0, 0, 0, 0, 0, 0);
            animation[playerid] = 0;
            TextDrawHideForPlayer(playerid,txtAnimHelper);
        }
    }
    if(IsAnOwnableCar(newcar))
    {
        if(PlayerInfo[playerid][pPcarkey] == newcar) { }
        else if(PlayerInfo[playerid][pPcarkey2] == newcar) { }
        else if(PlayerInfo[playerid][pPcarkey3] == newcar) { }
        else { return 1; }
    }
This is everything under OnPlayerKeyStateChange, i added the CallLocalFunction at the first place