31.05.2013, 17:52
Read what I said, you probably deleted or created a vehicle before this one it's a terrible design and this is why you create proper dynamic systems relying on specific vehicle id's and expecting them not to change during development is a terrible assumption. Fortunately this is a very easy problem I'll give you an example however it will require updating all of your code.
You can add any number of vehicle types to that for instance for your logging truck you would need to add..
How this relates to your code
if(Vehdid == 422)
becomes
if(IsALogging(GetPlayerVehicleID(playerid))
No fuss no bullshit no problems no matter what order your vehicles are created in.
pawn Код:
#define CAR_TYPE_COPCAR 0
new gCarData[MAX_VEHICLES] = { INVALID_VEHICLE_ID, ... };
public OnGameModeInit()
{
AddDynamicCar(596,1595.3313,-1709.8433,5.6725,180.4009,16,1, 3600, CAR_TYPE_COPCAR);
}
stock AddDynamicCar(model, Float:cx, Float:cy: Float:cz, Float:cfa, color1, color2, respawndelay, cartype)
{
new vindex = CreateVehicle(modelid, cx, cy, cz, cfa, color1, color2, respawndelay);
if(vindex != INVALID_VEHICLE_ID)
{
gCarData[vindex] = cartype;
return vindex;
}
return INVALID_VEHICLE_ID;
}
stock IsACopCar(carid)
{
if(gCarData[carid] == CAR_TYPE_COPCAR) return 1;
return 0;
}
pawn Код:
#define CAR_TYPE_LOGGING 1
The number doesn't really matter it is a reference, when creating
AddDynamicCar(596,1595.3313,-1709.8433,5.6725,180.4009,16,1, 3600, CAR_TYPE_LOGGING );
Checking
stock IsALogging(carid)
{
if(gCarData[carid] == CAR_TYPE_LOGGING) return 1;
return 0;
}
if(Vehdid == 422)
becomes
if(IsALogging(GetPlayerVehicleID(playerid))
No fuss no bullshit no problems no matter what order your vehicles are created in.

