unjail only for ID 0 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)
+--- Thread: unjail only for ID 0 problem. (
/showthread.php?tid=348279)
unjail only for ID 0 problem. -
MarkoN - 04.06.2012
pawn Код:
if(!strcmp(cmdtext, "/jail", true, 5))
{
if(Admin[playerid] >= 1 )
{
SendClientMessage(playerid, COLOR_RED, "WARNING : AFTER JAILING A PLAYER UNJAIL HIM AFTER 2 MIN");
if(!strlen(cmdtext[6]))
{
SendClientMessage(playerid, COLOR_RED, "Usage /jail [playerid]");
return 1;
}
new ID = strval(cmdtext[6]);
new strv[170];
if(IsPlayerConnected(ID))
{
format(strv, 170, "You have been jailed");
SendClientMessage(ID,COLOR_ORANGE, strv);
SetPlayerPos(ID, 264.8763,78.9862,1001.0390);
SetPlayerInterior(ID, 6);
}
}
else
{
SendClientMessage(playerid,COLOR_RED,"You are not an admin!");
}
return 1;
}
if(!strcmp(cmdtext, "/unjail", true, 7))
{
if(Admin[playerid] >= 1 )
{
if(!strlen(cmdtext[8]))
{
SendClientMessage(playerid, COLOR_RED, "Usage : /unjail [playerid]");
return 1;
}
new ID = strval(cmdtext[8]);
new strv[171];
if(IsPlayerConnected(ID))
{
format(strv, 171, "You have been Unjailed");
SendClientMessage(ID,COLOR_ORANGE, strv);
SetPlayerPos(ID, 1553.4637,-1675.6656,16.1953);
SetPlayerInterior(ID, 0);
}
}
else
{
SendClientMessage(playerid,COLOR_RED,"You are not an admin!");
}
return 1;
}
Jail works just fine, but /unjail only works for ID 0 .
Re: unjail only for ID 0 problem. -
Sandiel - 04.06.2012
For this you will be needing ZCMD, and sscanf. ZCMD is far more better than strcmp, seriously.
pawn Код:
COMMAND:unjail(playerid, params[])
{
if(PlayerInfo[playerid][pAdmin] >= 1)
{
new targetid;
if(!sscanf(params, "u", targetid))
{
if(IsPlayerConnected(targetid))
{
if(IsPlayerInRangeOfPoint(targetid, 3, jailX, jailY, jailZ))
{
SetPlayerPos(targetid, somewhereX, somewhereY, somewhereZ);
new pName[MAX_PLAYER_NAME], aName[MAX_PLAYER_NAME], str[128];
GetPlayerName(playerid, aName, sizeof(aName));
GetPlayerName(targetid, pName, sizeof(pName));
format(str, sizeof(str), "AdmCmd: %s has been released by %s from his jail time", pName, aName);
SendClientMessageToAll(COLOR_RED, str);
}
}
}
}
return 1;
}
Re: unjail only for ID 0 problem. -
park4bmx - 04.06.2012
All characters from a string count !
Try that instead of 8
reason
Becouse you have selected the string after the 8 character it leave you with nothing!
So it retrieves it as ID 0
Becouse 0 = nothing