Advertisement
obernardovieira

[Plugin] Anti rakSAMP

Sep 14th, 2013
460
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.55 KB | None | 0 0
  1. #include <sampgdk/core.h>
  2. #include <sampgdk/plugin.h>
  3. #include <sampgdk/a_players.h>
  4.  
  5. #include <thread>
  6. #include <chrono>
  7.  
  8. typedef void (*logprintf_t)(const char*, ...);
  9.  
  10. extern logprintf_t logprintf;
  11.  
  12. logprintf_t logprintf;
  13.  
  14. short int Spawned[MAX_PLAYERS];
  15.  
  16. bool n_VerificarPlayer(int playerid) {
  17.     if(! IsPlayerConnected(playerid)) {
  18.         Spawned[playerid] = false;
  19.         return true;
  20.     }
  21.     std::this_thread::sleep_for(std::chrono::seconds(1));
  22.     char pname[24];
  23.     GetPlayerName(playerid, pname, MAX_PLAYER_NAME);
  24.     if(GetPlayerState(playerid) != PLAYER_STATE_NONE && Spawned[playerid] == false)
  25.     {
  26.         Kick(playerid);
  27.         logprintf("%s egy BOT... volt.(State)", pname);
  28.         return true;
  29.     }
  30.     if(GetPlayerState(playerid) != PLAYER_STATE_NONE && GetPlayerCameraMode(playerid) > 100)
  31.     {
  32.         Kick(playerid);
  33.         logprintf("%s egy BOT... volt.(CameraMode)", pname);
  34.         return true;
  35.     }
  36.     float x, y, z;
  37.     GetPlayerCameraPos(playerid, &x, &y, &z);
  38.     if(GetPlayerState(playerid) != PLAYER_STATE_NONE && x == 0.0 && y == 0.0 && z == 0.0)
  39.     {
  40.         Kick(playerid);
  41.         logprintf("%s egy BOT... volt.(CameraPos)", pname);
  42.         return true;
  43.     }
  44.     GetPlayerCameraFrontVector(playerid, &x, &y, &z);
  45.     if(GetPlayerState(playerid) != PLAYER_STATE_NONE && (x > 1000.0 || y > 1000.0 || z > 1000.0))
  46.     {
  47.         Kick(playerid);
  48.         logprintf("%s egy BOT... volt.(CameraFrontVector)", pname);
  49.         return true;
  50.     }
  51.     std::thread nvp(n_VerificarPlayer, playerid);
  52.     nvp.detach();
  53.     return true;
  54. }
  55. cell AMX_NATIVE_CALL p_OnPlayerConnect(AMX* amx, cell* params)
  56. {
  57.     Spawned[(int)params[1]] = false;
  58.     std::thread nvp(n_VerificarPlayer, (int)params[1]);
  59.     nvp.detach();
  60.     return 1;
  61. }
  62. cell AMX_NATIVE_CALL p_OnPlayerSpawn(AMX* amx, cell* params)
  63. {
  64.     Spawned[(int)params[1]] = true;
  65.     return 1;
  66. }
  67. PLUGIN_EXPORT bool PLUGIN_CALL Load(void **ppPluginData)
  68. {
  69.     sampgdk_initialize_plugin(ppPluginData);
  70.     logprintf = (logprintf_t)ppPluginData[PLUGIN_DATA_LOGPRINTF];
  71.     logprintf("\n\n*** Plugin carregado ***\n");
  72.     return true;
  73. }
  74. PLUGIN_EXPORT void PLUGIN_CALL Unload()
  75. {
  76.     logprintf("\n\n*** Terminado ***\n");
  77. }
  78. AMX_NATIVE_INFO natives[] =
  79. {
  80.     { "p_OnPlayerConnect", p_OnPlayerConnect},
  81.     { "p_OnPlayerSpawn", p_OnPlayerSpawn},
  82.     { 0, 0 }
  83. };
  84. PLUGIN_EXPORT unsigned int PLUGIN_CALL Supports()
  85. {
  86.     return SUPPORTS_VERSION | SUPPORTS_AMX_NATIVES | SUPPORTS_PROCESS_TICK;
  87. }
  88. PLUGIN_EXPORT int PLUGIN_CALL AmxLoad(AMX *amx)
  89. {
  90.     return amx_Register(amx, natives, -1);
  91. }
  92. PLUGIN_EXPORT int PLUGIN_CALL AmxUnload(AMX *amx)
  93. {
  94.     return AMX_ERR_NONE;
  95. }
  96. PLUGIN_EXPORT void PLUGIN_CALL ProcessTick() {
  97.     sampgdk_process_timers();
  98. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement