OnVehicleSpawn hook not being called - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: OnVehicleSpawn hook not being called (
/showthread.php?tid=354678)
OnVehicleSpawn hook not being called -
MP2 - 27.06.2012
Hi. In my vfunc include I hook OnVehicleSpawn to re-apply vehicle colors and set paintjobs to 'none applied'. The problem is SOME vehicles in my gamemode don't call OnVehicleSpawn when they re-spawn, either through being left un-occupied for respawn_delay or exploding.
The code for hooking OnVehicleSpawn is this:
pawn Код:
public OnVehicleSpawn(vehicleid)
{
vehicleData[vehicleid][gVeh_Paintjob] = 3;
ChangeVehicleColours(vehicleid, vehicleData[vehicleid][gVeh_SpawnColor1], vehicleData[vehicleid][gVeh_SpawnColor2]);
return CallLocalFunction("vfunc_OnVehicleSpawn", "i", vehicleid); // Hooking method
}
#if defined _ALS_OnVehicleSpawn
#undef OnVehicleSpawn
#else
#define _ALS_OnVehicleSpawn
#endif
#define OnVehicleSpawn vfunc_OnVehicleSpawn
forward vfunc_OnVehicleSpawn(vehicleid);
Why is it not being called for certain vehicles? They are all created in the gamemode, at the same time, with the same function (CreateVehicle).