Advertisement
Guest User

Untitled

a guest
Nov 14th, 2016
233
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.21 KB | None | 0 0
  1. /*
  2. Troll detection
  3. By Jelly23
  4. */
  5. #include <a_samp>
  6.  
  7. /*Vars*/
  8. static VehID[MAX_PLAYERS];
  9.  
  10. /*Callbacks*/
  11. forward OnPlayerTroll(playerid);
  12. forward A_TrollDetection();
  13.  
  14. /*Functions*/
  15. stock A_PutPlayerInVehicle(playerid, vehicleid, seatid)
  16. {
  17. if(IsPlayerInAnyVehicle(playerid))
  18. {
  19. RemovePlayerFromVehicle(playerid);
  20. }
  21. if(PutPlayerInVehicle(playerid, vehicleid, seatid))
  22. {
  23. VehID[playerid] = vehicleid;
  24. return 1;
  25. }
  26. return 0;
  27. }
  28. public A_TrollDetection()
  29. {
  30. for(new i = 0, j = GetPlayerPoolSize(); i <= j; i++)
  31. {
  32. if(IsPlayerConnected(i))
  33. {
  34. if(IsPlayerInAnyVehicle(i))
  35. {
  36. if(GetPlayerState(i) == PLAYER_STATE_DRIVER)
  37. {
  38. if(VehID[i] != GetPlayerVehicleID(i))
  39. {
  40. CallLocalFunction("OnPlayerTroll", "i", i);
  41. }
  42. }
  43. }
  44. }
  45. }
  46. }
  47.  
  48. public OnPlayerStateChange(playerid, newstate, oldstate)
  49. {
  50. if(newstate == PLAYER_STATE_DRIVER || newstate == PLAYER_STATE_PASSENGER)
  51. {
  52. VehID[playerid] = GetPlayerVehicleID(playerid);
  53. }
  54. if(oldstate == PLAYER_STATE_PASSENGER && newstate == PLAYER_STATE_DRIVER && VehID[playerid] != GetPlayerVehicleID(playerid))
  55. {
  56. CallLocalFunction("OnPlayerTroll", "i", playerid);
  57. }
  58. #if defined A_OnPlayerStateChange
  59. return A_OnPlayerStateChange(playerid, newstate, oldstate);
  60. #else
  61. return 1;
  62. #endif
  63. }
  64.  
  65. public OnGameModeInit()
  66. {
  67. SetTimer("A_TrollDetection", 1000, true);
  68. #if defined A_OnGameModeInit
  69. return A_OnGameModeInit();
  70. #else
  71. return 1;
  72. #endif
  73. }
  74.  
  75.  
  76. #if defined _ALS_PutPlayerInVehicle
  77. #undef PutPlayerInVehicle
  78. #else
  79. #define _ALS_PutPlayerInVehicle
  80. #endif
  81. #define PutPlayerInVehicle A_PutPlayerInVehicle
  82.  
  83. #if defined _ALS_OnGameModeInit
  84. #undef OnGameModeInit
  85. #else
  86. #define _ALS_OnGameModeInit
  87. #endif
  88. #define OnGameModeInit A_OnGameModeInit
  89.  
  90. #if defined _ALS_OnPlayerStateChange
  91. #undef OnPlayerStateChange
  92. #else
  93. #define _ALS_OnPlayerStateChange
  94. #endif
  95. #define OnPlayerStateChange A_OnPlayerStateChange
  96.  
  97. #if defined A_OnGameModeInit
  98. forward A_OnGameModeInit();
  99. #endif
  100.  
  101. #if defined A_OnPlayerStateChange
  102. forward A_OnPlayerStateChange(playerid, newstate, oldstate);
  103. #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement