AdminsChat, Admins Warns -
oktokt1 - 19.07.2016
Hello,
Can Someone Help Me With This Problem??!
I Want To Make Some Hing Like Admins Chat And Way To Send Hackers Warns To Admins.
I Tried To Make This But idk Where Is The Problem.
PHP код:
stock AdminChat(COLOR,message[])
{
for(new i= 0; i <MAX_PLAYERS; i++)
if(pInfo[i][Adminlevel] => 1)
{
SendClientMessage(i,COLOR,message);
}
return 0;
}
I Should Be Like:
PHP код:
AdminChat(COLOR,String);
to use it in warns, String will be identified.
Re: AdminsChat, Admins Warns -
Zeus666 - 19.07.2016
PHP код:
stock SendMessageToAllAdmins(message[], color)
{
foreach(Player, i)
{
if(pInfo[i][pAdminLevel] >= 1 || IsPlayerAdmin(i))
{
SendClientMessage(i, color, message);
}
}
return 1;
}
easier
Re: AdminsChat, Admins Warns -
UltraScripter - 19.07.2016
PHP код:
stock AdminChat(COLOR,message[])
{
for(new i= 0; i <MAX_PLAYERS;i++)
if(pInfo[i][Adminlevel] == 0) return 0;
if(pInfo[i][Adminlevel] => 1)
{
SendClientMessage(i,COLOR,message);
}
return 1;
}
Re: AdminsChat, Admins Warns -
Sjn - 19.07.2016
Quote:
Originally Posted by UltraScripter
PHP код:
stock AdminChat(COLOR,message[])
{
for(new i= 0; i <GetPlayerPoolSize(); i++) //faster
if(pInfo[i][Adminlevel] == 0) return 0;
if(pInfo[i][Adminlevel] => 1)
{
SendClientMessage(i,COLOR,message);
}
return 1;
}
|
There is no need to return 0 if their level is 0, an if statement checking if their level is higher or equals to 1 will do the job fine. And; if(pInfo[i][Adminlevel]
=> 1) you really think this works?
Re: AdminsChat, Admins Warns -
oktokt1 - 19.07.2016
Quote:
Originally Posted by Zeus666
PHP код:
stock SendMessageToAllAdmins(message[], color)
{
foreach(Player, i)
{
if(pInfo[i][pAdminLevel] >= 1 || IsPlayerAdmin(i))
{
SendClientMessage(i, color, message);
}
}
return 1;
}
easier
|
Thnx All, But Can u Explain this,Zeus??
What is the meaning of
foreach(Player, i) ??
Re: AdminsChat, Admins Warns -
Stinged - 19.07.2016
foreach is an include. It's the recommended way of looping through online players.
But you don't have to use it.
Replace it with this:
Код:
for (new i, j = GetPlayerPoolSize(); i <= j; i++)
or with this, if you're not using 0.3.7:
Код:
for (new i = 0; i < MAX_PLAYERS; i++)
Re: AdminsChat, Admins Warns -
Konstantinos - 19.07.2016
foreach/y_iterate loops through connected players only, so basically it is recommended than normal loops as it uses lists. What Zeus666 posted is the old syntax which is not used anymore, the new syntax is:
with "i" being the iterator variable and "Player" the iterator for players (there are more iterators about NPCs, vehicles in the latest version and you can also make your own).
Re: AdminsChat, Admins Warns -
oktokt1 - 19.07.2016
I Got it. Thnx all for all ur replys.
Btw, Stinged said that
or with this, if you're not using 0.3.7:
Код:
for (new i = 0; i < MAX_PLAYERS; i++)
And that what i was using so its the problem?
What should i replace it with?
With
Код:
for (new i, j = GetPlayerPoolSize(); i <= j; i++)
??!
Re: AdminsChat, Admins Warns -
oktokt1 - 19.07.2016
What is the meaning of
??!
Re: AdminsChat, Admins Warns -
Konstantinos - 19.07.2016
It returns the highest player's ID currently in the server.
Let's say MAX_PLAYERS is re-defined to 50 and there are 2 players connected in the server with IDs 0 and 4 (3 players disconnected). The loop will go from 0 to 4 whereas normally would go up to 50 (using i < MAX_PLAYERS).