Custom function
#1

pawn Code:
public HelpRequest(color,string[])
{
        for(new i = 0; i < MAX_PLAYERS; i++)
    {
                 if(IsPlayerConnected(i))
        {
                        if (PlayerInfo[pAdmin] ==1(i))
            {
                         SendClientMessage(i, color, string);

                        }
                   }
          }
          return 1;
}
Trying to make this function so it sends a message to all the players whos pAdmin equals to the value of 1 (Helper value) But i keep getting these errors..

Code:
C:\Users\Scripting.Ash-PC\Desktop\Scripting\Roleplaying Server\gamemodes\roleplay.pwn(479) : error 029: invalid expression, assumed zero
C:\Users\Scripting.Ash-PC\Desktop\Scripting\Roleplaying Server\gamemodes\roleplay.pwn(479) : warning 215: expression has no effect
C:\Users\Scripting.Ash-PC\Desktop\Scripting\Roleplaying Server\gamemodes\roleplay.pwn(479) : error 001: expected token: ";", but found ")"
C:\Users\Scripting.Ash-PC\Desktop\Scripting\Roleplaying Server\gamemodes\roleplay.pwn(479) : error 029: invalid expression, assumed zero
C:\Users\Scripting.Ash-PC\Desktop\Scripting\Roleplaying Server\gamemodes\roleplay.pwn(479) : fatal error 107: too many error messages on one line

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


4 Errors.
Reply
#2

pawn Code:
public HelpRequest(color, string[])
{
    foreach(Player, i)
    {
        if(PlayerInfo[i][pAdmin] == 1)
        {
            SendClientMessage(i, color, string);
        }
    }
    return 1;
}

or:
public HelpRequest(color, string[])
{
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i))
        {
            if(PlayerInfo[i][pAdmin] == 1)
            {
                SendClientMessage(i, color, string);
            }
        }
    }
    return 1;
}
Reply
#3

If I'm not mistaken, shouldn't this line:
pawn Code:
if (PlayerInfo[pAdmin] ==1(i))
Say something like:
pawn Code:
if (PlayerInfo[i][pAdmin] == 1)
??

If that doesn't fix it, try changing 'string[]' to 'const string[]'.

EDIT: Fuck, I nearly got it first.
Reply
#4

pawn Code:
stock HelpRequest(color, const string[]) {
    for(new i = 0; i < MAX_PLAYERS; i++) {
        if(IsPlayerConnected(i) && PlayerInfo[i][pAdmin] > 0) {
            SendClientMessage(i, color, string);
        }
    }
    return 1;
}
Reply
#5

Thanks all, I got one more problem when trying to add my script though..

pawn Code:
COMMAND:help(playerid, params[])
{
        new message[28];
        if (!sscanf(params, "s",message))
        new name[MAX_PLAYER_NAME];
        GetPlayerName(playerid, name, sizeof (name));
        format(message, sizeof(message), "%s asks: %s", name, message);
        HelpRequest(-1, message);
        return 1;
}
Code:
C:\Users\Scripting.Ash-PC\Desktop\Scripting\Roleplaying Server\gamemodes\roleplay.pwn(282) : error 003: declaration of a local variable must appear in a compound block
C:\Users\Scripting.Ash-PC\Desktop\Scripting\Roleplaying Server\gamemodes\roleplay.pwn(282) : error 017: undefined symbol "name"
C:\Users\Scripting.Ash-PC\Desktop\Scripting\Roleplaying Server\gamemodes\roleplay.pwn(282) : warning 215: expression has no effect
C:\Users\Scripting.Ash-PC\Desktop\Scripting\Roleplaying Server\gamemodes\roleplay.pwn(282) : error 001: expected token: ";", but found "]"
C:\Users\Scripting.Ash-PC\Desktop\Scripting\Roleplaying Server\gamemodes\roleplay.pwn(282) : fatal error 107: too many error messages on one line

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


4 Errors.
Reply
#6

give us the 282 line
Reply
#7

pawn Code:
COMMAND:help(playerid, params[])
{
        new message[128];
        if (!sscanf(params, "s[128]",message))
        new name[MAX_PLAYER_NAME];
        GetPlayerName(playerid, name, sizeof (name));
        format(message, sizeof(message), "%s asks: %s", name, message);
        HelpRequest(-1, message);
        return 1;
}
You must increase the string size first of all and also implement the size on sscanf "s" specifier.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)