/enter, /exit
#1

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
Reply
#2

What do you mean?
Reply
#3

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;
}
Reply
#4

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");
    }
Reply
#5

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.
Reply
#6

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"?
Reply
#7

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

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...
Reply
#9

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.
Reply
#10

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
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)