Include Help - Overriding OnGameModeInit and a few other things - 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: Include Help - Overriding OnGameModeInit and a few other things (
/showthread.php?tid=341265)
Include Help - Overriding OnGameModeInit and a few other things -
Grimrandomer - 10.05.2012
Ive never made an include, I have a Working system for detecting when a trailer is hooked/detached, but id like it as an include for nice code and to release in the forums if it works well.
What i have:
Код:
#include <a_samp>
/*
native OnVehicleTrailerUpdate(vehicleid,trailerid,resultstate);
*/
#define TRAILERSTATE_ATTACH 0
#define TRAILERSTATE_DETACH 1
#define aTrailers_isTruckModel(%0) ((%0==403)||(%0==514)||(%0==515))
#define aTrailers_isTrailerModel(%0) ((%0==435)||(%0==591)||(%0==450)||(%0==584))
#define aTrailers_isTruck(%0) ((%0>0)&&(isTruckModel(GetVehicleModel(%0))))
#define aTrailers_isTrailer(%0) ((%0>0)&&(isTrailerModel(GetVehicleModel(%0))))
new aTrailers_timer;
new aTrailers_timerRunning=0;
new aTrailers_trailers[MAX_VEHICLES];
forward aTrailers_checkvehicles();
public aTrailers_checkVehicles() {
....
}
stock aTrailers_checkVehicleTrailer(vehicleid){
....
CallLocalFunction("OnVehicleTrailerUpdate","iii",vehicleid,trailerid,TRAILERSTATE_ATTACH);
....
}
stock aTrailers_startChecks(){
if (aTrailers_timerRunning==0) {
aTrailers_timer = SetTimer("aTrailers_checkVehicles", 250, true); //TRAILER HOOCKUP
aTrailers_timerRunning = 1;
}
}
stock aTrailers_endChecks(){
if (aTrailers_timerRunning==1) {
KillTimer(aTrailers_timer); //TRAILER HOOCKUP END
aTrailers_timerRunning = 0;
}
}
I need to override
OnGameModeInit & OnFilterScriptInit to use: aTrailers_startChecks()
OnGameModeExit & OnFilterScriptExit to use: aTrailers_endChecks()
Also, in my aTrailers_checkVehicleTrailer will CallLocalFunction("OnVehicleTrailerUpdate","iii",v ehicleid,trailerid,TRAILERSTATE_ATTACH); work correctly
Finaly, do i need to forward OnVehicleTrailerUpdate(vehicleid,trailerid,results tate) or native it?
Thanks for the help