SA-MP Forums Archive
!IsPlayerConnected - 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: !IsPlayerConnected (/showthread.php?tid=550241)



!IsPlayerConnected - nezo2001 - 11.12.2014

Here is my command
PHP Code:
CMD:check(playerid,params[])
{
    new 
targetid;
    
    if(
sscanf(params,"d",targetid)) return SendClientMessage(playerid,-1,"Usage: /check [playerid]");
    if(
PInfo[playerid][pDriver] == 1)
    {
        
SendClientMessage(playerid,-1,"Player has a license.");
    }
    else if(
PInfo[playerid][pDriver] == 0)
    {
     
SendClientMessage(playerid,-1,"Player doesnt have a license.");
    }
    else if(!
IsPlayerConnected(id))
     {
     
SendClientMessage(playerid,-4,"That player is not connected!");
     }
    return 
1;

It works but when i type `/check [any other id that isn't connected] it also send me "Player has a license" what should i do ??


Re: !IsPlayerConnected - HY - 11.12.2014

pawn Code:
CMD:check(playerid,params[])
{
    new targetid;
    if(sscanf(params,"u",targetid)) return SendClientMessage(playerid,-1,"Usage: /check [playerid]");
    if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid, -1, "That player isn't connected!");
    if(PInfo[playerid][pDriver] == 0) return SendClientMessage(playerid, -1, "That player doesn't have license.");
    if(PlayerInfo[playerid][pDriver] == 1) return SendClientMessage(playerid, -1, "That player have driving license!");
    return 1;
}



Re: !IsPlayerConnected - nezo2001 - 11.12.2014

Quote:
Originally Posted by HY
View Post
pawn Code:
CMD:check(playerid,params[])
{
    new targetid;
    if(sscanf(params,"u",targetid)) return SendClientMessage(playerid,-1,"Usage: /check [playerid]");
    if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid, -1, "That player isn't connected!");
    if(PInfo[playerid][pDriver] == 0) return SendClientMessage(playerid, -1, "That player doesn't have license.");
    if(PlayerInfo[playerid][pDriver] == 1) return SendClientMessage(playerid, -1, "That player have driving license!");
    return 1;
}
Thank you but i want to add other thing
if (PInfo[playerid][pCop] >= 1
allow him to use the command and if not send him a client message
"You are not a police officer"
if you make it i will rep you :


Re: !IsPlayerConnected - M4D - 11.12.2014

pawn Code:
if(PInfo[playerid][pCop] < 1) return SendClientMessage(playerid,-1,"You are not a police officer");
if you use sscanf , it will automaticly check player is online or no
and you don't need to use "IsPlayerConnected" !


Re: !IsPlayerConnected - Schneider - 11.12.2014

Quote:
Originally Posted by nezo2001
View Post
Thank you but i want to add other thing
if (PInfo[playerid][pCop] >= 1
allow him to use the command and if not send him a client message
"You are not a police officer"
if you make it i will rep you :

pawn Code:
CMD:check(playerid,params[])
{
    new targetid;
    if (PInfo[playerid][pCop] < 1) return SendClientMessage(playerid, -1, "You are not a police officer");
    if(sscanf(params,"u",targetid)) return SendClientMessage(playerid,-1,"Usage: /check [playerid]");
    if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid, -1, "That player isn't connected!");
    if(PInfo[playerid][pDriver] == 0) return SendClientMessage(playerid, -1, "That player doesn't have license.");
    if(PlayerInfo[playerid][pDriver] == 1) return SendClientMessage(playerid, -1, "That player has a driving license!");
    return 1;
}