PDA

View Full Version : Admin duty not workng


Devix
04/10/2012, 08:02 PM
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;
}

lelemaster
04/10/2012, 09:05 PM
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.

edgargreat
05/10/2012, 04:00 AM
What is your problem here? On /adminduty or if they type the /admins you want to see who are online?

Devix
05/10/2012, 07:21 AM
If I type /adminduty it will say I am on duty, yet if I type /admins I show up as offduty.

Devix
05/10/2012, 04:42 PM
It only shows one admin.. Weird, what loop can I use here? while or for?

Red_Dragon.
05/10/2012, 04:49 PM
Do you have the variable ?

Devix
05/10/2012, 06:44 PM
What variable?

clarencecuzz
05/10/2012, 08:13 PM
This should work. Give it a shot.

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

Devix
06/10/2012, 05:16 PM
Nothing has changed :(.

gtakillerIV
06/10/2012, 06:56 PM
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.

new AdminDuty[MAX_PLAYAERS]=0;

Devix
07/10/2012, 06:53 PM
Splitting the command would make no sense as this should work anyways...

Right now I get no admins online all the times even though I am online :P.