Very Important My Admin System
#1

guys this is my code of teh cmd /setadmin or /setlevel etc...

pawn Код:
if(strcmp(cmd, "/setadmin", true) == 0)
        {
        if(pInfo[playerid][Admin] > 0)
        {
        tmp = strtok(cmdtext,idx), tmp2 = strtok(cmdtext,idx);
        new player1, level;
        player1 = strval(tmp);
        level = strval(tmp2);
        if(!strlen(tmp) && !strlen(tmp2))
        {
        SendClientMessage(playerid, COLOR_YELLOW, "USAGE: /setadmin [playerid] [level]");
        }
        else
        {
        GetPlayerName(player1, playername, sizeof(playername));   GetPlayerName(playerid, adminname, sizeof(adminname));
        format(string,sizeof(string),"You have promoted %s to adminlevel %d ", playername, level);
        SendClientMessage(playerid, gold, string);
        format(string,sizeof(string),"Administrator %s has promoted %s to adminlevel %d",adminname, playername, level);
        SendClientMessageToAll(gold, string);
        printf("%s has promoted %s to adminlevel %d",adminname, playername, level);
        pInfo[player1][Admin] = level;
}
}
        return 1;
}
But when i try to do /setadmin on the server
Nothing Happens
What to do?
Reply
#2

Dont use the strcmp its old, stinky, buggy and annoying. Use zcmd (https://sampforum.blast.hk/showthread.php?tid=91354) to make commands on a much efficienter way
Reply
#3

Can i have the code please?
Reply
#4

As phantomcraft said, use ZCMD. It's faster and way efficient. Use sscanf too.

On topic; You can have my /setlevel command (I changed it to /setadmin so it can be easier for you)

pawn Код:
CMD:setadmin(playerid, o[])
{
    if(IsPlayerAdmin(playerid) || pInfo[playerid][pAdmin] == 1337) {
        new string[128], ID, cmdreason;

        if(sscanf(o,"ui",ID,cmdreason)) return SendClientMessage(playerid,COLOR_RED,"USAGE: /setadmin (Player Name/ID) (Level [0 - 7 | 1336 - 1337])");
        else if(!IsPlayerConnected(ID)) return SendClientMessage(playerid, COLOR_RED, "The player name/ID you entered is not connected to the server.");
        else if(cmdreason == pInfo[ID][pAdmin])
        {
            format(string,sizeof(string),"Player/Administrator %s(%d) is already at level %d.",PlayerName(ID),ID,cmdreason);
            SendClientMessage(playerid,COLOR_RED,string);
        }
        // this one down here is the current invalid levels. the levels are between 8 and 1335.
        else if(cmdreason > 7 && cmdreason < 1336) SendClientMessage(playerid, COLOR_RED, "ERROR: Invalid level.");
        else {
            pInfo[ID][pAdmin] =cmdreason;

            format(string,sizeof(string),"Administrator %s has set your admin level to %d.",PlayerName(playerid),cmdreason);
            SendClientMessage(ID, COLOR_ADMIN, string);

            format(string,sizeof(string),"You have set %s(%d)'s level to %d.",PlayerName(ID),ID,cmdreason);
            SendClientMessage(playerid, COLOR_ADMIN, string);

            format(string,sizeof(string),"An administrator has set %s's level to %d.",PlayerName(ID),cmdreason);
            SendClientMessageToAll(COLOR_LIMEGREEN, string);

            format(string,sizeof(string),"%s(%d) has set %s(%d)'s level to %d.",PlayerName(playerid),playerid,PlayerName(ID),ID,cmdreason);
            print(string);
        }
    } else SendClientMessage(playerid, COLOR_RED, "You are not authorized to use this command!");
    return 1;
}
Note; It's tested and works 100%. I deleted some of them (like to check if the selected ID is logged in or not) but you can always add some more things in the code.
Reply
#5

I got these errors
pawn Код:
C:\DOCUME~1\VASILIS\6808~1\84AC~1\MINI-M~1\MINI-M~1\FILTER~1\fsadmin.pwn(579) : warning 213: tag mismatch
C:\DOCUME~1\VASILIS\6808~1\84AC~1\MINI-M~1\MINI-M~1\FILTER~1\fsadmin.pwn(580) : warning 213: tag mismatch
C:\DOCUME~1\VASILIS\6808~1\84AC~1\MINI-M~1\MINI-M~1\FILTER~1\fsadmin.pwn(1735) : warning 219: local variable "Message" shadows a variable at a preceding level
C:\DOCUME~1\VASILIS\6808~1\84AC~1\MINI-M~1\MINI-M~1\FILTER~1\fsadmin.pwn(1800) : error 029: invalid expression, assumed zero
C:\DOCUME~1\VASILIS\6808~1\84AC~1\MINI-M~1\MINI-M~1\FILTER~1\fsadmin.pwn(1800) : error 017: undefined symbol "cmd_makeadmin"
C:\DOCUME~1\VASILIS\6808~1\84AC~1\MINI-M~1\MINI-M~1\FILTER~1\fsadmin.pwn(1800) : error 029: invalid expression, assumed zero
C:\DOCUME~1\VASILIS\6808~1\84AC~1\MINI-M~1\MINI-M~1\FILTER~1\fsadmin.pwn(1800) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664          Copyright (c) 1997-2006, ITB CompuPhase


4 Errors.
Reply
#6

It should be:

pawn Код:
CMD:setadmin(playerid, params[])
Reply
#7

Nothing...Same
Reply
#8

Quote:
Originally Posted by phantomcraft
Посмотреть сообщение
Dont use the strcmp its old, stinky, buggy and annoying. Use zcmd (https://sampforum.blast.hk/showthread.php?tid=91354) to make commands on a much efficienter way
I really hate it when you posted that. Strcmp was the first and original pawn code for SAMP. Yes of course, its confusing but yeah, using ZCMD and Sscanf is better. Faster Command Processors. But value strcmp, because many players like me use it and its important. Scripters learn strcmp first before they learn about the others.
Reply
#9

Quote:
Originally Posted by RTR12
Посмотреть сообщение
I really hate it when you posted that. Strcmp was the first and original pawn code for SAMP. Yes of course, its confusing but yeah, using ZCMD and Sscanf is better. Faster Command Processors. But value strcmp, because many players like me use it and its important. Scripters learn strcmp first before they learn about the others.
I wouldnt say that. I started out with ZCMD, not strcmp. The only times I use strcmp is when I want to compare strings (oh, the name of the function, what a concept).
Reply
#10

Any help of me any code...?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)