Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* SA-MP Include Trailer Callback
- *
- * (c) by Kaliber, 2015
- *
- */
- #if !defined _samp_included
- #include <a_samp>
- #endif
- #if defined _samp_trailer
- #endinput
- #endif
- #define _samp_trailer
- #if !defined MAX_TRAILER
- #define MAX_TRAILER (50)
- #endif
- #define A:: a_S_
- /*
- native CreateTrailer(modelid,Float:x,Float:y,Float:z,Float:a,color1,color2,respawn_delay);
- */
- static trailer[MAX_TRAILER];
- stock CreateTrailer(modelid,Float:x,Float:y,Float:z,Float:a,color1,color2,respawn_delay)
- {
- static idx;
- if(idx == MAX_TRAILER) return 0;
- trailer[idx++] = CreateVehicle(modelid,x,y,z,a,color1,color2,respawn_delay);
- return trailer[idx-1];
- }
- #if defined FILTERSCRIPT
- public OnFilterScriptInit()
- {
- SetTimer(!"@trailer",750,1);
- #if defined a_S_OnFilterScriptInit
- return A::OnFilterScriptInit();
- #else
- return 1;
- #endif
- }
- #if defined a_S_OnFilterScriptInit
- forward A::OnFilterScriptInit();
- #endif
- #if defined _ALS_OnFilterScriptInit
- #undef OnFilterScriptInit
- #else
- #define _ALS_OnFilterScriptInit
- #endif
- #define OnFilterScriptInit a_S_OnFilterScriptInit
- #else
- public OnGameModeInit()
- {
- SetTimer(!"@trailer",750,1);
- #if defined a_S_OnGameModeInit
- return A::OnGameModeInit();
- #else
- return 1;
- #endif
- }
- #if defined a_S_OnGameModeInit
- forward A::OnGameModeInit();
- #endif
- #if defined _ALS_OnGameModeInit
- #undef OnGameModeInit
- #else
- #define _ALS_OnGameModeInit
- #endif
- #define OnGameModeInit a_S_OnGameModeInit
- #endif
- static @trailer();@trailer() {
- static bool:attached[MAX_TRAILER char];
- for(new i; i<MAX_TRAILER; i++)
- {
- if(!trailer[i]) continue;
- if(IsTrailerAttachedToVehicle(trailer[i]) && !attached{i}) {
- CallLocalFunction(!"OnTrailerAttached",!"i",trailer[i]);
- attached{i}=true;
- } else if(!IsTrailerAttachedToVehicle(trailer[i]) && attached{i}) {
- CallLocalFunction(!"OnTrailerDetached",!"i",trailer[i]);
- attached{i}=false;
- }
- }
- return 1;
- }
- forward OnTrailerAttached(vehicleid);
- forward OnTrailerDetached(vehicleid);
- #undef A
Advertisement
Add Comment
Please, Sign In to add comment