if(!isnull(params)) BannedFromServer[params] = true;
CMD:ban(playerid, params[])
{
if(PlayerInfo[playerid][pAdmin] < 2)
return SendClientMessage(playerid, COLOR_GREY, "{FF0000}Error: {FFFFFF}Wrong command!! {FF0000}Check availables commands from here `{FFFFFF}/cmds{FF0000}`.");
new
pName[MAX_PLAYER_NAME],
tName[MAX_PLAYER_NAME],
targetid,
string[128],
reason[80]
;
if(!aDuty[playerid])
return SendClientMessage(playerid, COLOR_GREY, "{FF0000}Error: {FFFFFF}You must be ADMIN ON DUTY to kick someone.");
if(sscanf(params, "us[80]", targetid, reason))
return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /ban [playerid] [reason]");
if(!IsPlayerConnected(targetid))
return SendClientMessage(playerid, COLOR_GREY, "{FF0000}Error: {FFFFFF}INVAILD PLAYER ID / NAME.");
if(PlayerInfo[playerid][pAdmin] < PlayerInfo[targetid][pAdmin])
return SendClientMessage(playerid, COLOR_GREY, "{FF0000}Error: {FFFFFF}Player has a higher admin level than you. [CAN'T BANNED]!");
if(!isnull(params)) BannedFromServer[params] = true;
GetPlayerName(playerid,pName,sizeof(pName));
GetPlayerName(targetid,tName,sizeof(tName));
format(string, sizeof(string), "{FB00FF}[BANNED]: PLAYER %s(%d) has been BANNED by Admin %s(%d), REASON: %s.", tName,targetid, pName,playerid, reason);
SendClientMessageToAll(-1, string);
GameTextForPlayer(targetid, "~P~BANNED", 10000, 3);
SetTimerEx("Banned",5200,false,"i",targetid);
return 1;
}
if(!isnull(params)) BannedFromServer[strval(params)] = true;
params is a string (You can determine that by the two square brackets after the parameter, "params[]")
So how you use it, you expect it to work as an integer (index in the array). To do that, you need to convert the string to an integer. Try using strval(params) instead of params only at the last variable. This makes it be an integer. Remember that strval() returns 0 for text as well. https://sampwiki.blast.hk/wiki/Strval PHP код:
Your current method won't hold up. |
public OnPlayerConnect(playerid)
{
if(BannedFromServer[playerid])
{
SendClientMessage(playerid, -1, " You are banned ! ");
return Kick(playerid);
}