08.05.2014, 11:11
I would like to know if i can make an /unban [playername] command which will allow admins to unban a player by entering his name and not his IP.
Could someone help me?
Could someone help me?
if (strcmp(cmd, "/unban", true)==0) { if((IsPlayerAdmin(playerid)) || PlayerInfo[playerid][pAdmin] >=4) { tmp = strtok(cmdtext, idx); if(!strlen(tmp)) { SendClientMessage(playerid, COLOR_WHITE, "USAGE: /unban [PlayerName_LastName]"); return 1; } GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer)); GetPlayerName(playerid, sendername, sizeof(giveplayer)); format(string, 256, "AdmWarning: %s has unbanned account %s", sendername, tmp); ABroadCast(COLOR_YELLOW,string,1); format(string, 256, "AdmWarning: %s has unbanned account %s", sendername, tmp); printf(string); format(string,sizeof(string),"users/%s.ini",tmp); dini_IntSet(string, "Banned", 0); dini_IntSet(string, "Warnings", 0); SendClientMessage(playerid, COLOR_WHITE, "Player Unbanned"); SendRconCommand(string); SendRconCommand("reloadbans"); GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer)); GetPlayerName(playerid, sendername, sizeof(sendername)); } return 1; |
COMMAND:unban(playerid, params[]) { new str[128], account[30], file[128]; if(PlayerStat[playerid][AdminLevel] < 4) return SendClientMessage(playerid, GREY, "You can't use this command."); if(sscanf(params,"s[30]", account))return SendClientMessage(playerid, GREY, "USAGE: /unban [playeraccount]"); format(file, sizeof(file), "Accounts/%s.ini", account); if(fexist(file)) { if(INI_Open(file)) { if(INI_ReadInt("Banned") == 1) { INI_WriteInt("Banned", 0); format(str, sizeof(str), "You have successfully unbanned account '%s'.", account); SendClientMessage(playerid, RED, str); format(str, sizeof(str), "Admin %s has deleted unbanned '%s'.", GetOOCName(playerid), account); AdminActionLog(str); format(str, sizeof(str), "%s Unbanned.", account); BanLog(str); INI_Save(); INI_Close(); } else return SendClientMessage(playerid, GREY, "This account isn't banned."); } } else return SendClientMessage(playerid, GREY, "This account does not exist."); return 1; } |