SendToAdmins(color,Message[])
{
foreach(new i : Player)
{
if(pInfo[i][pLevel] >= 1)
SCM(i, color, Message);
}
return 1;
}
|
Well I'm using this code to send message to admins only it working perfect but but.
the problem come it causing lag because I'm calling this function in many locations like when some body cheating it send message to admin even some body join it send message to admin. Now it start making lag. Код:
SendToAdmins(color,Message[])
{
foreach(new i : Player)
{
if(pInfo[i][pLevel] >= 1)
SCM(i, color, Message);
}
return 1;
}
Cheers. Thanks |
|
if(pInfo[i][pLevel] >= 1) you don't need this line. You need something like pAdmin or pAdminLevel >= 1.
|
|
Why are you people using this SCM abbreviation? are you too lazy to type SendClientMessage? not only that, there is a tremendous amount of text editors that support syntax completion. not happy with your autocompletion.
I have a similar function in my gm, but I use it rather differently, I have an iterator that's specifically made to loop through admins only, I don't have any signs of lag coming from the function though. |
|
changing varaible name doesn't make sense dude lol.
if you're not sure kindly please don't spam post without thinking. |
|
He didn't mean it that way, he simply suggested that you would make an array with only admin ids in it so that you can iterate over it without worry about checking their admin levels.
|
SendToAdmins(color, Message[])
{
foreach(new i : Player)
{
if(!IsPlayerAdmin(i)) continue;
SCM(i, color, Message);
}
return 1;
}
for(new a=0;a<MAX_PLAYERS;a++)
if(AdminLevel[a]>=2) // YOUR ADMIN VAR here
{
SendClientMessage(a,-1,string);
}
SendMessageToAdmins(-1,str);
stock SendMessageToAdmins(color,const string[])
{
for(new i=0; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnectedEx(i))
if(AdminLevel[i] >=2)
SendClientMessage(i,color,string);
}
return 1;
}
|
Код:
SendToAdmins(color, Message[])
{
foreach(new i : Player)
{
if(!IsPlayerAdmin(i)) continue;
SCM(i, color, Message);
}
return 1;
}
|
|
Try this,
Works perfect for me. Код:
for(new a=0;a<MAX_PLAYERS;a++)
if(AdminLevel[a]>=2) // YOUR ADMIN VAR here
{
SendClientMessage(a,-1,string);
}
Код:
SendMessageToAdmins(-1,str);
stock SendMessageToAdmins(color,const string[])
{
for(new i=0; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnectedEx(i))
if(AdminLevel[i] >=2)
SendClientMessage(i,color,string);
}
return 1;
}
|