sendmessagetoadmins problem
#1

Hello,

i just created a little pm system, where admin can read messages, that players send to each other.

part of the pm system (where admins can read messages) is here:

PHP код:
     for(new 0; < MAX_PLAYERSi++)
    {
        if(
PlayerInfo[i][pAdmin] > 0)
         {
            
format(adminovisizeof(adminovi), "%s -> %s: %s"GetName(playerid), GetName(targetid), text);
            
SendClientMessage(iADMINadminovi);
        }
    } 
Error line 2591 is the first line in code above (loop).

the errors are:
Код:
(2591) : error 029: invalid expression, assumed zero
(2591) : warning 215: expression has no effect
(2591) : error 001: expected token: ")", but found ";"
(2591) : error 036: empty statement
(2591) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


4 Errors.
for any help i am thankful
Reply
#2

PHP код:
for(new 0MAX_PLAYERSi++) 
You forgot an "i" there.

Also going to give you a quick suggestion, there's a better way on sending a message to administrators.

You can just create a stock and then use it everytime you want to send a message to online admins.

Example:

PHP код:
stock SendAdminMessage(colorstring[])
{
    foreach(
Playeri)
    {
        if(
PlayerInfo[i][pAdmin] >= 1)
        {
            
SendClientMessage(icolorstring);
        }
    }

And then you can use: SendAdminMessage(COLOR, message);
Reply
#3

Well, I thought that I can just compare it straight forward, heh, thanks!

And for the handy dandy little tool, thanks aswell, i will use it asap, and than just differ in certain commands.

REP +
Reply
#4

If you don't use foreach, you must optimize your loop.
PHP код:
for(new iGetPlayerPoolSize(); <= ji++) 

    if(!
IsPlayerConnected(i))
        continue;
    if(
PlayerInfo[i][pAdmin] > 0
    { 
        
format(adminovisizeof(adminovi), "%s -> %s: %s"GetName(playerid), GetName(targetid), text); 
        
SendClientMessage(iADMINadminovi); 
    } 

Reply
#5

What is the difference between regular loop and this one?
Reply
#6

Quote:
Originally Posted by MrakBuster
Посмотреть сообщение
What is the difference between regular loop and this one?
This is more optimized. Why?
- Your loop do : 0 to 1000 but I'm pretty sure you don't have 1000 players on your server
- You are checking admin level for people doesn't exist

- This one loop through 0 to the highest player id
- It check if the player is connected or not
You can even add && !IsPlayerNPC(i) if you have bots on your server.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)