Error player not connected
#1

No matter what ID or name i type it says the player is not connected

pawn Код:
CMD:ban(playerid, params[])
{
    if(!IsAdmin(playerid, 1)) return ErrorMsg(playerid);

    new target;
    new reason = Info[playerid][BanReason];
    if(sscanf(params, "rs[32]", target, reason)) return Usage(playerid, "/ban [player] [reason]");
    if(!IsPlayerConnected(target)) return SendClientMessage(playerid, COLOR_RED, "ERROR: Player is not connected");

    new string[128];
    format(string, sizeof(string), "[ADMIN BAN]: %s has been banned from the server - %s", Name(target), reason);
    SendClientMessageToAll(COLOR_ADMIN, string);
    IRC_GroupSay(gGroupID, IRC_CHANNEL, string);
    format(string,sizeof(string), "[ADMIN CMD]: %s[%i] has banned %s[%i] - %s",Name(playerid),playerid,Name(target),target,reason);
    IRC_GroupSay(gGroupID, IRC_CHANNEL_ADMIN, string);
   
    format(string,sizeof(string), "~w~Banned from the server~n~~r~Reason: %s",reason);
    TextDrawSetString(AnnText, string);
    TextDrawShowForPlayer(target, AnnText);

    BanPlayer(target);
    return 1;
}
here is the ban player stock
pawn Код:
stock BanPlayer(playerid)
{
    new INI:File = INI_Open(UserPath(playerid));
    INI_WriteInt(File,"Banned",1);
    INI_WriteInt(File,"BanReason",Info[playerid][BanReason]);
    INI_Close(File);
    Kick(playerid);
    return 1;
}
Reply
#2

You should use:
Код:
if(sscanf(params, "us[32]", target, reason)) return Usage(playerid, "/ban [player] [reason]");
"U" checks for a player ID/Name.
Then use:
Код:
if(target == INVALID_PLAYER_ID)
This might fix your issue.
Reply
#3

Nope, now it says
Quote:

[ADMIN BAN]: has been banned from the server - reason

and then crashes the server :/
Reply
#4

That's to do with the rest of the banning process, the original problem was fixed.

In your ban stock, instead of opening the player file, just do Info[playerid][Banned] = 1 and format your BanReason too. Then when they disconnect it'll write to their file anyway. Also, you need to have a timer before the player actually gets kicked, read about it here. https://sampwiki.blast.hk/wiki/Kick
Reply
#5

Quote:
Originally Posted by Adamss
Посмотреть сообщение
That's to do with the rest of the banning process, the original problem was fixed.

In your ban stock, instead of opening the player file, just do Info[playerid][Banned] = 1 and format your BanReason too. Then when they disconnect it'll write to their file anyway. Also, you need to have a timer before the player actually gets kicked, read about it here. https://sampwiki.blast.hk/wiki/Kick
ty

4char
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)