SA-MP Forums Archive
/setadmin command. - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: /setadmin command. (/showthread.php?tid=479493)



/setadmin command. - Frank Biohazard - 05.12.2013

Hi, I need some help with this admin command I made.

When I set myself like level 3, the server.exe stops working, anyone that can fix this for me?

pawn Код:
CMD:setadmin(playerid, params[])
{
    if(PlayerInfo[playerid][pAdminLevel] == 4)
    {
        new id, level;
        if(sscanf(params, "ui", id, level)) return SendClientMessage(playerid, COLOR_WHITE, "[USAGE]: /setadmin <id> <level>");
        if(level > 4) return SendClientMessage(playerid, COLOR_RED, "[SERVER]: Levels Available: 1-4!");
        new file[64];
        dini_IntSet(file, "Admin Level", PlayerInfo[id][pAdminLevel] = level);
        SendClientMessage(id, COLOR_YELLOW, "[SERVER]: You have been promoted to Administrator - Ask your Owner about your level!");
        SendClientMessage(playerid, COLOR_LIME, "[SERVER]: You have succesfully promoted %s to Administrator!");
    }
    else if(!IsPlayerConnected(playerid))
    {
        SendClientMessage(playerid, COLOR_RED, "[SERVER]: That player is not connected!");
    }
    else if(PlayerInfo[playerid][pAdminLevel] <= 4)
    {
        SendClientMessage(playerid, COLOR_RED, "[SERVER]: You are not an Administrator or not high enough to perform this command!");
    }
    return 1;
}



Re: /setadmin command. - Konstantinos - 05.12.2013

You never check if the id is a valid player and that can cause runtime errors (Index out of bounds).

If the samp-server.exe stops working (probably a crash), then you will need to load crashdetect plugin.

https://github.com/Zeex/samp-plugin-...ases/tag/v4.12

And post what it printed in the console/server log the next time that will happen.


Re: /setadmin command. - Jankingston - 05.12.2013

do it directly from scriptfiles, isn't it?


Re: /setadmin command. - J4mmyHD - 05.12.2013

You haven't define the path of the file.


Re: /setadmin command. - Stinged - 05.12.2013

It should be !IsPlayerConnected(id)) since you are checking if the id, the id that the admin entered is not connected.

Also, add PlayerInfo[id][pAdminLevel] = level; and then dini_IntSet(file, "Admin level", level);


Re: /setadmin command. - Konstantinos - 05.12.2013

Quote:
Originally Posted by J4mmyHD
Посмотреть сообщение
You haven't define the path of the file.
Nice catch!

pawn Код:
new file[64];
dini_IntSet(file, "Admin Level", PlayerInfo[id][pAdminLevel] = level);
file is NULL.