Vehicle ID. -
When you enter the first player everything is ok, vehicle load properly. But when they join another player and also has a vehicle, multiply your first vehicle to second vehicle. How can I fix?
Код HTML:
forward PlayerOnVehiclesLoad(playerid);
public PlayerOnVehiclesLoad(playerid)
{
for(new r = 0; r < cache_num_rows(); ++r)
{
new ORM:ormid = Veh[r][ORM_ID] = orm_create("vehicles");
orm_addvar_int(ormid, Veh[r][ID], "ID"); //this is the key
orm_addvar_int(ormid, Veh[r][Owner], "Owner");
orm_addvar_int(ormid, Veh[r][Model], "Model");
orm_addvar_float(ormid, Veh[r][PosX], "PosX");
orm_addvar_float(ormid, Veh[r][PosY], "PosY");
orm_addvar_float(ormid, Veh[r][PosZ], "PosZ");
orm_addvar_float(ormid, Veh[r][VAngle], "VAngle");
orm_addvar_int(ormid, Veh[r][Color1], "Color1");
orm_addvar_int(ormid, Veh[r][Color2], "Color2");
orm_addvar_int(ormid, Veh[r][Paintjob], "Paintjob");
orm_addvar_int(ormid, Veh[r][Value], "Value");
orm_addvar_int(ormid, Veh[r][Lock], "Lock");
orm_addvar_int(ormid, Veh[r][Insurance], "Insurance");
orm_addvar_string(ormid, Veh[r][Plate], 16, "Plate");
orm_addvar_float(ormid, Veh[r][KM], "KM");
orm_addvar_int(ormid, Veh[r][Mod][0], "Mod0");
orm_addvar_int(ormid, Veh[r][Mod][1], "Mod1");
orm_addvar_int(ormid, Veh[r][Mod][2], "Mod2");
orm_addvar_int(ormid, Veh[r][Mod][3], "Mod3");
orm_addvar_int(ormid, Veh[r][Mod][4], "Mod4");
orm_addvar_int(ormid, Veh[r][Mod][5], "Mod5");
orm_addvar_int(ormid, Veh[r][Mod][6], "Mod6");
orm_addvar_int(ormid, Veh[r][Mod][7], "Mod7");
orm_addvar_int(ormid, Veh[r][Mod][8], "Mod8");
orm_addvar_int(ormid, Veh[r][Mod][9], "Mod9");
orm_addvar_int(ormid, Veh[r][Mod][10], "Mod10");
orm_addvar_int(ormid, Veh[r][Mod][11], "Mod11");
orm_addvar_int(ormid, Veh[r][Mod][12], "Mod12");
orm_addvar_int(ormid, Veh[r][Mod][13], "Mod13");
orm_addvar_string(ormid, Veh[r][Class], 13, "Class");
orm_apply_cache(ormid, r);
orm_setkey(ormid, "ID"); //here we declare it as the key
Veh[r][ServerID] = CreateVehicle(Veh[r][Model], Veh[r][PosX], Veh[r][PosY], Veh[r][PosZ], Veh[r][VAngle], Veh[r][Color1], Veh[r][Color2], -1);
}
return 1;
}
Re: Vehicle ID. -
Re: Vehicle ID. - Godly - 09.02.2016
Re: Vehicle ID. -
You need to store additional value in the database which checks if vehicle is already loaded In Game, dont forget to reset it to each server start.