SA-MP Forums Archive
/arrest bug - 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)
+--- Thread: /arrest bug (/showthread.php?tid=481604)



/arrest bug - Cat Cola - 16.12.2013

Hello. I got a bug in my script, when LEO's do /arrest it wont work.
It just says: "USAGE: /arrest [playerid] [minutes]"

Here is the command:
Quote:

CMD:arrest(playerid, params[])
{
new playerb, time, string[128];
if(!IsPlayerLoggedIn(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You need to login first before using any command.");
if(!IsACop(playerid) && !IsFBI(playerid) && !IsNG(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You are not a LEO.");
if(!PlayerInfo[playerid][pFacDuty]) return SendClientMessage(playerid, COLOR_GREY, "You are not on duty.");
if(!IsPlayerInRangeOfPoint(playerid, 2, ap[0], ap[1], ap[2])) return SendClientMessage(playerid, COLOR_GREY, "You are not near the arrest point.");
if(sscanf(params, "uis[64]", playerb, time, params)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /arrest [playerid] [minutes]");
if(!IsPlayerLoggedIn(playerb)) return SendClientMessage(playerid, COLOR_GREY, "Invalid player id.");
if(!PlayerInfo[playerb][pWanted]) return SendClientMessage(playerid, COLOR_GREY, "Player is not wanted.");
if(IsACop(playerb) && IsFBI(playerb) && IsNG(playerb)) return SendClientMessage(playerid, COLOR_GREY, "You can't arrest an LSPD Officer.");
if(!IsPlayerNearPlayer(playerid, playerb, 2)) return SendClientMessage(playerid, COLOR_GREY, "You are too far away from that player.");
format(string, sizeof(string), "Local Prison: %s has been arrested by %s.", RPN(playerb), RPN(playerid));
foreach(Player, i)
{
if(IsACop(i) || IsFBI(i) || IsNG(i))
{
SendClientMessage(i, COLOR_BLUE, string);
}
}
SetPlayerColor(playerb, TRANSPARENT_ORANGE);
PlayerInfo[playerb][pArrested] ++;
PlayerInfo[playerb][pPrison] = 2;
PlayerInfo[playerb][pPrisonTime] = time*60;
ClearDodWantedLevels(playerb);
SetPlayerInterior(playerb, 0);
SetPlayerVirtualWorld(playerb, 0);
new RandomCell = random(sizeof(RandomPrison));
SetPlayerFacingAngle(playerb, RandomPrison[RandomCell][3]);
TogglePlayerControllable(playerb, 0);
SetTimerEx("EnterExitTimer", 5000, false, "i", playerb);
SetPlayerPos(playerb, RandomPrison[RandomCell][0], RandomPrison[RandomCell][1], RandomPrison[RandomCell][2]);
SetCameraBehindPlayer(playerb);
format(string, sizeof(string), " You have been arrested by an officer for %d minutes (%d seconds)", PlayerInfo[playerb][pPrisonTime]/60, PlayerInfo[playerb][pPrisonTime]);
SendClientMessage(playerb, COLOR_LIGHTBLUE, string);
RemovePlayerAttachedObject(playerb, 0);
SetPlayerSpecialAction(playerb, SPECIAL_ACTION_NONE);




Re: /arrest bug - Brandon_More - 16.12.2013

pawn Код:
if(sscanf(params, "uds", playerb, time, params)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /arrest [playerid] [minutes] [Reason]");
Not really sure if this would work, your script is not exactly organized.


Re: /arrest bug - dominik523 - 16.12.2013

Replace:
pawn Код:
if(sscanf(params, "uis[64]", playerb, time, params)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /arrest [playerid] [minutes]");
with this:
pawn Код:
if(sscanf(params, "ui", playerb, time)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /arrest [playerid] [minutes]");
EDIT: @Brandon_More the way you wrote the sscanf part would print the warning each time when the command would be executed because you have to specify the length of the 's' specifier.