27.05.2014, 14:13
These are my ban commands and they do not work .
It only kicks the player but it doesn't ban him .
It also doesn't show the ban information when banned.
NOTE : the /oban and /unban commands are from a tutorial on the sa-mp forums and i dont remember which tut was it
It only kicks the player but it doesn't ban him .
It also doesn't show the ban information when banned.
NOTE : the /oban and /unban commands are from a tutorial on the sa-mp forums and i dont remember which tut was it
pawn Код:
CMD:ban(playerid, params[])
{
new targetid, reason[128], string[128];
new pName[MAX_PLAYER_NAME];
GetPlayerName(playerid,pName,MAX_PLAYER_NAME);
new targetname[MAX_PLAYER_NAME];
GetPlayerName(playerid,targetname,MAX_PLAYER_NAME);
new day, month, year;
getdate(day, month, year);
new hour, minute, second;
gettime(hour, minute, second);
if(PlayerInfo[playerid][pAdmin] >= 1)
{
if(sscanf(params, "us[128]", targetid, reason)) return SendClientMessage(playerid, -1, "USAGE:: /ban [id] [reason]");
if(!IsPlayerConnected(playerid)) return SendClientMessage(playerid,COLOR_RED,"The player is not connected.");
GetPlayerName(targetid, targetname, MAX_PLAYER_NAME);
format(string, sizeof(string), "You have been banned by an Administrator . If you feel that you were wrongly banned , appeal at : sfcnr.smfnew.com");
SendClientMessage(targetid, COLOR_RED, string);
SendClientMessage(targetid, COLOR_RED, "Ban Information");
format(string, sizeof(string), "Banned by: %s(AdminLevel:%d)", pName, PlayerInfo[playerid][pAdmin]);
SendClientMessage(targetid, COLOR_RED, string);
format(string, sizeof(string), "Ban reason: %s", reason);
SendClientMessage(targetid, COLOR_RED, string);
format(string, sizeof(string), "Date & Time of the ban: %d/%d/%d at %d:%d:%d.", day, month, year, hour, minute, second);
SendClientMessage(targetid, COLOR_RED, string);
SendClientMessage(targetid, COLOR_RED,"Please press the F8 button to take a screenshot to use it on your appeal");
format(string, sizeof(string), "[{FF0000}BAN{EEEEEE}]Administrator %s has banned %s for %s",pName,targetname,reason);
SendClientMessageToAll(COLOR_WHITE,string);
PlayerInfo[targetid][pBanned] = 1;
Kick(targetid);
}
else SendClientMessage(playerid,COLOR_RED,"You need to be an administrator to use this command");
return 1;
}
CMD:oban(playerid, params[])
{
new targetname[24], filestring[79];
if(sscanf(params, "s[24]", targetname)) return SendClientMessage(playerid,COLOR_RED, "USAGE:: /oban [Offline Player's Name]");
format(filestring, sizeof(filestring), "/Users/%s.ini", targetname);
if(!fexist(filestring)) return SendClientMessage(playerid,COLOR_RED, "The player is not registered");
else if(PlayerInfo[playerid][pAdmin] >= 1)
{
new INI:File = INI_Open(filestring);
INI_SetTag(File, "data");
INI_WriteInt(File, "pBanned", 1);
INI_Close(File);
new done[128];
format(done, sizeof(done), "You have banned %s", targetname);
SendClientMessage(playerid,COLOR_RED , done);
}
return 1;
}
CMD:unban(playerid, params[])
{
new tname[24];
if(sscanf(params, "s[24]", tname)) return SendClientMessage(playerid,COLOR_RED,"USAGE:: /unban [Player Name] ");
new filestring[79];
format(filestring, sizeof(filestring), "/Users/%s.ini", tname);
if(!fexist(filestring)) return SendClientMessage(playerid,COLOR_RED, "The player is not registered");
else if(PlayerInfo[playerid][pAdmin] >= 1)
{
new INI:File = INI_Open(filestring);
INI_SetTag(File, "data");
INI_WriteInt(File, "Banned",0);
INI_Close(File);
INI_ParseFile(filestring, "LoadIP_%s", .bExtra = true , .extra = playerid);
new cmdstring[44];
format(cmdstring, sizeof(cmdstring), "unbanip %s", PlayerInfo[playerid][BannedIP]);
SendRconCommand(cmdstring);
SendRconCommand("reloadbans");
new done[128];
format(done, sizeof(done),"You have successfully unbanned %s", tname);
SendClientMessage(playerid,COLOR_RED,done);
}
else return SendClientMessage(playerid,COLOR_RED,"You're not an Administrator");
return 1;
}