SA-MP Forums Archive
Error player 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: Error player not connected (/showthread.php?tid=529338)



Error player not connected - SnG.Scot_MisCuDI - 01.08.2014

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;
}



Re: Error player not connected - Adamss - 01.08.2014

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.


Re: Error player not connected - SnG.Scot_MisCuDI - 01.08.2014

Nope, now it says
Quote:

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

and then crashes the server :/


Re: Error player not connected - Adamss - 01.08.2014

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


Re: Error player not connected - SnG.Scot_MisCuDI - 01.08.2014

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