Banned,
new id;
new reason;
if(sscanf(params, "us", id, reason)) return // etc
Ban(id);
PlayerInfo[playerid][Banned] = 1;
1)
Yes it will save his name in ban lists 2) Ofc, add to your pinfo enum pawn Код:
pawn Код:
About the bans file you can add ban info (reason, ip , name) You can use one of these. P.S PlayerInfo is not the variable you use right? anyways, Like that You can ask more questions if you like |
Password = 173081214
Cash = 0
Admin = 0
Kills = 0
Deaths = 0
Score = 0
Muted = 0
VIP = 0
Reward = 0
TempAdmin = 0
IP = 15
LoggedIn = 0
TimesWarned = 0
TimeKicked = 0
Banned = 0
OriginalName = 0
Jailed = 0
ACBanned = 1
FailedRCON = 0
ACDetected = 0
[B]BannedBy = NAMEHERE
BanReason = REASONHERE[/B]
CMD:ban(playerid, params[])
{
new id;
new reason;
new name[MAX_PLAYER_NAME];
new aname[MAX_PLAYER_NAME];
new string[128];
if(sscanf(params, "us", id, reason)) return SendClientMessage(playerid, RED, "Usage /ban [playerid] [reason]");
if(PlayerInfo[playerid][Admin] >= 2) // you can change the "2" for level you like//
{
GetPlayerName(id, name, sizeof(name));
GetPlayerName(playerid, aname, sizeof(aname));
format(string, sizeof(string), "You have been banned by Administrator %s [Reason: %s]", aname, reason);
SendClientMessage(id, RED, string);
Ban(playerid);
PlayerInfo[playerid][Banned] = 1;
new INI:File = INI_Open(UserPath(playerid));
INI_WriteString("Banned By", aname);
INI_WriteString("Reason", reason);
INI_Close(File);
}
else return SendClientMessage(playerid, RED, "You are not high enough level to use this command");
return 1;
}
stock UserPath(playerid)
{
new string[128]; new name[MAX_PLAYER_NAME]; GetPlayerName(playerid, name, sizeof(name));
format(string, sizeof(string), PATH, name);
return string;
}
Sorry for late mate here's the whole command:
pawn Код:
pawn Код:
if anything dosen't work, tell me. |
stock UserPath(playerid)
{
new string[128],playername[MAX_PLAYER_NAME];
GetPlayerName(playerid,playername,sizeof(playername));
format(string,sizeof(string),PATH,playername);
return string;
}
CMD:ban(playerid, params[]) {
new id; //'defines' the targets id.
new reason[50]; //'defines' the reason.
if(PlayerInfo[playerid][pAdmin] < 2) return SendClientMessage(playerid, COLOR_RED, "[ADMIN] - Only admins can use command!"); //if player isn't a rcon admin, he will receive this "error" message.
if(sscanf(params, "us[50]", id, reason)) return SendClientMessage(playerid, COLOR_ORANGE, "[USAGE] - /ban [ID] [Reason]"); //if there are missing parameters, the admin will receive the usage of this command.
if(id == INVALID_PLAYER_ID) return SendClientMessage(playerid, COLOR_ORANGE, "[NOTE] - Player not found."); //If the targets id isnt found, the admin will receive this message (Player Not found).
if(PlayerInfo[id][pAdmin] == 7) return SendClientMessage(playerid, COLOR_RED, "* One does not simply ban the server owner!");
new string[150], sender[MAX_PLAYER_NAME], receiver[MAX_PLAYER_NAME]; //thanks to this, everyone will be able to see who was kicked, and by who.
GetPlayerName(playerid, sender, sizeof(sender)); //Gets the senders(admins) name/id.
GetPlayerName(id, receiver, sizeof(receiver)); //Gets the receivers(targets) name/id.
format(string, sizeof(string), "[BAN] - %s(%d) has been banned by %s(%d)", receiver, id, sender, playerid);
SendClientMessageToAll(COLOR_RED, string); //Sends the kick message, as seen above ^.
format(string, sizeof(string), "[BAN] - Reason: %s", reason);
SendClientMessageToAll(COLOR_RED, string); //Sends the kick reasons message, as seen above ^
SetTimerEx("BanTimer", 500, false, "i", id); //Sets KickTimer to 1 seond(will be kicked after 1 second)
PlayerInfo[id][pBanned] = 1;
SendClientMessage(id, COLOR_ORANGE, "[BAN] - You've been BANNED"); //Sends Target a message, saying that he was kicked.
SendClientMessage(id, COLOR_ORANGE, "[BAN] - For more info read the chat.");
format(string, sizeof(string), "[ADMIN] - %s[%d] has used BAN on %s[%d]", sender,playerid,receiver,id);
SendMessageToAdmins(COLOR_LIME,string);
printf("ADMIN %s HAS BANNED %s FOR: %s", sender, receiver, reason);
new INI:File = INI_Open(UserPath(id)); //added this as you told, changed to id
INI_WriteString("Banned By", sender); //added this as you told ||error line
INI_WriteString("Reason", reason); //added this as you told ||error line
INI_Close(File); //added this as you told
return 1;
}
test2.pwn(7459) : error 035: argument type mismatch (argument 1) test2.pwn(7460) : error 035: argument type mismatch (argument 1)
new INI:File = INI_Open(UserPath(id));
INI_WriteString(File,"Banned By", sender);
INI_WriteString(File,"Reason", reason);
INI_Close(File);