PDA

View Full Version : if(IsAdminConnected)


Alex_Obando
28/08/2011, 11:39 PM
Im using SendClientMessageToAdmins Strock,

So how I can make a strock which check if the player (ADMIN) is connected)

im using SendClientMessageToAdmins

IceCube!
28/08/2011, 11:46 PM
The only way i cn think of doing this is by doing

if(IsPlayerConnected)
{
if(IsPlayerAdmin)
{
SendClientMessageToAdmins....
}
}

Because there is no actual fuction to do that


EDIT: Sorry i didnt think you ment that sorry fot the n00b post

Alex_Obando
28/08/2011, 11:51 PM
I think thats wrong
It'll be:

If the player is connected & is rcon send the message to him.....

grand.Theft.Otto
28/08/2011, 11:51 PM
forward SendClientMessageToAdmins(color,const string[]);
public SendClientMessageToAdmins(color,const string[])
{
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i) == 1)
{
if(PlayerInfo[i][Level] >= 1 || IsPlayerAdmin(i))
{
SendClientMessage(i, COLOR_HERE, string);
}
}
}
return 1;
}


Change PlayerInfo to yours, like Info, pInfo, etc... Unless you don't have one, then just delete it and make the line

if(IsPlayerAdmin(i))

Then when you want a message to be sent to admins, use SendClientMessageToAdmins(color,string);

Alex_Obando
28/08/2011, 11:58 PM
Can it be this:



stock AdminConnected(playerid)
{
for(new a, g = GetMaxPlayers(); a < g; a++)
if(IsPlayerConnected(a) && IsPlayerAdmin(a))
}

JaTochNietDan
29/08/2011, 12:02 AM
Can it be this:



stock AdminConnected(playerid)
{
for(new a, g = GetMaxPlayers(); a < g; a++)
if(IsPlayerConnected(a) && IsPlayerAdmin(a))
}


Yes but you haven't returned a value or done anything so how are you supposed to know?

Simply edit the function to return a value as expected, for example:


stock AdminConnected()
{
for(new a, g = GetMaxPlayers(); a < g; a++)
if(IsPlayerConnected(a) && IsPlayerAdmin(a)) return 1;
return 0;
}


Now it will return 1 when an administrator is connected and 0 when there are no administrators connected.

Additionally, why do you create two variables in the loop? You only really need one:

stock AdminConnected()
{
for(new a = 0; a < GetMaxPlayers(); a++)
if(IsPlayerConnected(a) && IsPlayerAdmin(a)) return 1;
return 0;
}

Alex_Obando
29/08/2011, 12:04 AM
Holy cow, an admin replied me xD, Thanks sir...