OnPlayerKeyStateChange
#1

somebody help me here please, i want to make a key to arrest and issue a ticket to a player, so this would be easy to arrest and issue a tk instead of writing a command.

i made a script but it doesn't check if the targetid is in range of point, any ideas ?

pawn Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    new targetid, string[128];
    new Random = random(sizeof(RandomJail));
    if(LawEnforcementMode[playerid] == 1)
    {
        if ((newkeys & KEY_SUBMISSION) && !(oldkeys & KEY_SUBMISSION))
        {
            if(GetDistanceBetweenPlayers(playerid,targetid) > AVAILABLE_DISTANCE) return SendClientMessage(playerid, COLOR_WHITE, "Error: There is no player in range.");
            if(1<=GetPlayerWantedLevel(targetid)<=3)
            {
                if(PlayerInfo[targetid][pTicket] == 0)
                {
                    PlayerInfo[targetid][pTicket] = 1;
                    SetPlayerScore(playerid,GetPlayerScore(playerid)+1);
                    format(string, sizeof(string), "%s(%d) has issued you a ticket for $4000, type /pay to pay it", GetName(playerid), playerid);
                    SendClientMessage(targetid, COLOR_WHITE,string);
                    GameTextForPlayer(targetid,"~w~Ticket is Issued~n~~Type /pay to pay it",5000,4);
                }
            }
            else if(GetPlayerWantedLevel(targetid)>=4)
            {
                SetPlayerWantedLevel(targetid,0);
                ResetPlayerWeapons(targetid);
                PlayerInfo[targetid][pJailed] = 1;
                SetPlayerInterior(targetid,3);
                SetPlayerPos(targetid, RandomJail[Random][0], RandomJail[Random][1], RandomJail[Random][2]);
                SetPlayerFacingAngle(targetid, RandomJail[Random][3]);
                SetCameraBehindPlayer(targetid);
                SetPlayerVirtualWorld(targetid,1);
                format(string, sizeof(string), "%s(%d) has been Arrested by %s(%d)", GetName(targetid), targetid, GetName(playerid), playerid);
                SendClientMessageToAll(COLOR_WHITE,string);
            }
        }
    }
    return 1;
}
Reply
#2

GetDistanceBetweenPlayers most likely failed. Get the position of the targetid and check if the player is not in range of those coordinates with range to AVAILABLE_DISTANCE.
Reply
#3

FIXED
THANK YOU
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)