/arrest still not working
#1

ok so i finished scripting a /arrest cmd but its not working, can someone plz fix it, or tell me whats wrorng, thanks
pawn Код:
if(strcmp("/arrest", cmdtext, true, 7) == 0)
    {
        if(gTeam[playerid] != TEAM_COP) return SendClientMessage(playerid, COLOR_RED, "You Are Not A Cop. Only Cops Can Use This Command.");
        if(strlen(cmdtext[8]) == playerid) return SendClientMessage(playerid,COLOR_RED,"You Cannot Arrest Yourself, Idoit.");

        if(strlen(cmdtext[8]) == 0){

        new closest[MAX_PLAYERS];
        new closestlvl;
        closest[playerid] = GetClosestPlayer(1);
        closestlvl = GetPlayerWantedLevel(closest[playerid]);
        if(closestlvl >= 4)
        {


        new copname[MAX_PLAYER_NAME];
        new cmdname[MAX_PLAYER_NAME], string[128];

        GetPlayerName(playerid, copname, sizeof(cmdname));
        GetPlayerName(strval(cmdtext[8]), cmdname, sizeof(cmdname));

        format(string, sizeof(string), "%s (%d) Has Been Arested By Officer %s (%d)", cmdname,strval(cmdtext[8]),copname,playerid);
        SendClientMessageToAll(COLOR_PURPLE, string);

        new rand;
        rand = random(sizeof(AJail));
        SetPlayerInterior(strval(cmdtext[8]), 3);
        SetPlayerPos(strval(cmdtext[8]), AJail[rand][0], AJail[rand][1], AJail[rand][2]);
        gPlayerJailed[playerid] = 1;
        SetPlayerWantedLevel(strval(cmdtext[8]),0);

        return 1;
        } else return SendClientMessage(playerid,COLOR_RED,"No Wanted Players Close Enough TO Arrest.");

        }
       
        return 1;
    }
Reply
#2

what errors have you got?
Reply
#3

none, it just dont work.....
Reply
#4

Код:
new closest;
new closestlvl;
closest = GetClosestPlayer(strval(cmdtext[8]));
closestlvl = GetPlayerWantedLevel(strval(cmdtext[8]));
and

Код:
gPlayerJailed[strval(cmdtext[8])] = 1;
?
Reply
#5

Try this for a closestwanted player, just tweak it how you want it, seems to work for me.
pawn Код:
stock GetClosestWantedPlayer(playerid) //By Slick (edited by Gabriel "Larcius" Cordes and Salmon)
{
    if(IsPlayerConnected(playerid) && IsPlayerConnected(0))
    {
        new closestplayer=0;
        new Float:closestdist=GetDistanceBetweenPlayers(playerid,0);
        for(new playerid2=0; playerid2<MAX_PLAYERS; playerid2++)
        {
        if(gTeam[playerid2] == TEAM_CRIMS)
        {
            new Float:dist = GetDistanceBetweenPlayers(playerid,playerid2);
            if ((dist < closestdist))
            {
                closestdist = dist;
                closestplayer = playerid;
            }
        }
        }
        return closestplayer;
    }
    return -1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)