Admin duty isn't working?
#1

EDIT:

I made this now:

pawn Код:
if(strcmp(cmd, "/aduty", true) == 0)
    {
        if(PlayerInfo[playerid][pAdmin] == 0)
        {
            new adName[100];
            GetPlayerName(playerid, adName, sizeof(adName));
            format(string, sizeof(string), "%s has went on admin duty.", adName);
            SendClientMessageToAll(COLOR_GREEN, string);
            adutytext = Create3DTextLabel("{F81414}ADMIN DUTY", 0x008080FF, 30.0, 40.0, 50.0, 40.0, 0);
            Attach3DTextLabelToPlayer(adutytext, playerid, 0.0, 0.0, 0.7);
        }
        else
        {
            new adName[100];
            GetPlayerName(playerid, adName, sizeof(adName));
            format(string, sizeof(string), "%s has went off admin duty.", adName);
            SendClientMessageToAll(COLOR_WHITE, string);
            Delete3DTextLabel(adutytext);
            return 1;
        }
    }
BUT STILL!! IT GIVES ME 3 WARNINGS:

pawn Код:
warning 213: tag mismatch
Reply
#2

pawn Код:
new bool:AdminDuty[MAX_PLAYERS];//global variable
    if(strcmp(cmd, "/aduty", true) == 0)
    {
        if(IsPlayerAdmin(playerid))//put here your variable that defines who is admin
        {
            new name1[MAX_PLAYER_NAME];
            GetPlayerName(playerid, name1, sizeof(name1));
            if(!AdminDuty[playerid])
            {
                format(string, sizeof(string), "%s has went on admin duty.",name1);
                SendClientMessageToAll(COLOR_GREEN, string);
                adminduty[playerid] = Create3DTextLabel("{F81414}ADMIN DUTY", 0x008080FF, 30.0, 40.0, 50.0, 40.0, 0);
                Attach3DTextLabelToPlayer(adminduty[playerid], playerid, 0.0, 0.0, 0.7);
                SendClientMessage(playerid, COLOR_GREEN, "You're on admin duty. If you want to go off duty type /aoduty.");
                AdminDuty[playerid] = true;
            }
            else
            {
                format(string, sizeof(string), "%s has went off admin duty.",name2);
                Delete3DTextLabel(adminduty[playerid]);
                AdminDuty[playerid] = false;
            }
        }
    }
    return 1;
 }
edited
Reply
#3

Thank you but PAWN crashes
Reply
#4

Is there any fix that can help me fixing the command? It crashes my PAWNO
Reply
#5

Explain what exactly is not working with the first code...
Reply
#6

When I type it, it doesn't give me anything even Unknown command. So, I have no Idea why.. I wanted it to be like:

When they type /aduty, Their name turns into a red color, Textdraw creates on their heads saying( ADMIN ON DUTY ) and a ClientMessage sends to All saying %s has went on admin duty. use /n. (%s = Player's name).

I don't know what's wrong, my code doesn't crash the Gamemode(PAWNO) But the one Pharrel gave does.
Reply
#7

/aoduty should work, while /aduty doesn't, because you haven't returned it, return 1; under SendClientMessage
Reply
#8

Because Pharrel had one bracket +.

pawn Код:
if(strcmp(cmd, "/aduty", true) == 0)
    {
        if(IsPlayerAdmin(playerid))//put here your variable that defines who is admin
        {
            new name1[MAX_PLAYER_NAME];
            GetPlayerName(playerid, name1, sizeof(name1));
            if(!AdminDuty[playerid])
            {
                format(string, sizeof(string), "%s has went on admin duty.",name1);
                SendClientMessageToAll(COLOR_GREEN, string);
                adminduty[playerid] = Create3DTextLabel("{F81414}ADMIN DUTY", 0x008080FF, 30.0, 40.0, 50.0, 40.0, 0);
                Attach3DTextLabelToPlayer(adminduty[playerid], playerid, 0.0, 0.0, 0.7);
                SendClientMessage(playerid, COLOR_GREEN, "You're on admin duty. If you want to go off duty type /aoduty.");
                AdminDuty[playerid] = true;
            }
            else
            {
                format(string, sizeof(string), "%s has went off admin duty.",name2);
                Delete3DTextLabel(adminduty[playerid]);
                AdminDuty[playerid] = false;
            }
        }
    }
    return 1;
Reply
#9

Still crashes the Pawno.

@G@m3OVER: Um, tried it but both of them aren't working.
Reply
#10

Why did you do this?
pawn Код:
if(PlayerInfo[giveplayerid][pAdmin] > PlayerInfo[playerid][pAdmin])
From your explanation i don't see the point of this, just do

pawn Код:
if(PlayerInfo[playerid][pAdmin] > 0)
Then, in /aoduty you are just checking if player's admin level is 1, so it won't work if there level is different from 1, do this:

pawn Код:
if(PlayerInfo[playerid][pAdmin] > 0)


And about the compiler crashing, I don't think it's because of your command, since there are no huge errors on it, it could be, for example, that you defined a function inside another one, you might have coded a dcmd command inside onplayercommandtext, that will make the compiler crash.
Check ALL the code you have made, and see where you've put it.

See ya!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)