#1

Hey guys. I keep running in to this error

C:\Users\Bart\Desktop\infinityrp\gamemodes\infinit yrp.pwn(103 : error 033: array must be indexed (variable "FactionS")
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase


1 Error.
pawn Code:



format(FactionS, sizeof FactionS, "%s", dini_Get(file, "Faction"));



Variables are:

FactionS[60];
Faction[60];
Reply
#2

Forget what I told you on xfire, I read the error wrong. After sizeof you need an opening and closing bracket. So it would look like this:

pawn Код:
format(FactionS,sizeof(FactionS), "%s", dini_Get(file, "Faction"));//Brackets.
You had:

pawn Код:
format(FactionS,sizeof FactionS, "%s", dini_Get(file, "Faction"));//No brackets.
Reply
#3

Thanks but now I have the same error here.
if(PlayerInfo[i][pFaction] == FactionS)
Reply
#4

you dont need brackets for sizeof since it is an operator

yare you sure that that is this line ?, there is nothing wrong if you defined the variable like that

pawn Код:
new FactionS[60];
Reply
#5

I have that. Maybe if you take a look at the whole thing
pawn Код:
SendFactionMessage(color, text[])
{
    foreach(Player, i)
    {
        new FactionS[60];
        GetPlayerName(i, Name, sizeof Name);
        format(file, sizeof file, SERVER_USER_FILE, Name);
        format(FactionS,sizeof(FactionS), "%s", dini_Get(file, "Faction"));//Brackets.
        if(PlayerInfo[i][pFaction] == FactionS)
        {
            SendClientMessage(i, color, text);
        }
    }
    return 0;
}
Reply
#6

pawn Код:
if(strcmp(PlayerInfo[i][pFaction],FactionS, false))
Reply
#7

Now this is the command:
pawn Код:
COMMAND:f(playerid,params[])
{
    new chat[100];
    if(sscanf(params,"s[100]",chat)) return SendClientMessage(playerid,COLOR_GREY,"USAGE: /f [factionchat]");
    if(PlayerInfo[playerid][pFrank] <1) return SendClientMessage(playerid,COLOR_GREY,"You're not in a faction.");
    GetPlayerName(playerid,Name,sizeof(Name));
    format(String, sizeof(String), "Faction Chat %s: %s",Name,chat);
    SendFactionMessage(COLOR_PURPLE,String);
    return 1;
}
this the sendfactionmessage
pawn Код:
SendFactionMessage(color, text[])
{
    foreach(Player, i)
    {
        new FactionS[60];
        GetPlayerName(i, Name, sizeof Name);
        format(file, sizeof file, SERVER_USER_FILE, Name);
        format(FactionS,sizeof(FactionS), "%s", dini_Get(file, "Faction"));//Brackets.
        if(strcmp(PlayerInfo[i][pFaction],FactionS, false))
        {
            SendClientMessage(i, color, text);
        }
    }
    return 0;
}
No errors now but when I do /f test
Nothing happends. Just nothing.
Reply
#8

You could use strcmp or:

pawn Код:
stock SendFactionMessage(playerid, color, text[])//Don't mind 'playerid'
{
    foreach(Player, i)
    {
        if(PlayerInfo[playerid][pFaction] == PlayerInfo[i][pFaction])
        {
            SendClientMessage(i, color, text);
        }
    }
    return 0;
}
Not tested but should work.
Reply
#9

C:\Users\Bart\Desktop\infinityrp\gamemodes\infinit yrp.pwn(533) : error 035: argument type mismatch (argument 2)
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase


1 Error.
SendFactionMessage(COLOR_PURPLE,String);
Reply
#10

Add playerid before the color.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)