IsPlayerAdmin can't use [i]
#1

pawn Код:
forward MessageToAdmins(color,const string[]);
public MessageToAdmins(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, string);
    }
    return 1;
}
pawn Код:
D:\3x-TCTDM\gamemodes\TCTDM.pwn(12950) : error 028: invalid subscript (not an array or too many subscripts): "IsPlayerAdmin"
D:\3x-TCTDM\gamemodes\TCTDM.pwn(12950) : warning 215: expression has no effect
D:\3x-TCTDM\gamemodes\TCTDM.pwn(12950) : error 001: expected token: ";", but found "]"
D:\3x-TCTDM\gamemodes\TCTDM.pwn(12950) : error 029: invalid expression, assumed zero
D:\3x-TCTDM\gamemodes\TCTDM.pwn(12950) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664          Copyright (c) 1997-2006, ITB CompuPhase


4 Errors.
At the isplayeradmin Line Thanks in advance !
Reply
#2

IsPlayerConnected doesnt need 1-2 check, as it return true or false.

PHP код:

forward MessageToAdmins
(color,const string[]);
public 
MessageToAdmins(color,const string[])
{
    for(new 
0MAX_PLAYERSi++)
    {
        if(
IsPlayerConnected(i)) {
             if(
PlayerInfo[i][Level] >= || IsPlayerAdmin(i)) {
                 
SendClientMessage(icolorstring);
            }
        }
    }
    return 
1;

EDIT: woops fixed


EDIT v2: Yes, you cannot use [i] on IsPlayerAdmin since thats an in-built SA:MP function and it responds to IsPlayerAdmin(playerid) or in your case IsPlayerAdmin(i)
Look more here
https://sampwiki.blast.hk/wiki/IsPlayerAdmin
Reply
#3

everything works fine now, also thanks for your explaining your surly deserve the +rep...
Reply
#4

pawn Код:
stock SendMessageToAdmins(const color, const string[])
{
    for(new i = 0, j = GetPlayerPoolSize(); i <= j; i ++)
    {
        if(!IsPlayerConnected(i) || !PlayerInfo[i][Level] || !IsPlayerAdmin(i))
        {
            continue;
        }

        SendClientMessage(i, color, string);
    }
    return 1;
}
@TwinkiDaBoss - Update your player loops.

[] = index/cell
() = arguments/operation
Reply
#5

Quote:
Originally Posted by SickAttack
Посмотреть сообщение
pawn Код:
stock SendMessageToAdmins(const color, const string[])
{
    for(new i = 0, j = GetPlayerPoolSize(); i <= j; i ++)
    {
        if(!IsPlayerConnected(i) || !PlayerInfo[i][Level] || !IsPlayerAdmin(i))
        {
            continue;
        }

        SendClientMessage(i, color, string);
    }
    return 1;
}
@TwinkiDaBoss - Update your player loops.

[] = index/cell
() = arguments/operation
I personally use foreach for this stuff, but a good point there.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)