OnPlayerKeyStateChange problem
#1

pawn Код:
command(enter, playerid, params[])
{

    if(IsPlayerInRangeOfPoint(playerid, 5.0, 2269.3821,-75.3405,26.7724))
    {
        SetPlayerPos(playerid, 916.6719,2380.9543,246.4695);
        SetPlayerInterior(playerid, 1);
        GameTextForPlayer(playerid, "~g~T66bьroo~n~~r~Tryki /v2lju et v2ljuda hoonest", 3000, 5);
        LoadInterior(playerid);
        FadePlayerScreen(playerid, BLACK, 15);
    }
    if(IsPlayerInRangeOfPoint(playerid, 5.0, 248.19241, -33.15711, 1.60261))
    {
        SetPlayerPos(playerid, -2029.7589,-118.3868,1035.1719);
        SetPlayerInterior(playerid, 3);
        GameTextForPlayer(playerid, "~w~ARK~n~~r~Tryki /v2lju et v2ljuda hoonest", 3000, 5);
        LoadInterior(playerid);
        FadePlayerScreen(playerid, BLACK, 5);
    }
    else if(IsPlayerInRangeOfPoint(playerid, 5.0, 627.9313,-571.6613,17.4696))
    {
        SetPlayerPos(playerid, 246.2813,108.7695,1003.2188);
        SetPlayerInterior(playerid, 10);
        GameTextForPlayer(playerid, "~w~Red County Sheriff's Department~n~~r~Tryki /v2lju et v2ljuda hoonest", 3000, 5);
        LoadInterior(playerid);
        FadePlayerScreen(playerid, BLACK, 5);
    }
    else if(IsPlayerInRangeOfPoint(playerid, 5.0, 624.0983,-600.0155,16.7198))
    {
        if(Player[playerid][Faction] == 1)
        {
            if(IsPlayerInAnyVehicle(playerid))
            {
                SetVehiclePos(GetPlayerVehicleID(playerid), 1589.5502,-1646.0876,11.3940);
                SetVehicleZAngle(GetPlayerVehicleID(playerid), 201.7274);
                LoadInterior(playerid);
                FadePlayerScreen(playerid, BLACK, 5);
            }
            else
            {
                SetPlayerPos(playerid, 1589.5502,-1646.0876,11.3940);
                LoadInterior(playerid);
                FadePlayerScreen(playerid, BLACK, 5);
            }
        }
        else return SendClientMessage(playerid, WHITE, "Sul pole хigust siia siseneda.");
    }
    else
    {
        for(new i = 1; i < MAX_HOUSES; i++)
        {
            if(IsPlayerInRangeOfPoint(playerid, 3.0, Houses[i][HouseExteriorX], Houses[i][HouseExteriorY], Houses[i][HouseExteriorZ]))
            {
                if(Houses[i][HouseLocked] == 0)
                {
                    new string[256];
                    SetPlayerPos(playerid, Houses[i][HouseInteriorX], Houses[i][HouseInteriorY], Houses[i][HouseInteriorZ]);
                    SetPlayerInterior(playerid, Houses[i][HouseInteriorID]);
                    format(string, sizeof(string), "~w~%s~n~~r~Trьki /v2lju et vдljuda hoones", Houses[i][HouseName]);
                    GameTextForPlayer(playerid, string, 3000, 5);
                    SetPlayerVirtualWorld(playerid, Houses[i][HouseWorld]);
                    LoadInterior(playerid);
                    FadePlayerScreen(playerid, BLACK, 5);
                }
                else
                {
                    new string[256];
                    format(string, sizeof(string), "%s on hetkel suletud.", Houses[i][HouseName]);
                    SendClientMessage(playerid, WHITE, string);
                }
            }
        }
        for(new i = 1; i < MAX_BUSINESS; i++)
        {
            if(IsPlayerInRangeOfPoint(playerid, 3.0, Business[i][BusinessExteriorX], Business[i][BusinessExteriorY], Business[i][BusinessExteriorZ]))
            {
                if(Business[i][BusinessEnterable] == 1)
                {
                    if(Player[playerid][Money] >= Business[i][BusinessEnterFee])
                    {
                        new string[256];
                        SetPlayerPos(playerid, Business[i][BusinessInteriorX], Business[i][BusinessInteriorY], Business[i][BusinessInteriorZ]);
                        SetPlayerInterior(playerid, Business[i][BusinessInteriorID]);
                        format(string, sizeof(string), "Teretulemast %s. Omanik %s. Sissepддsu tasu: $%d.", Business[i][BusinessName], Business[i][BusinessOwner], Business[i][BusinessEnterFee]);
                        SendClientMessage(playerid, WHITE, string);
                        InBusiness[playerid] = i;
                        Player[playerid][Money] -= Business[i][BusinessEnterFee];
                        SetPlayerVirtualWorld(playerid, Business[i][BusinessWorld]);
                        format(string, sizeof(string), "~w~%s~n~~r~Trьki /v2lju et vдljuda hoones", Business[i][BusinessName]);
                        GameTextForPlayer(playerid, string, 3000, 5);
                        LoadInterior(playerid);
                        FadePlayerScreen(playerid, BLACK, 5);
                    }
                    else return SendClientMessage(playerid, GREY, "Sul pole piisavalt raha, et siia siseneda.");
                }
                else return SendClientMessage(playerid, WHITE, "Siia firmasse ei saa hetkel siseneda.");
            }
        }
    }
    return 1;
}
Problem is, i want to change /enter on key. If press key "n", then enter building and exit use "n" too. I tried to make something, it wont work, errors appears. Here only enter command...

pawn Код:
if(newkeys == KEY_NO)
{
    if(GetPlayerState(playerid) == PLAYER_STATE_ONFOOT)
    {
        if(newkeys == KEY_NO)
        {
            command_enter;
            return 1;
        }
    }
}
Reply
#2

Get guide from here
OnPlayerKeyStateChange
GetPlayerKeys
Reply
#3

pawn Код:
if(newkeys & KEY_NO)
{
    if(GetPlayerState(playerid) == PLAYER_STATE_ONFOOT)
    {  
        cmd_enter(playerid, params[]);
        return true;
    }
}
Reply
#4

pawn Код:
: error 010: invalid function or declaration
: error 010: invalid function or declaration
: error 021: symbol already defined: "cmd_enter"
: error 010: invalid function or declaration
Those errors appears if i use IZN code.
It's just first time when i use OnPlayerKeyStateChange.
Reply
#5

pawn Код:
if(newkeys == KEY_NO)
{
    if(GetPlayerState(playerid) == PLAYER_STATE_ONFOOT)
    {
            command_enter;
            return 1;
    }
}
Reply
#6

remove '[]' in CMD_enter.
or
try

pawn Код:
return cmd_enter(playerid, params)
Rep if right


This forum requires that you wait 240 seconds between posts. Please try again in 183 seconds. :@ fuck it
Reply
#7

pawn Код:
if(newkeys == KEY_NO) --line 11486
{
     if(GetPlayerState(playerid) == PLAYER_STATE_ONFOOT) --line 11488
    {
        return cmd_sisene(playerid, params); -- line11490
        return true; -- line 11491
    }
}
(11486) : error 010: invalid function or declaration
(11488 : error 010: invalid function or declaration
(11490) : error 010: invalid function or declaration
(11491) : error 010: invalid function or declaration
Reply
#8

Maybe someone know the solution?
Reply
#9

pawn Код:
new
    bool: PlayerInHouse[ MAX_PLAYERS char ]
;

// OnPlayerConnect:
PlayerInHouse{ playerid } = false;

// OnPlayerKeyStateChange:
if(newkeys & KEY_NO)
{
    if(GetPlayerState(playerid) == PLAYER_STATE_ONFOOT)
    {
        if(!PlayerInHouse{ playerid })
        {
            PlayerInHouse{ playerid } = true;
            return cmd_enter(playerid, "");
        }
        else
        {
            PlayerInHouse{ playerid } = false;
            return cmd_exit(playerid, "");
        }
    }
}
Reply
#10

pawn Код:
if(newkeys == KEY_NO)
{
    if(GetPlayerState(playerid) == PLAYER_STATE_ONFOOT)
    {
        CallLocalFunction("OnPlayerCommandText", "is", playerid, "/enter");
        //https://sampwiki.blast.hk/wiki/CallLocalFunction
    }
}
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)