SA-MP Forums Archive
array must be indexed (variable "GetStatsTypeAsString") - 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)
+--- Thread: array must be indexed (variable "GetStatsTypeAsString") (/showthread.php?tid=546148)



array must be indexed (variable "GetStatsTypeAsString") - nGen.SoNNy - 13.11.2014

So...any ideas of making this work?

pawn Код:
if( PlayerInfo[ playerid ][ GetStatsTypeAsString( TradeInfo[ playerid ][ SendThingType ] ) ] )
array must be indexed (variable "GetStatsTypeAsString")

stock GetStatsTypeAsString( thing )
{
    new StatsThing[ 128 ];
    switch( thing )
    {
        case 0: StatsThing = "Coins";
        case 1: StatsThing = "Kills";
        case 2: StatsThing = "Hours";
        case 3: StatsThing = "Fireworks";
    }
    return StatsThing;
}



Re: array must be indexed (variable "GetStatsTypeAsString") - DavidBilla - 13.11.2014

Well, an array size cannot be a string.


Re: array must be indexed (variable "GetStatsTypeAsString") - nGen.SoNNy - 13.11.2014

So..again...any ideas of making this "check" working?


Re: array must be indexed (variable "GetStatsTypeAsString") - IstuntmanI - 13.11.2014

Your code actually (sort of) looks like
pawn Код:
if( PlayerInfo[ playerid ][ "Coins" ] )
(example, when "thing" is 0, that function returns "Coins" string)
how do you want it to work ?

You have to make cases for everything (each 4 cases).

pawn Код:
switch( TradeInfo[ playerid ][ SendThingType ] )
{
    case 0:
    {
        if( PlayerInfo[ playerid ][ Coins ] )
        {
            // code
        }
    }
    case 1:
    {
        if( PlayerInfo[ playerid ][ Kills ] )
        {
            // code
        }
    }
    case 2:
    {
        if( PlayerInfo[ playerid ][ Hours ] )
        {
            // code
        }
    }
    case 3:
    {
        if( PlayerInfo[ playerid ][ Fireworks ] )
        {
            // code
        }
    }
}



Re: array must be indexed (variable "GetStatsTypeAsString") - nGen.SoNNy - 13.11.2014

I know it looks like that but i thought i will find a new way to check that without "case".