08.08.2017, 08:15
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:
But when I try to create an array 'vehicles' with 'rows' index, I got errors:
Please help me solving these errors, thanks in advanced.
PHP код:
CMD:v(playerid, params[])
{
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(MHandle, query, sizeof(query), "SELECT * FROM `vehicles` WHERE `OwnerName` = '%s'", Character[playerid][Username]);
mysql_query(MHandle, query);
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 i = 0; i < rows; i++) // line 26
{
cache_get_value_name_int(i, "Model", szModel);
vehicles[i] = szModel; // line 28
}
ShowModelSelectionMenuEx(playerid, vehicles, sizeof(vehicles),"Your Vehicles", pVehiclesList);
}
}
}
return 1;
}
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(2 : error 017: undefined symbol "szModel" |