SA-MP Forums Archive
array must be indexed? - 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: array must be indexed? (/showthread.php?tid=169829)



array must be indexed? - willsuckformoney - 21.08.2010

I think i asked this before but can't remember it.

Код:
error 033: array must be indexed (variable "aName")
What does that mean?


Re: array must be indexed? - [L3th4l] - 21.08.2010

Must have an array to it, aName[MAX_PLAYER_NAME]; aName[24]; etc..


Re: array must be indexed? - willsuckformoney - 21.08.2010

I have that, it still says must be indexed


Re: array must be indexed? - Zezombia - 21.08.2010

Show us; The variable you created, and the line you get the error on.


Re: array must be indexed? - Retardedwolf - 21.08.2010

aName[playerid];

The playerid part.

Or maybe when you created the variable.


Re: array must be indexed? - willsuckformoney - 21.08.2010

how about.. I show the whole thing? kkgood

pawn Код:
forward UpdatePlayer(playerid);
public UpdatePlayer(playerid)
{
    #if defined AntiWeap
    if(PlayerInfo[playerid][Level] >= 1 || IsPlayerAdmin(playerid)) return 1;
    if(PlayerInfo[playerid][WHack] == 1) return print("Admins Aware");
    if(PlayerInfo[playerid][WHack] == 2) return Kick(playerid), SendClientMessage(playerid,red,"You been kicked for Weapon hacks, this means you had warning next is ban");
    if(PlayerInfo[playerid][WHack] == 3) return Ban(playerid), SendClientMessage(playerid,red,"You been banned for Weapn Hacks, This means u been warned and kicked."), PlayerInfo[playerid][WHack] = 0;
    for(new x=0; x<13; x++)
    {
        new WepData[13][2], WepName[25];
        GetPlayerWeaponData(playerid, x, WepData[x][0], WepData[x][1]);
        GetWeaponName(WepData[x][0], WepName, sizeof(WepName));

        if(IsIllegalWeapon(WepData[x][0]))
        {
            new aName[MAX_PLAYER_NAME], str[120];
            GetPlayerName(playerid, aName, sizeof(aName));

            format(str, sizeof(str), "%s Has Weapon %s with %d ammo, Illegal Weapon, Removed.", aName, WepName, WepData[x][1]);
            MessageToAdmin(0xFFC800FF,str);
            SendClientMessage(playerid,red,"WEAPON HACKS DETECTED! Cheating weapons leads to warning kick then ban, This is your warning");
            ResetPlayerWeapons(playerid);
            PlayerInfo[playerid][WHack] ++;
            return 1;
        }
    }
    #endif
    return 1;
}
.... Btw if anyone knows how to make it so that the WHack goes up after the warning kick and ban D:


Re: array must be indexed? - Retardedwolf - 21.08.2010

pawn Код:
new aName, str[120];
and try again.


Re: array must be indexed? - willsuckformoney - 21.08.2010

Quote:
Originally Posted by EllipseRage
Посмотреть сообщение
pawn Код:
new aName, str[120];
and try again.
It's already there, anyways i fixed that i just need it to kick if its the second attempt and ban on third

pawn Код:
if(PlayerInfo[playerid][WHack] == 1) return print("Admins Aware");
    if(PlayerInfo[playerid][WHack] == 2) return Kick(playerid), SendClientMessage(playerid,red,"You been kicked for Weapon hacks, this means you had warning next is ban"), PlayerInfo[playerid][WHack] = 2;
    if(PlayerInfo[playerid][WHack] == 3) return Ban(playerid), SendClientMessage(playerid,red,"You been banned for Weapn Hacks, This means u been warned and kicked."), PlayerInfo[playerid][WHack] = 3;
^^


Re: array must be indexed? - Zezombia - 21.08.2010

You can't return more then 1 value.

pawn Код:
if(PlayerInfo[playerid][WHack] == 1)
    {
        print("Admins Aware");
        PlayerInfo[playerid][WHack] = 2;
        return 1;
    }

    if(PlayerInfo[playerid][WHack] == 2)
    {
        Kick(playerid);
        SendClientMessage(playerid, red, "You been kicked for Weapon hacks, this means you had warning next is ban");
        PlayerInfo[playerid][WHack] = 3;
        return 1;
    }

    if(PlayerInfo[playerid][WHack] == 3)
    {
        Ban(playerid);
        SendClientMessage(playerid, red, "You been banned for Weapn Hacks, This means u been warned and kicked.");
        return 1;
    }
Also, I hope you have a way to link 'playerid' with their IP or name, because I assume once they rejoin from being kicked theyir WHack will be 0.


Re: array must be indexed? - willsuckformoney - 21.08.2010

lol it saves into the registerfile and it sets it when they log inn, no problem there Ima test what you posted.

EDIT: It failed. IT automatically sends it the the kick part because of the PlayerInfo[playerid][WHack] = 2;