SA-MP Forums Archive
Hooking CreateVehicle - 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: Hooking CreateVehicle (/showthread.php?tid=423806)



[SOLVED] Hooking CreateVehicle - Scenario - 19.03.2013

SOLVED

As the title of the thread suggests, I want to hook the CreateVehicle function. So far, this is the code I've got:

pawn Код:
stock realCreateVehicle(modelid, Float:x, Float:y, Float:z, Float:angle, color1, color2, respawn_delay)
{
    new vehicleid = CreateVehicle(modelid, Float:x, Float:y, Float:z, Float:angle, color1, color2, respawn_delay);
   
    // other code here 
    return vehicleid;
}

#if defined _ALS_CreateVehicle
    #undef CreateVehicle
#else
    #define _ALS_CreateVehicle
#endif
#define CreateVehicle realCreateVehicle
However, the hook doesn't seem to get called. Am I doing it wrong, or is hooking this function not plausible?


Re: Hooking CreateVehicle - Misiur - 19.03.2013

Looks fine. Tried putting some prints inside your createvehicle?

#e: works fine too
#e2: make sure that you hook function before calling it in code


Re: Hooking CreateVehicle - Scenario - 19.03.2013

Quote:
Originally Posted by Misiur
Посмотреть сообщение
#e2: make sure that you hook function before calling it in code


At least my scripting errors are generally easy to solve... Thanks!