array must be indexed (variable "GetStatsTypeAsString")
#1

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;
}
Reply
#2

Well, an array size cannot be a string.
Reply
#3

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

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
        }
    }
}
Reply
#5

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


Forum Jump:


Users browsing this thread: 2 Guest(s)