Help with making a new file after banning.
#1

Hello, I have been trying to make a ban system where it writes in it's own file, so when an admin bans a player it will save their IP, the ban reason and the admins name for later use, but I am having problems with putting this together, i've tried writing the code but it does not seem to work... The way I've wrote it, is as you use the command /ban, it will make a new file, with the players name and write everything in it, so I can load it up in a dialog for when the banned player joins. here is my code:

pawn Код:
enum banInfo
{
    BanReason,
    BanAdmin,
}
new bInfo[MAX_PLAYERS][banInfo];

stock bPath(playerid)
{
    GetPlayerName(playerid,pName,sizeof(pName));
    format(ustr,sizeof(ustr),UserPath,pName);
    return ustr;
}
pawn Код:
ACMD:ban(playerid, params[])
{
    if (pInfo[playerid][Adminlevel] < 2)return 0;
    new reason[128];
    if(sscanf(params, "us[128]",ID, reason))
    return SCM(playerid, orange, "Ban a player: /ban <ID> <Reason>");
    if(ID == IPI)return SCM(playerid, red, "Player is not connected!");
    GetPlayerName(playerid,pName,sizeof(pName)); //Get player's name
    if(fexist(bPath(playerid)))
    new INI:file = INI_Open(bPath(playerid));
    INI_WriteInt(file,"BanReason", bInfo[playerid][BanReason]);
    INI_WriteInt(file, "BanAdmin", bInfo[playerid][BanAdmin]);
    INI_Close(file);
    GetPlayerName(ID,pName,MAX_PLAYER_NAME);
    GetPlayerName(playerid,pName, MAX_PLAYER_NAME);
    SetTimerEx("KickTimer", 10, false, "i", playerid);
    format(ustr, sizeof(ustr), "%s %s has banned %s for %s", AdminLevelName(playerid),pName, pName, reason);
    SCMToAll(red, ustr);
    SetTimerEx("KickTimer", 1000, false, "d", playerid);
    return 1;
}
If you know how to help please do so! I'll give rep to anyone who can help me solve this. Thank you
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 4 Guest(s)