need help with /setadmin command ! fast
#1

This Code i got for make me Admin lvl 5
can you help me code out for lvl from 1-5
and Message on promotion Like
You Have Been Promoted To Admin Level (Level) By (Admin Name here)

pawn Код:
CMD:setadmin(playerid,params[]) return PlayerInfo[playerid][Admin] = 5;
Reply
#2

pawn Код:
CMD:setadmin(playerid,params[])
{
    new ID;
    new Level;
    new AdminName;
    new string[128];
    if(PlayerInfo[playerid][Admin] >= 5)
    {
        if(sscanf(params,"ii", ID, Level)) return SendClientMessage(playerid,-1,"{FF0000}USAGE: {15FF00}/SetAdmin [ID] [Level]");
        PlayerInfo[playerid][Admin] = Level;
        format(string, sizeof(string), "{FF0000}[INFO]: {15FF00}You gave to {FF0000}%s {15FF00}Admin Level {0066CC}: %s", ID, Level);
        SendClientMessage(playerid, -1, string);
        format(string, sizeof(string), "{FF0000}[INFO]: {15FF00}Admin {FF0000}%s {15FF00}has setted your Admin Level to{0066CC}: %s", AdminName, Level);
        SendClientMessage(ID, -1, string);
    }
    else
    {
        SendClientMessage(playerid, -1, "You need to be Admin Level 5 !");
    }
    return 1;
}

stock GetAdminName(playerid)
{
    GetPlayerName(playerid, AdminName);
}

/*

Can optimize him, I worked 5 minutes at it

*/
http://www.solidfiles.com/d/ba2f/sscanf.inc

http://www.solidfiles.com/d/d20f/zcmd.inc
Reply
#3

Thankx HY i +REp you
Reply
#4

pawn Код:
CMD:makeadmin(playerid, params[])
{
    new targetid, level, string[128];
    [PUT YOUR ADMIN SYSTEM HERE] && !IsPlayerAdmin(playerid)) return SendClientMessageEx(playerid, COLOR_GREY, "You are not authourized to use this command.");
    else if(sscanf(params, "ui", targetid, level)) return SendClientMessageEx(playerid, COLOR_GREY, "Usage: /makeadmin [playerid] [0-5]");
    else if(!IsPlayerConnectedEx(targetid) || !IsPlayerLogged(targetid)) return SendClientMessageEx(playerid, COLOR_GREY, "Invalid player specified.");
    else if(level < 0 || level > 5) return SendClientMessageEx(playerid, COLOR_GREY, "You have enter an invalid administrator level.");
    PlayerInfo[targetid][pAdminLevel] = level;
    format(string, sizeof(string), "* You have been made a %s by %s %s.", GetAdminRank(targetid), GetAdminRank(playerid), GetPlayerNameEx(playerid));
    SendClientMessageEx(targetid, COLOR_LIGHTBLUE, string);
    format(string, sizeof(string), "You have made %s a %s.", GetPlayerNameEx(targetid), GetAdminRank(targetid));
    SendClientMessageEx(playerid, COLOR_LIGHTBLUE, string);
    return 1;
}
+Rep if I helped please bro, it'd really help me out.
Reply
#5

There were flaws in HY's code, i corrected it.
pawn Код:
CMD:setadmin(playerid,params[])
{
    new ID;
    new Level;
    new string[128];
    if(PlayerInfo[playerid][Admin] >= 5)
    {
        if(sscanf(params,"ui", ID, Level)) return SendClientMessage(playerid,-1,"{FF0000}USAGE: {15FF00}/SetAdmin [ID] [Level]");
        if(!IsPlayerConnected(ID)) return SendClientMessage(playerid,-1,"Player is not connected");
        PlayerInfo[ID][Admin] = Level;
        format(string, sizeof(string), "{FF0000}[INFO]: {15FF00}You gave to {FF0000}%s {15FF00}Admin Level {0066CC}: %i", GetName(ID), Level);
        SendClientMessage(playerid, -1, string);
        format(string, sizeof(string), "{FF0000}[INFO]: {15FF00}Admin {FF0000}%s {15FF00}has setted your Admin Level to{0066CC}: %i", GetName(playerid), Level);
        SendClientMessage(ID, -1, string);
    }
    else
    {
        SendClientMessage(playerid, -1, "You need to be Admin Level 5 !");
    }
    return 1;
}

stock GetName(playerid)
{
    new Name[24];
    GetPlayerName(playerid, Name,24);
    return Name;
}
Reply
#6

Both Codes dont work
when ingame try type /Setadmin id 5 its show
Setting to 0
Reply
#7

pawn Код:
format(string, sizeof(string), "{FF0000}[INFO]: {15FF00}You gave to {FF0000}%s {15FF00}Admin Level {0066CC}: %i", GetName(ID), Level);
Raplace

pawn Код:
format(string, sizeof(string), "{FF0000}[INFO]: {15FF00}You gave to {FF0000}%s {15FF00}Admin Level {0066CC}: %d", GetName(ID), Level);
Try.
Reply
#8

There is no difference between %i and %d.
This should work.
pawn Код:
CMD:setadmin(playerid, params[])
{
    if (PlayerInfo[playerid][Admin] >= 5)
    {
        new id, level;
        if (sscanf(params,"ui", id, level))
            return SendClientMessage(playerid, -1, "Usage: /setadmin <id/name> <level>");
        if (id == INVALID_PLAYER_ID))
            return SendClientMessage(playerid, -1, "Invalid playerid.");
                if (level < 0 || level > 5)
                    return SendClientMessage(playerid, -1, "Admin levels are between 0 and 5 only.");
           
        new string[66];
       
        GetPlayerName(playerid, string, sizeof (string));
        format(string, sizeof (string), "Your admin level has been changed to %i by %s", level, string);
        SendClientMessage(id, -1, string);
       
        GetPlayerName(id, string, sizeof (string));
        format(string, sizeof (string), "Admin %s has changed your admin level to %i", string, level);
        SendClientMessage(playerid, -1, string);
       
        PlayerInfo[playerid][Admin] = level;
    }
    else
    {
        SendClientMessage(playerid, -1, "You are not allowed to use this command.");
    }
    return 1;
}
Reply
#9

Edited my last post,check it.
Reply
#10

Mine works perfectly on my server, use that.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)