That user is not connected.
#1

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!");
}
Reply
#2

Do you have the latest sscanf (the plugin version)?
Reply
#3

If it happens to be 2.5.2, then yes.
Reply
#4

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");
Reply
#5

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;
}
Reply
#6

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.
Reply
#7

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.
Reply
#8

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!");
}
Reply
#9

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!");
}
Reply
#10

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


Forum Jump:


Users browsing this thread: 1 Guest(s)