SA-MP Forums Archive
That user is not connected. - 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: That user is not connected. (/showthread.php?tid=379827)



That user is not connected. - [MM]18240[FMB] - 23.09.2012

If I do /ban 0 test it says, That user is not connected, while I am ID 0. Happens with all of my commands that involve IDs, making me think I have a fuckup Please try and spot it.
pawn Код:
CMD:ban(playerid, params[])
{
    if(PVar[playerid][pLevel] >= 4)
    {
        new
            PID;
        if(sscanf(params, "us[70]", PID, params)) return SendClientMessage(playerid, COLOR_RED, ""#CRED"USAGE: "#CORANGE"/Ban < Player ID > < Reason >");
        if(!IsPlayerConnected(PID)) return SendClientMessage(playerid, COLOR_RED, "* That user is not connected!");

        SendFMessage(PID, COLOR_LIGHTBLUE, "You have been banned by: %s(%d) for: %s", pName(playerid), playerid, params);
        SendFMessageToAll(COLOR_LIGHTBLUE, "Admin: %s(%d) has banned: %s(%d) for: %s", pName(playerid), playerid, pName(PID), PID, params);

        return BanEx(PID, params);
    }
    else return SendClientMessage(playerid, COLOR_RED, "You are not an admin!");
}



Re: That user is not connected. - Psymetrix - 23.09.2012

Do you have the latest sscanf (the plugin version)?


Re: That user is not connected. - [MM]18240[FMB] - 23.09.2012

If it happens to be 2.5.2, then yes.


Re: That user is not connected. - AtItsMax - 23.09.2012

I've always been facing problems while using this with Sscanf
pawn Код:
if(!IsPlayerConnected(PID)) return SendClientMessage(playerid, COLOR_RED, "* That user is not connected!");
Instead, you can use
pawn Код:
if(PID == INVALID_PLAYER_ID) return SendClientMessage(playerid,-1,"* That user id is invalid");



Re: That user is not connected. - trapstar2020 - 23.09.2012

try this RPN ====pname and u can change the info 2 fit urs but it works 100%

CMD:ban(playerid, params[])
{
new playerb, string[128];
if(PlayerInfo[playerid][pAdmin] < 3) return SendClientMessage(playerid, COLOR_GREY, "You are not authorized to use this command.");
if(!aDuty[playerid]) return SendClientMessage(playerid, COLOR_GREY, "You are not on admin duty.");
if(sscanf(params, "us[128]", playerb, params)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /ban [playerid] [reason]");
if(PlayerInfo[playerid][pAdmin] < PlayerInfo[playerb][pAdmin]) return SendClientMessage(playerid, COLOR_GREY, "Player has a higher admin level than you.");
format(string, sizeof(string), "AdmCmd: %s has been banned by %s, reason: %s", RPN(playerb), RPN(playerid), params);
SendClientMessageToAll(COLOR_LIGHTRED, string);
format(string, sizeof(string), "AdmCmd: %s has been banned by %s (%s), reason: %s", RPN(playerb), RPN(playerid) , RPIP(playerid), params);
// Banning
PlayerInfo[playerb][pBanned] = 1;
AddBan(playerb);
Kick(playerb);
return 1;
}


Re: That user is not connected. - AtItsMax - 23.09.2012

Quote:
Originally Posted by trapstar2020
Посмотреть сообщение
try this RPN ====pname and u can change the info 2 fit urs but it works 100%

CMD:ban(playerid, params[])
{
new playerb, string[128];
if(PlayerInfo[playerid][pAdmin] < 3) return SendClientMessage(playerid, COLOR_GREY, "You are not authorized to use this command.");
if(!aDuty[playerid]) return SendClientMessage(playerid, COLOR_GREY, "You are not on admin duty.");
if(sscanf(params, "us[128]", playerb, params)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /ban [playerid] [reason]");
if(PlayerInfo[playerid][pAdmin] < PlayerInfo[playerb][pAdmin]) return SendClientMessage(playerid, COLOR_GREY, "Player has a higher admin level than you.");
format(string, sizeof(string), "AdmCmd: %s has been banned by %s, reason: %s", RPN(playerb), RPN(playerid), params);
SendClientMessageToAll(COLOR_LIGHTRED, string);
format(string, sizeof(string), "AdmCmd: %s has been banned by %s (%s), reason: %s", RPN(playerb), RPN(playerid) , RPIP(playerid), params);
// Banning
PlayerInfo[playerb][pBanned] = 1;
AddBan(playerb);
Kick(playerb);
return 1;
}
Copy-paste detected.


Re: That user is not connected. - [MM]18240[FMB] - 23.09.2012

Quote:
Originally Posted by AtItsMax
Посмотреть сообщение
I've always been facing problems while using this with Sscanf
pawn Код:
if(!IsPlayerConnected(PID)) return SendClientMessage(playerid, COLOR_RED, "* That user is not connected!");
Instead, you can use
pawn Код:
if(PID == INVALID_PLAYER_ID) return SendClientMessage(playerid,-1,"* That user id is invalid");
Undefined symbol(PID)
Also, I am not even trying that stolen one that has admin duty or some shit. Clean up your stolen code, brah.


Re: That user is not connected. - AtItsMax - 23.09.2012

pawn Код:
CMD:ban(playerid, params[])
{
    if(PVar[playerid][pLevel] >= 4)
    {
        new
            PID;
        if(sscanf(params, "us[70]", PID, params)) return SendClientMessage(playerid, COLOR_RED, ""#CRED"USAGE: "#CORANGE"/Ban < Player ID > < Reason >");
       if(PID == INVALID_PLAYER_ID) return SendClientMessage(playerid,-1,"* That user id is invalid"); // now feeling good being spoon-feeded?

        SendFMessage(PID, COLOR_LIGHTBLUE, "You have been banned by: %s(%d) for: %s", pName(playerid), playerid, params);
        SendFMessageToAll(COLOR_LIGHTBLUE, "Admin: %s(%d) has banned: %s(%d) for: %s", pName(playerid), playerid, pName(PID), PID, params);

        return BanEx(PID, params);
    }
    else return SendClientMessage(playerid, COLOR_RED, "You are not an admin!");
}



Re: That user is not connected. - [MM]RoXoR[FS] - 23.09.2012

pawn Код:
CMD:ban(playerid, params[])
{
    if(PVar[playerid][pLevel] >= 4)
    {
        new
            PID,reason[70];
        if(sscanf(params, "us[70]", PID, reason)) return SendClientMessage(playerid, COLOR_RED, ""#CRED"USAGE: "#CORANGE"/Ban < Player ID > < Reason >");
        if(!IsPlayerConnected(PID)) return SendClientMessage(playerid, COLOR_RED, "* That user is not connected!");

        SendFMessage(PID, COLOR_LIGHTBLUE, "You have been banned by: %s(%d) for: %s", pName(playerid), playerid, reason);
        SendFMessageToAll(COLOR_LIGHTBLUE, "Admin: %s(%d) has banned: %s(%d) for: %s", pName(playerid), playerid, pName(PID), PID, reason);

        return BanEx(PID, reason);
    }
    else return SendClientMessage(playerid, COLOR_RED, "You are not an admin!");
}



Re: That user is not connected. - [MM]18240[FMB] - 23.09.2012

Just says, "That user ID is invalid." when I try to /ban 0 Test