Ban List
#1

I want to ask ..
How to create a banlist so that when I click on a banned player so it gets unban
Reply
#2

Dialog?

fetch an array of banned players with their names, remember to not fetch too much.
loop through them and strcat into one big array with line breaks,
when the loop finish, you just display it as in a list dialog.

into the loop store the with the current index in the loop the player account id into a different array.

When the user chooses something in the list, use the "OnDialogResponse" the parameter listid which returns the id of the list that was chosen.

afaik, listid should begin with 0.

So because the listid is organized in the same order the loop is, we can use the listid as the `index` of the array we stored the player account id's and fetch the account id with it

AccID=playerAccountId[playerid][listid];

And the rest is just data manipulation which is easy peazy if you already have an /unban command.
Reply
#3

Hello EmpireSk,

im using a Web-Control Panel

Its very useful and helps my Admins to Unban/Ban/Edit stats etc.



You can PM me if you need some help
Reply
#4

Adjust to your gamemode:

PHP код:
new
LastBanName[10][24],
    
LastBanIP[10][16],
    
LastBanReason[10][32]
;
#define banlist 4646
stock AddPlayerBanList(const playername[24], const reason[32], const ip[16])
{
    
LastBanName[0] = LastBanName[1];
    
LastBanName[1] = LastBanName[2];
    
LastBanName[2] = LastBanName[3];
    
LastBanName[3] = LastBanName[4];
    
LastBanName[4] = LastBanName[5];
    
LastBanName[5] = LastBanName[6];
    
LastBanName[6] = LastBanName[7];
    
LastBanName[7] = LastBanName[8];
    
LastBanName[8] = LastBanName[9];
    
LastBanName[9] = playername;
    
LastBanIP[0] = LastBanIP[1];
    
LastBanIP[1] = LastBanIP[2];
    
LastBanIP[2] = LastBanIP[3];
    
LastBanIP[3] = LastBanIP[4];
    
LastBanIP[4] = LastBanIP[5];
    
LastBanIP[5] = LastBanIP[6];
    
LastBanIP[6] = LastBanIP[7];
    
LastBanIP[7] = LastBanIP[8];
    
LastBanIP[8] = LastBanIP[9];
    
LastBanIP[9] = ip;
    
LastBanReason[0] = LastBanReason[1];
    
LastBanReason[1] = LastBanReason[2];
    
LastBanReason[2] = LastBanReason[3];
    
LastBanReason[3] = LastBanReason[4];
    
LastBanReason[4] = LastBanReason[5];
    
LastBanReason[5] = LastBanReason[6];
    
LastBanReason[6] = LastBanReason[7];
    
LastBanReason[7] = LastBanReason[8];
    
LastBanReason[8] = LastBanReason[9];
    
LastBanReason[9] = reason;
    return 
1;
}
//to ongamemodeinit
for(new 010b++)
     {
         
LastBanName[b] = "N/A";
         
LastBanIP[b] = "N/A";
         
LastBanReason[b] = "N/A";
     }
//to ban cmd
AddPlayerBanList(name,reason,ipadr);
CMD:bans(playerid,params[])
{
    if(
User[playerid][USER_ADMIN] < 4) return 0;
    new 
str[1480],line[148];
    for(new 
010++)
    {
        
format(line148"{FFFFFF}Username: {FFFF00}%s\t{FFFFFF}Reason: {FF0000}%s\t{FFFFFF}IP: {FFFF00}%s\n"LastBanName[b], LastBanReason[b], LastBanIP[b]);
        
strcat(strline);
    }
    
ShowPlayerDialog(playeridbanlistDIALOG_STYLE_TABLIST"Recent Bans",str,"Unban","Cancel");
    return 
1;
}
else if(
dialogid == banlist)
    {
        if(
response)
        {
            if(
strcmp("N/A"LastBanName[listitem], true))
            {
                new 
str[128], adminname[24], file[64];
                
format(strsizeof(str), "unbanip %s"LastBanIP[listitem]);
                
SendRconCommand(str);
                
SendRconCommand("reloadbans");
                
GetPlayerName(playerid,adminname,24);
                
format(filesizeof(file), "/Users/%s.ini"LastBanName[listitem]);
                
dini_IntSet(file"Ban"0);
                
format(str,128,"%s (ID: %d) has unbanned IP %s and username %s.",adminname,playerid,LastBanIP[listitem],LastBanName[listitem]);
                
SendAdminInfo(str);
                
LastBanName[listitem] = "N/A";
                 
LastBanIP[listitem] = "N/A";
                 
LastBanReason[listitem] = "N/A";
            }
            else return 
SendError(playerid,"Invalid ban!");
        }
    } 
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)