AdminsChat, Admins Warns
#1

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 
i0<MAX_PLAYERSi++)
     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.
Reply
#2

PHP код:
stock SendMessageToAllAdmins(message[], color)
{
    foreach(
Playeri)
    {
        if(
pInfo[i][pAdminLevel] >= || IsPlayerAdmin(i))
        {
             
SendClientMessage(icolormessage);
         }
     }
    return 
1;

easier
Reply
#3

PHP код:
stock AdminChat(COLOR,message[]) 

    for(new 
i0<MAX_PLAYERS;i++)  
     if(
pInfo[i][Adminlevel] == 0) return 0;
     if(
pInfo[i][Adminlevel] => 1
     { 
        
SendClientMessage(i,COLOR,message); 
    } 
    return 
1

Reply
#4

Quote:
Originally Posted by UltraScripter
Посмотреть сообщение
PHP код:
stock AdminChat(COLOR,message[]) 

    for(new 
i0<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?
Reply
#5

Quote:
Originally Posted by Zeus666
Посмотреть сообщение
PHP код:
stock SendMessageToAllAdmins(message[], color)
{
    foreach(
Playeri)
    {
        if(
pInfo[i][pAdminLevel] >= || IsPlayerAdmin(i))
        {
             
SendClientMessage(icolormessage);
         }
     }
    return 
1;

easier
Thnx All, But Can u Explain this,Zeus??
What is the meaning of foreach(Player, i) ??
Reply
#6

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++)
Reply
#7

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:
pawn Код:
foreach(new i : Player)
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).
Reply
#8

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++)
??!
Reply
#9

What is the meaning of
Код:
GetPlayerPoolSize
??!
Reply
#10

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).
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)