Command Crashes Server
#1

Hey guys, I have a command to set someone's level of administration, but when it's used, my server crashes. I can't seem to figure out why. It's probably something simple that I'm overlooking.

pawn Код:
CMD:setadminlevel(playerid, params[])
{
    if(GetAdminLevel(playerid) == 3 || IsPlayerAdmin(playerid))
    {
        new giveplayerid, level, file[128];
        format(file, sizeof(file), USER_FILE, GetPName(playerid));

        if(sscanf(params, "ud", giveplayerid, level)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /setadmin [playerid] [level 0-3]");
        SetAdminLevel(giveplayerid, level);
       
        if(level == 0)
        {
            new str[80], str2[80];
            format(str, sizeof(str), "(ADMIN INFO) You have removed %s from the staff team.", GetPName(giveplayerid));
            format(str2, sizeof(str2), "(ADMIN INFO) You have been removed from the staff team by %s.", GetPName(playerid));
        }
        else if(level == 1)
        {
            new str[80], str2[80];
            format(str, sizeof(str), "(ADMIN INFO) You have set %s to Level 1 Moderator.", GetPName(giveplayerid));
            format(str2, sizeof(str2), "(ADMIN INFO) You have been set to Level 1 Moderator by %s.", GetPName(playerid));
        }
        else if(level == 2)
        {
            new str[80], str2[80];
            format(str, sizeof(str), "(ADMIN INFO) You have set %s to Level 2 Administrator.", GetPName(giveplayerid));
            format(str2, sizeof(str2), "(ADMIN INFO) You have been set to Level 2 Administrator by %s.", GetPName(playerid));
        }
        else if(level == 3)
        {
            new str[80], str2[80];
            format(str, sizeof(str), "(ADMIN INFO) You have set %s to Level 3 Senior Administrator.", GetPName(giveplayerid));
            format(str2, sizeof(str2), "(ADMIN INFO) You have been set to Level 3 Senior Administrator by %s.", GetPName(playerid));
        }
       
        new File:log = fopen(ADMINLOG, io_append);
        new logstring[65], day, month, year, hour, minute, second;
        getdate(year, month, day);
        gettime(hour, minute, second);
        format(logstring, sizeof(logstring), "[%02d\%02d\%d | %02d:%02d:%02d] %s set %s to admin level %i.\r\n", day, month, year, hour, minute, second, GetPName(playerid), GetPName(giveplayerid), level);
        fwrite(log, logstring);
        fclose(log);
    }
    return 1;
}
pawn Код:
GetAdminLevel(playerid)
{
    new file[128];
    format(file, sizeof(file), USER_FILE, GetPName(playerid));

    return dini_Int(file, "AdminLevel");
}

SetAdminLevel(playerid, level)
{
    new file[128];
    format(file, sizeof(file), USER_FILE, GetPName(playerid));
 
    dini_IntSet(file, "AdminLevel", level);
   
    return 1;
}
Reply
#2

which admin system you use
are you need to plugin whirlpool or no ?
Reply
#3

Where's the line we can see where the file should open?
Reply
#4

The directory ADMIN_LOG probably does not exist. Add some printf to see which get executed last before the crash. You should also download and use the "crashdetect" plugin to see whats wrong.
Reply
#5

Sorry I took so long to reply. I'm not using any admin system, I use my own work lol.


Quote:
Originally Posted by iggy1
Посмотреть сообщение
The directory ADMIN_LOG probably does not exist. Add some printf to see which get executed last before the crash. You should also download and use the "crashdetect" plugin to see whats wrong.
EDIT: Not the problem, it is defined.

pawn Код:
#define ADMINLOG "/Logs/adminlog.txt"
EDIT 2: Adding in the printfs.

EDIT 3: I'm retarded and was looking at the wrong server files. I didn't have the logfile created in the new files, so iggy was correct after all.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)