Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <sampgdk/core.h>
- #include <sampgdk/plugin.h>
- #include <sampgdk/a_players.h>
- #include <thread>
- #include <chrono>
- typedef void (*logprintf_t)(const char*, ...);
- extern logprintf_t logprintf;
- logprintf_t logprintf;
- short int Spawned[MAX_PLAYERS];
- bool n_VerificarPlayer(int playerid) {
- if(! IsPlayerConnected(playerid)) {
- Spawned[playerid] = false;
- return true;
- }
- std::this_thread::sleep_for(std::chrono::seconds(1));
- char pname[24];
- GetPlayerName(playerid, pname, MAX_PLAYER_NAME);
- if(GetPlayerState(playerid) != PLAYER_STATE_NONE && Spawned[playerid] == false)
- {
- Kick(playerid);
- logprintf("%s egy BOT... volt.(State)", pname);
- return true;
- }
- if(GetPlayerState(playerid) != PLAYER_STATE_NONE && GetPlayerCameraMode(playerid) > 100)
- {
- Kick(playerid);
- logprintf("%s egy BOT... volt.(CameraMode)", pname);
- return true;
- }
- float x, y, z;
- GetPlayerCameraPos(playerid, &x, &y, &z);
- if(GetPlayerState(playerid) != PLAYER_STATE_NONE && x == 0.0 && y == 0.0 && z == 0.0)
- {
- Kick(playerid);
- logprintf("%s egy BOT... volt.(CameraPos)", pname);
- return true;
- }
- GetPlayerCameraFrontVector(playerid, &x, &y, &z);
- if(GetPlayerState(playerid) != PLAYER_STATE_NONE && (x > 1000.0 || y > 1000.0 || z > 1000.0))
- {
- Kick(playerid);
- logprintf("%s egy BOT... volt.(CameraFrontVector)", pname);
- return true;
- }
- std::thread nvp(n_VerificarPlayer, playerid);
- nvp.detach();
- return true;
- }
- cell AMX_NATIVE_CALL p_OnPlayerConnect(AMX* amx, cell* params)
- {
- Spawned[(int)params[1]] = false;
- std::thread nvp(n_VerificarPlayer, (int)params[1]);
- nvp.detach();
- return 1;
- }
- cell AMX_NATIVE_CALL p_OnPlayerSpawn(AMX* amx, cell* params)
- {
- Spawned[(int)params[1]] = true;
- return 1;
- }
- PLUGIN_EXPORT bool PLUGIN_CALL Load(void **ppPluginData)
- {
- sampgdk_initialize_plugin(ppPluginData);
- logprintf = (logprintf_t)ppPluginData[PLUGIN_DATA_LOGPRINTF];
- logprintf("\n\n*** Plugin carregado ***\n");
- return true;
- }
- PLUGIN_EXPORT void PLUGIN_CALL Unload()
- {
- logprintf("\n\n*** Terminado ***\n");
- }
- AMX_NATIVE_INFO natives[] =
- {
- { "p_OnPlayerConnect", p_OnPlayerConnect},
- { "p_OnPlayerSpawn", p_OnPlayerSpawn},
- { 0, 0 }
- };
- PLUGIN_EXPORT unsigned int PLUGIN_CALL Supports()
- {
- return SUPPORTS_VERSION | SUPPORTS_AMX_NATIVES | SUPPORTS_PROCESS_TICK;
- }
- PLUGIN_EXPORT int PLUGIN_CALL AmxLoad(AMX *amx)
- {
- return amx_Register(amx, natives, -1);
- }
- PLUGIN_EXPORT int PLUGIN_CALL AmxUnload(AMX *amx)
- {
- return AMX_ERR_NONE;
- }
- PLUGIN_EXPORT void PLUGIN_CALL ProcessTick() {
- sampgdk_process_timers();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement