SA-MP Forums Archive
Admin duty not workng - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Admin duty not workng (/showthread.php?tid=382732)



Admin duty not workng - Devix - 04.10.2012

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;
}



Re : Admin duty not workng - lelemaster - 04.10.2012

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.


Re: Admin duty not workng - edgargreat - 05.10.2012

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


Re: Admin duty not workng - Devix - 05.10.2012

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


Re: Admin duty not workng - Devix - 05.10.2012

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


Re: Admin duty not workng - Red_Dragon. - 05.10.2012

Do you have the variable ?


Re: Admin duty not workng - Devix - 05.10.2012

What variable?


Re: Admin duty not workng - clarencecuzz - 05.10.2012

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;
}



Re: Admin duty not workng - Devix - 06.10.2012

Nothing has changed .


Re: Admin duty not workng - gtakillerIV - 06.10.2012

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