Help returning a client message. - 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: Help returning a client message. (
/showthread.php?tid=443455)
Help returning a client message. -
Strier - 12.06.2013
pawn Код:
CMD:pauser(playerid, params[])
{
new player, pName[MAX_PLAYER_NAME];
if( sscanf ( params, "u", player)) return SendClientMessage(playerid, -1, "Usage: /pauser [ playerid ]");
if(AfkOn[ player ] == true) return SendClientMessage(playerid, -1, "This player is not pausing!");
if(IsPlayerConnected(player))
{
if(AfkOn[ player ] == true)
{
if(afksecs[ player ] > 2)
{
new str[ 75 ];
GetPlayerName(player, pName, MAX_PLAYER_NAME);
format(str, 75, "%s[%d] has been afk for %d seconds ", pName, player, afksecs[ player ]);
SendClientMessage(playerid, -1, str);
if(afksecs[ player ] < 2) return SendClientMessage(playerid, -1, "This player is not pausing!");
}
}
}else return SendClientMessage(playerid, -1, "This player is not connected!");
return 1;
}
Help me on returning this line else return SendClientMessage(playerid, -1, "This player is not connected!");
for IsPlayerConnected, please.. i tried almost three different ways and it says "ERROR:Server unknown command" when typing another player's id that is not connected, but when i type a valid id the command processes.
Re: Help returning a client message. -
JaKe Elite - 12.06.2013
why use IsPlayerConnected?
If you can use INVALID_PLAYER_ID by comparing it to the player.
If player and INVALID_PLAYER_ID match it means the playerID that the player trying to input is not in the server!
Anyways here is the code
pawn Код:
CMD:pauser(playerid, params[])
{
new player, pName[MAX_PLAYER_NAME];
if(sscanf(params, "u", player)) return SendClientMessage(playerid, -1, "Usage: /pauser [playerid]");
if(AfkOn[player] == true) return SendClientMessage(playerid, -1, "This player is not pausing!");
if(player == INVALID_PLAYER_ID) return SendClientMessage(playerid, -1, "This player is not connected!");
if(AfkOn[player] == true)
{
if(afksecs[player] > 2)
{
new str[75];
GetPlayerName(player, pName, MAX_PLAYER_NAME);
format(str, 75, "%s[%d] has been afk for %d seconds ", pName, player, afksecs[player]);
SendClientMessage(playerid, -1, str);
if(afksecs[player] < 2) return SendClientMessage(playerid, -1, "This player is not pausing!");
}
}
return 1;
}