Quantcast
Channel: SA-MP Forums
Viewing all articles
Browse latest Browse all 18226

Creating an array with variable's value index!

$
0
0
I'm working on a command that spawn the player's chosen vehicle from the list, I use mSelection include to show this list. So, this is my code:
PHP Code:

CMD:v(playeridparams[])
{
    if(
isnull(params)) System_Scm(playerid"Syntax: /v [get | engine | lights | hood | trunk | lock]"TYPE_GLOBAL);
    else
    {
        new 
            
vid GetPlayerVehicleID(playerid);
        if(!
strcmp(params"get"true))
        {
            new 
query[256],
                
rows;
            
mysql_format(MHandlequerysizeof(query), "SELECT * FROM `vehicles` WHERE `OwnerName` = '%s'"Character[playerid][Username]);
            
mysql_query(MHandlequery);
            
cache_get_row_count(rows);
            if(!
rows
            {
                
System_Scm(playerid"You need to own at least one vehicle."TYPE_ERROR);
            }
            else
            {
                new 
vehicles[rows], // line 24
                    
szModel// line 25
                
for(new 0rowsi++) // line 26
                
{
                    
cache_get_value_name_int(i"Model"szModel);
                    
vehicles[i] = szModel// line 28
                
}
                
ShowModelSelectionMenuEx(playeridvehiclessizeof(vehicles),"Your Vehicles"pVehiclesList);
            }
        }
    }
    return 
1;


But when I try to create an array 'vehicles' with 'rows' index, I got errors:
Quote:

./core/Commands.pwn(24) : warning 219: local variable "vehicles" shadows a variable at a preceding level
./core/Commands.pwn(24) : error 008: must be a constant expression; assumed zero
./core/Commands.pwn(24) : error 029: invalid expression, assumed zero
./core/Commands.pwn(25) : loose indentation
./core/Commands.pwn(25) : error 017: undefined symbol "szModel"
./core/Commands.pwn(26) : error 001: expected token: ";", but found "for"
./core/Commands.pwn(26) : loose indentation
./core/Commands.pwn(28) : error 017: undefined symbol "szModel"
Please help me solving these errors, thanks in advanced.

Viewing all articles
Browse latest Browse all 18226

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>