PDA

View Full Version : Problem with Getting player vehicles and spawn them


madl
09/07/2016, 11:47 AM
Hello.I'm Very new to this forum and to Pawn.i Was trying to Get the Player's vehicles(the vehicles which a player owns) and then spawn them.but i get lots of error like Array must be index and other that i have attached in the end of the post.i really have no idea why i get these errors and i tried searching ****** and the forum,but i couldnt get a result


GetPlayerVehicles(playerid){
new vehicles[50][32];
new ind;
ind=0;
for(new i;i<MAX_VEHICLES;i++)
{
if(VehicleInfo[i][cOwner]== PlayerInfo[playerid][pName])
{
vehicles[ind]=i;
ind++;
}
}
return vehicles;
}
SpawnPlayerVehicles(playerid)
{
new fields = GetPlayerVehicles(playerid);
new length[10] = sizeof(fields);
new id;
for (new i;i<length;i++)
{
id = strval(fields[i]);
CreateVehicle(VehicleInfo[id][cModel],VehicleInfo[id][cLocationX],VehicleInfo[id][cLocationY],VehicleInfo[id][cLocationZ],VehicleInfo[id][cAngle],VehicleInfo[id][cColor1],VehicleInfo[id][cColor2],0);
}
}


Errors:


array must be indexed (variable "vehicles")
array must be indexed (variable "-unknown-")// on new fields = GetPlayerVehicles(playerid);
array must be indexed (variable "length")
invalid subscript (not an array or too many subscripts): "fields"//On id = strval(fields[i]);
warning 215: expression has no effectid = strval(fields[i]);//On id = strval(fields[i]);
error 001: expected token: ";", but found "]"//On id = strval(fields[i]);
error 029: invalid expression, assumed zero//On id = strval(fields[i]);
fatal error 107: too many error messages on one line//On id = strval(fields[i]);
7 Errors.

I Hope Someone can help me to make these functions correct and fix the errors