admin system errors
#1

Hi guys, I'm trying to make my own built-in admin system, there are some errors that I need help..

This is the command I've done so far..

pawn Код:
dcmd_promote(playerid, params[])
{
    new id, level;
    if(IsPlayerAdmin(playerid))
    {
    if(sscanf(params,"ud",id,level) return SendClientMessage(playerid, COLOR_WHITE, "Usage: /promote <ID/Name> <Level>");
    }
    else
    {
        if(level > 3) return SendClientMessage(playerid, COLOR_ERROR, "ERROR: Invalid level. Max level is 3.");
        }
        else
        {
            new INI:File = INI_Open(UserPath(id));
            INI_WriteInt(File,"Admin",level);
            INI_Close(File);
            }
        }
    }
    else
    {
        SendClientMessage(playerid, COLOR_ERROR, "ERROR: You're not authorized to use this command.");
    }
}

dcmd_kick(playerid, params[])
{
    new id, reason[128],name[MAX_PLAYER_NAME];
    new string1[128];
    if(PlayerInfo[playerid][pAdmin] > 1)
    {
        if(sscanf(params,"us[128]",id,reason); return SendClientMessage(playerid, COLOR_ERROR, "Error!");
        else
        {
        format(string1,sizeof(string1),"%s has been kicked from the server! - %s", GetPlayerName(id,name,sizeof(name)),reason);
        SendClientMessageToAll(0xFFFFFF,string1);
        Kick(id);
      }
    }
    else
    {
        SendClientMessage(playerid, COLOR_ERROR, "ERROR: You're not authorized to use this command!");
    }
}

7 Errors.

Can anyone help me please? I will be very grateful
Reply
#2

pawn Код:
dcmd_promote(playerid, params[])
{
    new id, level;
    if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COLOR_ERROR, "ERROR: You're not authorized to use this command.");
    if(sscanf(params, "ud", id, level) return SendClientMessage(playerid, COLOR_WHITE, "Usage: /promote <ID/Name> <Level>");
    if(level > 3) return SendClientMessage(playerid, COLOR_ERROR, "ERROR: Invalid level. Max level is 3.");
    new INI:File = INI_Open(UserPath(id));
    INI_WriteInt(File,"Admin",level);
    INI_Close(File);
    return 1;
}

dcmd_kick(playerid, params[])
{
    new id, reason[128],name[MAX_PLAYER_NAME];
    new string1[128];
    if(PlayerInfo[playerid][pAdmin] > 1)
    {
        if(sscanf(params, "us[128]", id, reason) return SendClientMessage(playerid, COLOR_ERROR, "Error!");
        format(string1, sizeof(string1), "%s has been kicked from the server! - %s", GetPlayerName(id,name,sizeof(name)), reason);
        SendClientMessageToAll(0xFFFFFF, string1);
        Kick(id);
    }
    else
    {
        SendClientMessage(playerid, COLOR_ERROR, "ERROR: You're not authorized to use this command!");
    }
    return 1;
}
Not tested.
Reply
#3

Thank you! There are still 2 errors

Quote:

C:\Users\USER\Desktop\Street Kings Server\gamemodes\SKCNR.pwn(12867) : error 001: expected token: ")", but found "return"
C:\Users\USER\Desktop\Street Kings Server\gamemodes\SKCNR.pwn(12881) : error 001: expected token: ")", but found "return"

pawn Код:
if(sscanf(params, "ud", id, level) return SendClientMessage(playerid, COLOR_WHITE, "Usage: /promote <ID/Name> <Level>");
pawn Код:
if(sscanf(params, "us[128]", id, reason) return SendClientMessage(playerid, COLOR_ERROR, "Error!");
Reply
#4

pawn Код:
if(sscanf(params, "ud", id, level)) return SendClientMessage(playerid, COLOR_WHITE, "Usage: /promote <ID/Name> <Level>");

if(sscanf(params, "us[128]", id, reason)) return SendClientMessage(playerid, COLOR_ERROR, "Error!");
Reply
#5

Damn! That was easy to fix, thanks alot! +rep both of you.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)