aJail command problem - 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: aJail command problem (
/showthread.php?tid=253704)
aJail command problem -
BizzyD - 07.05.2011
Alright, I got a problem with my /ajail command. It is scripted with sscanf & zcmd. And i am new to sscanf. I dont understand it so good. But when i write /ajail 1(my ID) 5(5 mins) test(reason) it just shows up: You cant jail NPCS!
This is my code:
pawn Код:
CMD:ajail(playerid, params[])
{
new
user,
ajailtime,
szReason[32],
giveplayerid;
if(sscanf(params, "us[32]", user, ajailtime, szReason))
return SendClientMessage(playerid, RED, "[LOST:RP] /ajail [ID] [TIME] [REASON]");
if(IsPlayerNPC(giveplayerid))
return SendClientMessage(playerid, RED, "[LOST:RP] You cant ajail npcs");
if(PlayerInfo[playerid][pAdmin] == 0)
return SendClientMessage(playerid, RED, "[LOST:RP] You are not a admin");
if(PlayerInfo[playerid][pAdmin] < 2)
return SendClientMessage(playerid, RED, "[LOST:RP] You are not a admin or you are a to low one");
if(PlayerInfo[playerid][pAdmin] > 3)
{
new
sendername[MAX_PLAYER_NAME],
string[128],
giveplayer[MAX_PLAYER_NAME];
GetPlayerName(user, giveplayer, sizeof(giveplayer));
GetPlayerName(playerid, sendername, sizeof(sendername));
PlayerInfo[user][pJailed] = 1;
PlayerInfo[user][pJailTime] = ajailtime*60;
SetPlayerInterior(user, 6);
SetPlayerVirtualWorld(playerid, 0);
SetPlayerPos(user, 264.6288,77.5742,1001.0391);
SetPlayerFacingAngle(user, -90);
format(string, sizeof(string), "You got jailed! %d minutes left.", ajailtime);
SendClientMessage(user, RED, string);
}
return 1;
}
Anyone know how to fix this?
Again, Im new to sscanf.
Re: aJail command problem -
Seven_of_Nine - 07.05.2011
You didn't set giveplayerid.
Do like this
Re: aJail command problem -
BizzyD - 07.05.2011
That worked with the npc thing :P But now when i write /ajail 1 5 test it says: Invaild command
Re: aJail command problem -
austin070 - 07.05.2011
pawn Код:
if(sscanf(params, "uis[32]", user, ajailtime, szReason))
You can't have 2 formats with 3 definitions. You need an integer value for "ajailtime", hence the "i" between the "u" and the "s[32]".
Re: aJail command problem -
BizzyD - 07.05.2011
Works fine now
Thanks
and i'll remember that with the UIS
Re: aJail command problem -
Seven_of_Nine - 07.05.2011
Look:
u = username, playerid
i,d = integer
s = string
And you format the sscanf with these.
Re: aJail command problem -
BizzyD - 07.05.2011
ahh okey
Thanks