SA-MP Forums Archive
error - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: error (/showthread.php?tid=264812)



error - bartje01 - 27.06.2011

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];


Re: error - Tee - 28.06.2011

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.



Re: error - bartje01 - 28.06.2011

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


AW: error - Nero_3D - 28.06.2011

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];



Re: error - bartje01 - 28.06.2011

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;
}



Re: error - =WoR=Varth - 28.06.2011

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



Re: error - bartje01 - 28.06.2011

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.


Re: error - Tee - 28.06.2011

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.


Re: error - bartje01 - 28.06.2011

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);


Re: error - Tee - 28.06.2011

Add playerid before the color.