SA-MP Forums Archive
/ajail Help - 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: /ajail Help (/showthread.php?tid=409238)



/ajail Help - Noles2197 - 20.01.2013

PHP код:
CMD:ajail(playeridparams[])
{
    if(
PlayerInfo[playerid][pAdmin] > 0)
    {
        new 
name[MAX_PLAYER_NAME],name2[MAX_PLAYER_NAME],string[128],id,reason[64],time;
        if(
sscanf(params,"ds[64]",id,time,reason)) return SendClientMessage(playerid,GRAY,"CMD: /ajail <playerid> <minutes> <reason>");
        
GetPlayerName(playerid,namesizeof(name));
        
GetPlayerName(id,name2sizeof(name2));
        if(!
IsPlayerConnected(id)) return SendClientMessage(playeridGRAY,"CMD: Invalid playerid.");
        
format(stringsizeof(string), "Administrator %s admin jailed %s %s minutes for %s."name,name2,time,reason);
        
SendClientMessageToAll(PINK,string);
        
SetPlayerPos(id,-1425.1499,1490.4562,1.8672);
    } 
// Administrator Noles2197 admin jailed Noles2197  minutes for 60 dm."
    
return 1;

appears as "Administrator Noles2197 admin jailed Noles2197 minutes for 60 dm."
The time and reason seem to be getting mixed up and I think it has something to do with..
"if(sscanf(params,"ds[64]",id,time,reason)) return SendClientMessage(playerid,GRAY,"CMD: /ajail <playerid> <minutes> <reason>");"


Re: /ajail Help - Chenko - 20.01.2013

When formatting a number into a string use "%d" not "%s". Also,

pawn Код:
if(sscanf(params,"ds[64]",id,time,reason)) return SendClientMessage(playerid,GRAY,"CMD: /ajail <playerid> <minutes> <reason>");
Should be:

pawn Код:
if(sscanf(params,"uds[64]",id,time,reason)) return SendClientMessage(playerid,GRAY,"CMD: /ajail <playerid> <minutes> <reason>");
You forgot to put the "u" parameter for playerid.