Admin duty not workng
#1

It keeps saying I am off duty...


Код:
COMMAND:admins(playerid, params[])
{
	if(IsPlayerLogged[playerid] == 1)
	{
    	for(new i = 0; i <MAX_PLAYERS; i++)
    	{
    	    if(PlayerInfo[i][pAdmin] >= 3)
        	{
				SendClientMessage(playerid,COLOR_IORANGE, "online administrators");
   				new aname[24],astring[124];
 	    		GetPlayerName(playerid,aname,sizeof(aname));
        	    if(AdminDuty[i] == 1)
        	    {
        	    	format(astring,sizeof(astring),"%s %s - Onduty",adminlevel(playerid), aname);
 		     		SendClientMessage(playerid,IGREEN,astring);
 		     		return 1;
				}
				else
				{
        	    	format(astring,sizeof(astring),"%s %s - Offduty",adminlevel(playerid), aname);
 		     		SendClientMessage(playerid,GRAY,astring);
 		     		return 1;
				}
         	}
         	else SendClientMessage(playerid, YELLOW, "No admins available!");
         	return 1;
    	}
	}
	else SendClientMessage(playerid, RED, "You're not logged in!");
	return 1;
}
And to turn on/off adminduty:

Код:
COMMAND:adminduty(playerid, params[])
{
	if(IsPlayerLogged[playerid] == 1)
	{
	    if(PlayerInfo[playerid][pAdmin] >= 3)
	    {
			if(AdminDuty[playerid] == 1)
			{
			    AdminDuty[playerid] = 0;
                SendClientMessage(playerid, IYELLOW, "You are now off adminduty.");
                SetPlayerColor(playerid, 0xFFFFFFFF);
                return 1;
			}
			else
			{
			    AdminDuty[playerid] = 1;
                SendClientMessage(playerid, IGREEN, "You are now on adminduty!");
                SetPlayerColor(playerid, ORANGE);
			}
			return 1;
		}
		else SendClientMessage(playerid, COLOR_RED, "You are not authorized!");
	}
	else SendClientMessage(playerid, COLOR_RED, "You're not logged in!");
	return 1;
}
Reply
#2

First, what does it tell you when you do /adminduty?

Second, I bet you are devlopping your sever alone. When there will 2 admins online, it will spam you twice "online administrators". You should place the SendClientMessage before the loop.
Reply
#3

What is your problem here? On /adminduty or if they type the /admins you want to see who are online?
Reply
#4

If I type /adminduty it will say I am on duty, yet if I type /admins I show up as offduty.
Reply
#5

It only shows one admin.. Weird, what loop can I use here? while or for?
Reply
#6

Do you have the variable ?
Reply
#7

What variable?
Reply
#8

This should work. Give it a shot.

pawn Код:
COMMAND:admins(playerid, params[])
{
    if(IsPlayerLogged[playerid] == 1)
    {
        new count = 0;
        SendClientMessage(playerid, COLOR_IORANGE, "Online Administrators");
        for(new i = 0; i <MAX_PLAYERS; i++)
        {
            if(PlayerInfo[i][pAdmin] >= 3)
            {
                count++;
                new aname[MAX_PLAYER_NAME];
                GetPlayerName(i,aname,sizeof(aname));
                if(AdminDuty[i] == 1)
                {
                    format(astring,sizeof(astring),"%s %s - Onduty",adminlevel(playerid), aname);
                    SendClientMessage(playerid,IGREEN,astring);
                    continue;
                }
                else
                {
                    format(astring,sizeof(astring),"%s %s - Offduty",adminlevel(playerid), aname);
                    SendClientMessage(playerid,GRAY,astring);
                    continue;
                }
            }
        }
        if(count == 0) return SendClientMessage(playerid, YELLOW, "There Are Currently No Administrators Available!");
    }
    else return SendClientMessage(playerid, RED, "You're not logged in!");
    return 1;
}

COMMAND:adminduty(playerid, params[])
{
    if(IsPlayerLogged[playerid] == 1)
    {
        if(PlayerInfo[playerid][pAdmin] >= 3)
        {
            if(AdminDuty[playerid] == 1)
            {
                AdminDuty[playerid] = 0;
                SendClientMessage(playerid, IYELLOW, "You are now off adminduty.");
                SetPlayerColor(playerid, 0xFFFFFFFF);
            }
            else if(AdminDuty[playerid] == 0)
            {
                AdminDuty[playerid] = 1;
                SendClientMessage(playerid, IGREEN, "You are now on adminduty!");
                SetPlayerColor(playerid, ORANGE);
            }
        }
        else return SendClientMessage(playerid, COLOR_RED, "You are not authorized to use this command!");
    }
    else return SendClientMessage(playerid, COLOR_RED, "You're not logged in!");
    return 1;
}
Reply
#9

Nothing has changed .
Reply
#10

Well try this maybe?

Replace your one with my one, if that doesn't work then split the command into two.

What I mean is make a /dutyon command and a /dutyoff command.

PHP код:
new AdminDuty[MAX_PLAYAERS]=0
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)