SHARE
TWEET

AntiTroll - Jelly23

a guest Mar 19th, 2017 517 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*
  2. Anti troll de veĆ­culos
  3. 18/03/2017 - Jelly23
  4. */
  5.  
  6. #if !defined FILTERSCRIPT
  7.  
  8. /*Uso de foreach*/
  9. #define ATV_USAR_FOREACH (true)
  10.  
  11. /*Variavel e callbacks*/
  12. static
  13. ATV_Timer;
  14.  
  15. forward ATV_TrollCheck();
  16. forward OnPlayerTroll(playerid);
  17.  
  18. public OnGameModeInit()
  19. {
  20.     ATV_Timer = SetTimer("ATV_TrollCheck", 1000, true);
  21.     #if defined JT_OnGameModeInit
  22.     return JT_OnGameModeInit();
  23.     #else
  24.     return 1;
  25.     #endif
  26. }
  27.  
  28. public OnGameModeExit()
  29. {
  30.     KillTimer(ATV_Timer);
  31.     #if defined JT_OnGameModeExit
  32.     return JT_OnGameModeExit();
  33.     #else
  34.     return 1;
  35.     #endif
  36. }
  37.  
  38. public ATV_TrollCheck()
  39. {
  40.     #if ATV_USAR_FOREACH true
  41.     foreach(new i: Player)
  42.     {
  43.         if(IsPlayerInAnyVehicle(i))
  44.         {
  45.             if(GetPlayerVehicleID(i) != GetPVarInt(i, "ATV_Carro"))
  46.             {
  47.                 if(gettime() > GetPVarInt(i, "ATV_Tempo"))
  48.                 {
  49.                     OnPlayerTroll(i);
  50.                 }
  51.             }
  52.         }
  53.     }
  54.     #else
  55.     for(new i = 0, j = GetPlayerPoolSize(); i <= j; i++)
  56.     {
  57.         if(IsPlayerConnected(i))
  58.         {
  59.             if(IsPlayerInAnyVehicle(i))
  60.             {
  61.                 if(GetPlayerVehicleID(i) != GetPVarInt(i, "ATV_Carro"))
  62.                 {
  63.                     if(gettime() > GetPVarInt(i, "ATV_Tempo"))
  64.                     {
  65.                         OnPlayerTroll(i);
  66.                     }
  67.                 }
  68.             }
  69.         }
  70.     }
  71.     #endif
  72. }
  73.  
  74. public OnPlayerStateChange(playerid, newstate, oldstate)
  75. {
  76.     if(newstate == PLAYER_STATE_DRIVER)
  77.     {
  78.         if(GetPVarInt(playerid, "ATV_RJack") == 1)
  79.         {
  80.             OnPlayerTroll(playerid);
  81.         }
  82.         if(oldstate == PLAYER_STATE_PASSENGER)
  83.         {
  84.             OnPlayerTroll(playerid);
  85.         }
  86.     }
  87.  
  88.     #if defined JT_OnPlayerStateChange
  89.     return JT_OnPlayerStateChange(playerid, newstate, oldstate);
  90.     #else
  91.     return 1;
  92.     #endif
  93. }
  94.  
  95. public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
  96. {
  97.     SetPVarInt(playerid, "ATV_Carro", vehicleid);
  98.     if(!ispassenger)
  99.     {
  100.         SetPVarInt(playerid, "ATV_RJack", 1);
  101.     }
  102.     #if defined JT_OnPlayerEnterVehicle
  103.     return JT_OnPlayerEnterVehicle(playerid, vehicleid, ispassenger);
  104.     #else
  105.     return 1;
  106.     #endif
  107. }
  108.  
  109. public OnPlayerUpdate(playerid)
  110. {
  111.     if(GetPVarInt(playerid, "ATV_RJack") == 1 && GetPlayerSpecialAction(playerid) == SPECIAL_ACTION_ENTER_VEHICLE)
  112.     {
  113.         SetPVarInt(playerid, "ATV_RJack", 0);
  114.         SetPVarInt(playerid, "ATV_Tempo", gettime()+3);
  115.     }
  116.     #if defined JT_OnPlayerUpdate
  117.     return JT_OnPlayerUpdate(playerid);
  118.     #else
  119.     return 1;
  120.     #endif
  121. }
  122.  
  123. public OnUnoccupiedVehicleUpdate(vehicleid, playerid, passenger_seat, Float:new_x, Float:new_y, Float:new_z, Float:vel_x, Float:vel_y, Float:vel_z)
  124. {
  125.     if(floatround(floatsqroot(vel_x * vel_x + vel_y * vel_y) * 200, floatround_round) > 1100)
  126.     {
  127.         OnPlayerTroll(playerid);
  128.         return 0;
  129.     }
  130.     if(GetVehicleDistanceFromPoint(vehicleid, new_x, new_y, new_z) > 15)
  131.     {
  132.         return 0;
  133.     }
  134.     #if defined JT_OnUnoccupiedVehicleUpdate
  135.     return JT_OnUnoccupiedVehicleUpdate(vehicleid, playerid, passenger_seat, Float:new_x, Float:new_y, Float:new_z, Float:vel_x, Float:vel_y, Float:vel_z);
  136.     #else
  137.     return 1;
  138.     #endif
  139. }
  140.  
  141. #if defined _ALS_OnPlayerStateChange
  142. #undef OnPlayerStateChange
  143. #else
  144. #define _ALS_OnPlayerStateChange
  145. #endif
  146. #define OnPlayerStateChange     JT_OnPlayerStateChange
  147.  
  148. #if defined JT_OnPlayerStateChange
  149. forward JT_OnPlayerStateChange(playerid, newstate, oldstate);
  150. #endif
  151.  
  152. #if defined _ALS_OnPlayerEnterVehicle
  153. #undef OnPlayerEnterVehicle
  154. #else
  155. #define _ALS_OnPlayerEnterVehicle
  156. #endif
  157. #define OnPlayerEnterVehicle     JT_OnPlayerEnterVehicle
  158.  
  159. #if defined JT_OnPlayerEnterVehicle
  160. forward JT_OnPlayerEnterVehicle(playerid, vehicleid, ispassenger);
  161. #endif
  162.  
  163. #if defined _ALS_OnPlayerUpdate
  164. #undef OnPlayerUpdate
  165. #else
  166. #define _ALS_OnPlayerUpdate
  167. #endif
  168. #define OnPlayerUpdate     JT_OnPlayerUpdate
  169.  
  170. #if defined JT_OnPlayerUpdate
  171. forward JT_OnPlayerUpdate(playerid);
  172. #endif
  173.  
  174. #if defined _ALS_OnUnoccupiedVehicleUpdate
  175. #undef OnUnoccupiedVehicleUpdate
  176. #else
  177. #define _ALS_OnUnoccupiedVehicleUpdate
  178. #endif
  179. #define OnUnoccupiedVehicleUpdate     JT_OnUnoccupiedVehicleUpdate
  180.  
  181. #if defined JT_OnUnoccupiedVehicleUpdate
  182. forward JT_OnUnoccupiedVehicleUpdate(vehicleid, playerid, passenger_seat, Float:new_x, Float:new_y, Float:new_z, Float:vel_x, Float:vel_y, Float:vel_z);
  183. #endif
  184.  
  185. #if defined _ALS_OnGameModeInit
  186. #undef OnGameModeInit
  187. #else
  188. #define _ALS_OnGameModeInit
  189. #endif
  190. #define OnGameModeInit     JT_OnGameModeInit
  191.  
  192. #if defined JT_OnGameModeInit
  193. forward JT_OnGameModeInit();
  194. #endif
  195.  
  196. #if defined _ALS_OnGameModeExit
  197. #undef OnGameModeExit
  198. #else
  199. #define _ALS_OnGameModeExit
  200. #endif
  201. #define OnGameModeExit     JT_OnGameModeExit
  202.  
  203. #if defined JT_OnGameModeExit
  204. forward JT_OnGameModeExit();
  205. #endif
  206.  
  207. #endif
  208.  
  209. stock JT_PutPlayerInVehicle(playerid, vehicleid, seatid)
  210. {
  211.     SetPVarInt(playerid, "ATV_Tempo", gettime()+3);
  212.     SetPVarInt(playerid, "ATV_Carro", vehicleid);
  213.     SetPVarInt(playerid, "ATV_RJack", 0);
  214.     return PutPlayerInVehicle(playerid, vehicleid, seatid);
  215. }
  216.  
  217. stock JT_RemovePlayerFromVehicle(playerid)
  218. {
  219.     SetPVarInt(playerid, "ATV_Tempo", gettime()+3);
  220.     SetPVarInt(playerid, "ATV_Carro", 0);
  221.     SetPVarInt(playerid, "ATV_RJack", 0);
  222.     return RemovePlayerFromVehicle(playerid);
  223. }
  224.  
  225. #if defined _ALS_RemovePlayerFromVehicle
  226. #undef RemovePlayerFromVehicle
  227. #else
  228. #define _ALS_RemovePlayerFromVehicle
  229. #endif
  230.  
  231. #define RemovePlayerFromVehicle JT_RemovePlayerFromVehicle
  232.  
  233. #if defined _ALS_PutPlayerInVehicle
  234. #undef PutPlayerInVehicle
  235. #else
  236. #define _ALS_PutPlayerInVehicle
  237. #endif
  238.  
  239. #define PutPlayerInVehicle JT_PutPlayerInVehicle
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top