[HELP] check if player is online when using offline command - 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] check if player is online when using offline command (
/showthread.php?tid=569962)
[HELP] check if player is online when using offline command -
Luca12 - 04.04.2015
Hello. So I have offline command /offcheck and what I want is that if admin use that command on online player then I want to send him a message you cannot use this command on online player. I use sscanf like
if(sscanf(params,"s[128]",offnick))
Thanks.
AW: [HELP] check if player is online when using offline command -
Mencent - 04.04.2015
Hello!
Do you mean it like that?
PHP код:
CMD:offcheck(playerid,params[])
{
new pID;
if(sscanf(params,"u",pID))return SendClientMessage(playerid,-1,"Use /offcheck [playerid]");
if(IsPlayerConnected(pID))
{
SendClientMessage(playerid,-1,"you cannot use this command on online player");
return 1;
}
//If the player isn't connected
return 1;
}
Re: [HELP] check if player is online when using offline command -
Sellize - 04.04.2015
Untested but should work
PHP код:
CMD:offcheck(playerid,params[])
{
new offnick[MAX_PLAYER_NAME];
if(sscanf(params,"s[128]",offnick)) return SendClientMessage(playerid, -1, "Usage: /offcheck [full name]");
if(IsPlayerConnected(GetPlayerIdFromName(offnick)) return SendClientMessage(playerid, -1, "You cannot use this command on online players.");
// Code
return 1;
}
stock GetPlayerIdFromName(playername[])
{
for(new i = 0; i <= MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
new playername2[MAX_PLAYER_NAME];
GetPlayerName(i, playername2, sizeof(playername2));
if(strcmp(playername2, playername, true, strlen(playername)) == 0)
{
return i;
}
}
}
return INVALID_PLAYER_ID;
}
Re: AW: [HELP] check if player is online when using offline command -
Luca12 - 04.04.2015
Quote:
Originally Posted by Mencent
Hello!
Do you mean it like that?
PHP код:
CMD:offcheck(playerid,params[])
{
new pID;
if(sscanf(params,"u",pID))return SendClientMessage(playerid,-1,"Use /offcheck [playerid]");
if(IsPlayerConnected(pID))
{
SendClientMessage(playerid,-1,"you cannot use this command on online player");
return 1;
}
//If the player isn't connected
return 1;
}
|
Thank you mencent work perfect