/arrest still not working - 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)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: /arrest still not working (
/showthread.php?tid=66955)
/arrest still not working -
StrickenKid - 25.02.2009
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;
}
Re: /arrest still not working -
brett7 - 25.02.2009
what errors have you got?
Re: /arrest still not working -
StrickenKid - 26.02.2009
none, it just dont work.....
Re: /arrest still not working -
Jefff - 26.02.2009
Код:
new closest;
new closestlvl;
closest = GetClosestPlayer(strval(cmdtext[8]));
closestlvl = GetPlayerWantedLevel(strval(cmdtext[8]));
and
Код:
gPlayerJailed[strval(cmdtext[8])] = 1;
?
Re: /arrest still not working -
Salmon - 26.02.2009
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;
}