SA-MP Forums Archive
HALP! :P - 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: HALP! :P (/showthread.php?tid=584321)



HALP! :P - Fancy - 03.08.2015

This jail command sets unjail timer for playerid 0

Код:
CMD:jail(playerid, params[])
{
	new str[128], id, reason[128],rand = random(sizeof(JailRandomSpawn)),time;
	if(PlayerInfo[playerid][pAdmin] >= 3)
	{
		if(sscanf(params, "usd[128]", id, reason, time)) return GameTextForPlayer(playerid,"~g~/jail~w~~n~(id)~w~~n~(reason)~w~~n~(time)",4500,3);
		if(id == INVALID_PLAYER_ID) return ErrorMessages(playerid, 2);
	    if(PlayerInfo[playerid][pAdmin] < PlayerInfo[id][pAdmin]) return ErrorMessages(playerid, 3);
		if(PlayerInfo[id][Jail] == 1) return SendClientMessage(playerid, COLOR_RED, "That player is already in jail!");
		PlayerInfo[id][Jail] = 1;
		MegaJump[id] = 0;
        SetPlayerPos(id, JailRandomSpawn[rand][0], JailRandomSpawn[rand][1], JailRandomSpawn[rand][2]);
        SetPlayerFacingAngle(id, JailRandomSpawn[rand][3]);
		SetPlayerInterior(id, 3);
		SetCameraBehindPlayer(playerid);
		format(str, sizeof(str), "Admin %s(%d) has jailed %s(%d) for %d minuites (Reason:%s)", GetName(playerid), playerid, GetName(id), id,time,reason);
		SendClientMessageToAll(BAN, str);
		JailLog(playerid, id, reason);
		SetTimerEx("Unjail",time*60000,false, "i", id);
		fr[id] = 0;
		PlayerInfo[id][JailC]++;
		format(str, sizeof(str), "You jailed %s(%d) for %d minuites (Reason:%s)", GetName(id), id,time,reason);
		SendClientMessage(playerid, BAN, str);
        format(str, sizeof(str), ""COL_GREEN"\nYou have been jailed for %d minuites\n(Reason:%s)",time, reason);
       	ShowPlayerDialog(id, 122, DIALOG_STYLE_MSGBOX, ""COL_GREEN"Jailed", str, "OK", "");
	    }
	    else return ErrorMessages(playerid, 1);
    return 1;
}
How can i fix it?


Re: HALP! :P - Jefff - 03.08.2015

Change order
pawn Код:
sscanf(params, "uis[128]", id, time, reason)



Re: HALP! :P - nezo2001 - 03.08.2015

try
PHP код:
if(sscanf(params"us[128]d"idreasontime)) return GameTextForPlayer(playerid,"~g~/jail~w~~n~(id)~w~~n~(reason)~w~~n~(time)",4500,3); 



Re: HALP! :P - Variable™ - 03.08.2015

Removed.


Re: HALP! :P - Crayder - 03.08.2015

Don't try what nexo said, the order is faulty. The string will never terminate.

Jefff however, is correct. Use his sscanf line.

That though doesn't explain why it is calling id 0. Try Jefff's code then come back with results. If the results are bad bring your unjail callback too.