/unban command -
kbalor - 20.09.2012
Anyone know how to make unban?
If I do /unban [Exact Name]
this dini_IntSet(file, "Status", 2); will change to dini_IntSet(file, "Status", 0);
So the status will reset to 0 or offline.
Код:
Status (0 = offline, 1 = online, 2 = banned)
and lastly check if player is not banned, else SendClientMessage(playerid, RED, "Player is not banned.");
pawn Код:
COMMAND:ban(playerid,params[])
{
if(PlayerInfo[playerid][AdminLevel] >= LEVEL_ban)
{
new player, reason[128];
if(sscanf(params, "rs[128]", player, reason))
{
SendClientMessage(playerid, WHITE,"{FFFF00}Usage: /ban [PlayerID/PartOfName] [Reason]");
return 1;
}
if(PlayerInfo[player][AdminLevel] != MAX_ADMIN_LEVEL)
{
if(IsPlayerConnected(player) && player != INVALID_PLAYER_ID && player != playerid && PlayerInfo[player][AdminLevel] != MAX_ADMIN_LEVEL && PlayerInfo[player][Logged] == true)
{
new year,month,day, string[128], string2[128];
getdate(year, month, day);
format(string,sizeof(string),"** %s has been banned from the server by %s [Reason: %s]",GetName(player),GetName(playerid),reason);
SendClientMessageToAll(GREY,string);
print(string);
CreateBan(player, GetName(playerid), reason);
format(string2, sizeof(string2),""red"You have been banned!"white"\n\nAdmin:\t\t%s\nReason:\t%s\n",GetName(playerid),reason);
ShowPlayerDialog(player, BAN_DIALOG, DIALOG_STYLE_MSGBOX, "Notice", string2, "Close", "");
Kick(player);
return 1;
}
else
{
SendClientMessage(playerid, WHITE, "{FF0000}>> Player is not connected or is yourself or is the highest level admin");
}
}
else
{
new warnstring[128];
format(warnstring,sizeof(warnstring),"WARNING: %s just tried to ban you with reason: %s", GetName(playerid), reason);
SendClientMessage(player, RED, warnstring);
SendClientMessage(playerid, RED, ">> I hope thats a joke");
}
}
else
{
SendClientMessage(playerid, WHITE, NO_PERM);
}
return 1;
}
pawn Код:
stock CreateBan(playerid, adminname[], reason[])
{
new Date[16], year, month, day;
getdate(year, month, day);
format(Date, sizeof(Date), "%d/%d/%d", day, month, year);
#if USE_MYSQL == true
new query[256];
mysql_real_escape_string(reason, reason);
mysql_real_escape_string(adminname, adminname);
format(query, sizeof(query), "UPDATE `"#MYSQL_TABLE"` SET `Status` = 2, `BannedBy` = '%s', `BanReason` = '%s', `BanDate` = '%s' WHERE `PlayerName` = '%s'", adminname, reason, Date, GetName(playerid));
if(mysql_ping(gSQL))
{
mysql_query(query, _THREAD_BAN_USER, 0, gSQL);
}
#else
new file[128];
format(file, sizeof(file), "/%s/%s.ini", DINI_PATH, GetName(playerid));
dini_IntSet(file, "Status", 2);
dini_Set(file, "BannedBy", adminname);
dini_Set(file, "BanReason", reason);
dini_Set(file, "BanDate", Date);
#endif
return 1;
}
Re: /unban command -
ViniBorn - 20.09.2012
How do you check if the player is banned? (OnPlayerconnect i guess)
Re: /unban command -
Blasphemy - 21.09.2012
Basically, make a command /unban [player name] and check if the player name submitted exists in the database.
If it exists check if there banned status is in place, if so change it to offline status and save the changes.
And the player has been unbanned.
This way you can unban them even if there offline.
Re: /unban command -
ThePhenix - 21.09.2012
I have a /Unbanip command.
PHP код:
CMD:unbanip(playerid, params[])
{
if(PlayerInfo[playerid][pAdmin] >= 4 || PlayerInfo[playerid][pBanAppealer] >= 1)
{
if(isnull(params)) return SendClientMessageEx(playerid, COLOR_WHITE, "USAGE: /unbanip [ip]");
if(IsValidIP(params)) return SendClientMessageEx(playerid, COLOR_WHITE, "That is not a valid IP address!");
new string[128], year, month,day;
getdate(year, month, day);
RemoveBan(params);
format(string, 128, "AdmCmd: %s has unbanned IP %s", GetPlayerNameEx(playerid), params);
ABroadCast(COLOR_LIGHTRED,string,2);
format(string, sizeof(string), "AdmCmd: %s has unbanned IP %s (%d-%d-%d)", GetPlayerNameEx(playerid), params, month, day, year);
Log("logs/ban.log", string);
print(string);
}
return 1;
}
Unban by name:
PHP код:
CMD:unban(playerid, params[])
{
if(PlayerInfo[playerid][pAdmin] >= 4 || PlayerInfo[playerid][pBanAppealer] >= 1)
{
new string[128];
if(isnull(params)) return SendClientMessageEx(playerid, COLOR_WHITE, "USAGE: /unban [playername]");
if(doesAccountExist(params))
{
OnPlayerOfflineLogin(params);
if( PlayerInfo[MAX_PLAYERS][pPermaBanned] == 3 )
{
SendClientMessageEx( playerid, COLOR_WHITE, "Permanently banned accounts can only be unbanned via FTP." );
}
else
{
if( PlayerInfo[MAX_PLAYERS][pBanned] >= 1 )
{
PlayerInfo[MAX_PLAYERS][pBanned] = 0;
PlayerInfo[MAX_PLAYERS][pWarns] = 0;
PlayerInfo[MAX_PLAYERS][pDisabled] = 0;
RemoveBan(PlayerInfo[MAX_PLAYERS][pIP]);
print("OnPlayerOfflineLogin: Saving variables to file");
OnPlayerOfflineSave(params);
print("OnPlayerOfflineLogin: Variables saved properly");
format(string, 128, "AdmCmd: %s (IP:%s) was unbanned by %s.", params, PlayerInfo[MAX_PLAYERS][pIP], GetPlayerNameEx(playerid));
ABroadCast(COLOR_LIGHTRED,string,2);
new year, month,day;
getdate(year, month, day);
format(string, sizeof(string), "AdmCmd: %s (IP:%s) was unbanned by %s. (%d-%d-%d)", params, PlayerInfo[MAX_PLAYERS][pIP], GetPlayerNameEx(playerid),month,day,year);
Log("logs/ban.log", string);
print(string);
}
else
{
SendClientMessageEx( playerid, COLOR_WHITE, "Not a banned account!" );
}
}
}
else
{
SendClientMessageEx( playerid, COLOR_WHITE, "That account doesn't exist." );
}
}
else
{
SendClientMessageEx(playerid, COLOR_GRAD1, "You are not authorized to use that command!");
}
return 1;
}