Problem with INVALID_PLAYER_ID - 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: Problem with INVALID_PLAYER_ID (
/showthread.php?tid=96805)
Problem with INVALID_PLAYER_ID -
Gappy - 11.09.2009
INVALID_PLAYER_ID doesn't seem to be working right.
I've got this command, along with heaps others and even if I do an invalid ID the command still gets called.
This is the code(all my other commands use the same code):
pawn Code:
zcmd(kick, playerid, params[])
{
if (AccountInfo[playerid][AdminLevel] >= 1 || IsPlayerAdmin(playerid))
{
new tmp[256], idx;
tmp = strtok(params, idx);
if (isnull(tmp))
{
SendClientMessage(playerid, COLOR_WHITE, "USAGE: /kick [playerid] [reason]");
return 1;
}
new targetid = strval(tmp);
new reason[128];
reason = bigstrtok(params, idx);
if (targetid != INVALID_PLAYER_ID)
{
new sendername[MAX_PLAYER_NAME];
new targetname[MAX_PLAYER_NAME];
GetPlayerName(targetid, targetname, sizeof(targetname));
GetPlayerName(playerid, sendername, sizeof(sendername));
printf("ADMIN: %s has kicked %s, Reason: %s.", sendername, targetname, reason);
format(tmp, sizeof(tmp), "ADMIN: Administrator %s has kicked %s, Reason: %s.", sendername,targetname,reason);
SendClientMessageToAll(COLOR_LIGHTRED, tmp);
Kick(targetid);
KickLog(tmp);
}
else return SendClientMessage(playerid, COLOR_RED, "Invalid Player ID!");
}
else SendClientMessage(playerid, COLOR_GREY, "You are not authorized to use that command!");
return 1;
}
Re: Problem with INVALID_PLAYER_ID -
Simon - 11.09.2009
INVALID_PLAYER_ID is a number, you must set your variable to INVALID_PLAYER_ID for it to work.
pawn Code:
if ( !IsPlayerConnected( targetid ) )
{
targetid = INVALID_PLAYER_ID ;
}
Best thing to do would be to change
pawn Code:
if (targetid != INVALID_PLAYER_ID)
to
pawn Code:
if ( !IsPlayerConnected( targetid ) )
Re: Problem with INVALID_PLAYER_ID -
Gappy - 11.09.2009
Cheers man, it works.