cmd doesn't check if player is connected
#1

Hey, I've built a simple ban cmd for admins, now it doesn't check if the player is connected or no, it just simply does the command and bans an unexisting id...

this is the command
Код:
CMD:ban(playerid, params[])
{
    new id, reason[50], string[128], banned[MAX_PLAYER_NAME];
    if(PlayerInfo[playerid][pAdmin] < 1) return SendClientMessage(playerid,-1,"You are not an admin.");
    if(sscanf(params, "uz", id, reason)) return SendClientMessage(playerid, -1, "USAGE: /ban [playerid] [reason(optional)]");
    if(!IsPlayerConnected(id)) return SendClientMessage(playerid, -1,"ERROR: Invalid targetid."); //this is the line 
   	GetPlayerName(id, banned, sizeof(banned));
   	format(string, sizeof(string), "AdmCmd: %s has been banned by %s. reason: %s", banned, GetName(playerid), reason);
   	SendClientMessageToAll(-1, string);
   	BanEx(id, reason);
    return 1;
}
Thanks.
Reply
#2

pawn Код:
if(id == INVALID_PLAYER_ID || !IsPlayerConnected(id)) return SendClientMessage(playerid, -1,"ERROR: Invalid targetid.");
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)