Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define _SILENCE_STDEXT_HASH_DEPRECATION_WARNINGS
- #include <windows.h>
- #include <string>
- #include <assert.h>
- #include <process.h>
- #include "SAMPFUNCS_API.h"
- #include "game_api\game_api.h"
- SAMPFUNCS *SF = new SAMPFUNCS();
- bool ActTeleportActor;
- DWORD time;
- bool Timer;
- float mapPos[3];
- void Timer1()
- {
- mapPos[2] = GAME->GetWorld()->FindGroundZForPosition(mapPos[0], mapPos[1]);
- PEDSELF->Teleport(mapPos[0], mapPos[1], mapPos[2] + 0.5f);
- ActTeleportActor = false;
- Timer = false;
- }
- void CALLBACK TeleportActor(std::string)
- {
- ActTeleportActor ^= true;
- if (ActTeleportActor)
- {
- if ((*(int *)0xBA6774 != 0))
- {
- for (int i = 0; i < (0xAF * 0x28); i += 0x28)
- {
- if (*(short *)(0xBA873D + i) == 4611)
- {
- float *pos = (float *)(0xBA86F8 + 0x28 + i);
- mapPos[0] = *pos;
- mapPos[1] = *(pos + 1);
- mapPos[2] = GAME->GetWorld()->FindGroundZForPosition(pos[0], pos[1]) + 1.0f;
- PEDSELF->Teleport(mapPos[0], mapPos[1], mapPos[2]);
- time = GetTickCount();
- Timer = true;
- }
- }
- }
- }
- }
- void CALLBACK mainloop()
- {
- static bool init = false;
- if (!init)
- {
- if (GAME == nullptr)
- return;
- if (GAME->GetSystemState() != eSystemState::GS_PLAYING_GAME)
- return;
- if (!SF->getSAMP()->IsInitialized())
- return;
- SF->getSAMP()->getChat()->AddChatMessage(0xffcacaca, "SFPlugin TPC loaded");
- SF->getSAMP()->registerChatCommand("tpcsf", TeleportActor);
- init = true;
- }
- if (GetTickCount() - time > 50 && Timer) Timer1();
- }
- BOOL APIENTRY DllMain(HMODULE hModule, DWORD dwReasonForCall, LPVOID lpReserved)
- {
- switch (dwReasonForCall)
- {
- case DLL_PROCESS_ATTACH:
- SF->initPlugin(mainloop, hModule);
- break;
- case DLL_THREAD_ATTACH:
- case DLL_THREAD_DETACH:
- case DLL_PROCESS_DETACH:
- break;
- }
- return TRUE;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement