22.01.2014, 11:09
Yes, your code is horrible. I will show you where you went wrong in your code. (NOTE: Even after being fixed, it still will not work the way you want it to, so use the one I have provided for you.)
I stopped commenting about half way through because there was just too many things wrong with it. Keep practicing and you will get there in as little as a few weeks. To be honest, I learned how to script by editing releases of other people's filterscripts and gamemodes. Just read it, understand what it's doing, learn it, remember it, master it.
pawn Код:
COMMAND:ban(playerid, params[])
{
//if (PInfo[playerid][Level] > 1 || (!IsPlayerAdmin [playerid] return 0
if(PInfo[playerid][Level] < 1 && !IsPlayerAdmin(playerid)) return 0; //This line translates to: If the player's admin level is LESS than 1, AND they are not
//logged into RCON, then return 0 and do not process the command.
//new targetid,[playerid];
new targetid; //playerid is already defined in the COMMAND:ban(playerid... line. Indentation is not very good here.
//Also, you should add this AFTER you check if they're an admin, otherwise you will create this for no reason if they're not one.
//else if (sscanf(params,"us',targetid,name)SendClientMessage,(playerid,YELLOW,"Usage /ban [playerid].");
if(sscanf(params, "u", targetid) return SendClientMessage(playerid, YELLOW, "Usage: /ban [playerid].");
//There is no need to use an 'else if' statement here. Also, make sure you RETURN SendClientMessage, or the code will still continue.
//You do not need an 'else' statement here, as the code will end if the above if statement is not met because of the 'return'.
Ban(targetid); //Missing a ';' at the end.
new string[85], Name[MAX_PLAYER_NAME], pName[MAX_PLAYER_NAME]; //You need to define 'string' before you use it... (Unless you have a global variable, which I highly do not recommend)
GetPlayerName(playerid, Name, sizeof(Name));
GetPlayerName(targetid, pName, sizeof(pName));
format(string, sizeof(string), "Administrator %s has banned %s[ID:%d]", Name, pName, targetid);
SendClientMessageToAll(playerid, PINK, string);
return 1;
}

