Advertisement
Guest User

Trailer Callbacks

a guest
Oct 16th, 2016
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.65 KB | None | 0 0
  1. /* SA-MP Include Trailer
  2.  *
  3.  * (c) by Kaliber, 2016
  4.  *
  5.  */
  6. #if !defined _samp_included
  7.     #include <a_samp>
  8. #endif
  9. #if defined _samp_trailer
  10.     #endinput
  11. #endif
  12. #define _samp_trailer
  13. /******************************************************************************/
  14. #define Hook:: _@@_
  15. /******************************************************************************/
  16. forward OnTrailerAttachedToVehicle(vehicleid, trailerid);
  17. forward OnTrailerDettachedFromVehicle(vehicleid, trailerid);
  18. /******************************************************************************/
  19. public OnGameModeInit()
  20. {
  21.     SetTimer(!"@trailer_check",997,1);
  22.     #if defined _@@_OnGameModeInit
  23.         return Hook::OnGameModeInit();
  24.     #else
  25.         return 1;
  26.     #endif
  27. }
  28. #if defined _@@_OnGameModeInit
  29.     forward Hook::OnGameModeInit();
  30. #endif
  31. #if defined _ALS_OnGameModeInit
  32.     #undef OnGameModeInit
  33. #else
  34.     #define _ALS_OnGameModeInit
  35. #endif
  36. #define OnGameModeInit _@@_OnGameModeInit
  37. /******************************************************************************/
  38. static @trailer_check();@trailer_check()
  39. {
  40.     static v,str[16],t;
  41.     for(v=GetVehiclePoolSize(); v!=0; v--)
  42.     {
  43.         format(str,sizeof(str),"v_%d",v);
  44.         if(IsTrailerAttachedToVehicle(v))
  45.         {
  46.             if(existproperty(.name=str)) continue;
  47.             t = GetVehicleTrailer(v);
  48.             setproperty(.name=str,.value=t);
  49.             CallLocalFunction(!"OnTrailerAttachedToVehicle",!"dd",v,t);
  50.         }
  51.         else
  52.         {
  53.             if(existproperty(.name=str))
  54.             {
  55.                 CallLocalFunction(!"OnTrailerDettachedFromVehicle",!"dd",v,getproperty(.name=str));
  56.                 deleteproperty(.name=str);
  57.             }
  58.         }
  59.     }
  60.     return 1;
  61. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement