Assigning a vehicle (id) to an array problem
#1

5th Dec - Resolved

Hi all,
I have a 'stock' to load a vehicle from its file, however when i go to spawn the vehicle and associate that vehicle (and its id) to an array, it becomes -1. The vehicle still spawns, but according to the array, the vehicle id is -1 (this is for all vehicles)

Here is the 'LoadVehicle' stock
pawn Код:
stock LoadVehicle(vid)
{
    DestroyVehicle(Vehicles[vid]);
    DestroyDynamic3DTextLabel(VehicleText[vid]);

    new file[64], string[64], Float:x, Float:y, Float:z;
    format(file, sizeof(file), "vehicles/%i.veh", vid);
    Vehicles[vid] = CreateVehicle(dini_Int(file, "Model"), dini_Float(file, "x"), dini_Float(file, "y"), dini_Float(file, "z"), dini_Float(file, "rot"), dini_Int(file, "Colour1"), dini_Int(file, "Colour2"), -1);
    format(string, sizeof(string), "This vehicle is owned by %s\nIt cost %i", dini_Get(file, "Owner"), dini_Int(file, "Cost"));
    GetVehiclePos(Vehicles[vid], x, y, z);
    VehicleText[vid] = CreateDynamic3DTextLabel(string, COLOUR, x, y, z, 5.0, -1, Vehicles[vid], 0, -1, -1, -1, 100.0);
    printf("%i", Vehicles[vid]); //is -1
}
If i wanted to load all vehicles, i would do this...
pawn Код:
for(new i; i < LastID; i++) // Last ID is a variable that is saved to file on filterscript close, and the number is retrieved on filterscript init - this means less looping because i dont have to go through till my max vehicle limit
{
     LoadVehicle(i);
}
Has anyone got any ideas? Its probably a stupid error knowing me

Thanks in advance
Ash
Reply


Messages In This Thread
Assigning a vehicle (id) to an array problem - by Ash. - 04.12.2010, 18:04
Re: Assigning a vehicle (id) to an array problem - by JaTochNietDan - 04.12.2010, 18:17
Re: Assigning a vehicle (id) to an array problem - by Ash. - 04.12.2010, 18:25
Re: Assigning a vehicle (id) to an array problem - by dice7 - 04.12.2010, 19:03
Re: Assigning a vehicle (id) to an array problem - by JaTochNietDan - 05.12.2010, 11:47
Re: Assigning a vehicle (id) to an array problem - by xpeppe - 05.12.2010, 12:26
Re: Assigning a vehicle (id) to an array problem - by dice7 - 05.12.2010, 14:12
Re: Assigning a vehicle (id) to an array problem - by Ash. - 11.12.2010, 15:44

Forum Jump:


Users browsing this thread: 1 Guest(s)