#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 lol;
bool bGiveOrTake;
short int iPlayerID;
float fAmmount;
int iWeaponID, iBodyPart;
DWORD rTimer;
stFontInfo *pFont;
char buf[128];
bool CALLBACK outcomingRPC( stRakNetHookParams *params )
{
if( params->packetId == RPCEnumeration::RPC_GiveTakeDamage)
if(lol == true)
{
params->bitStream->Read(bGiveOrTake);
params->bitStream->Read(iPlayerID);
params->bitStream->Read(fAmmount);
params->bitStream->Read(iWeaponID);
params->bitStream->Read(iBodyPart);
if(!bGiveOrTake)
{
SF->getSAMP()->getChat()->AddChatMessage(D3DCOLOR_XRGB(245, 184, 0), "{006400}Попал по: %d | Нанес: %.f | Оружие: %d | Часть тела: %d ",iPlayerID, fAmmount, iWeaponID, iBodyPart);
sprintf(buf, "{006400}/ - %.2f / ", fAmmount );
rTimer = GetTickCount() + 2000;
}
else
{
SF->getSAMP()->getChat()->AddChatMessage(D3DCOLOR_XRGB(245, 184, 0), "{8b0000}Урон от: %d | Нанес по мне: %.f | Оружие: %d | Часть тела: %d ",iPlayerID, fAmmount, iWeaponID, iBodyPart);
}
};
return true;
};
bool CALLBACK Present ( CONST RECT *pSourceRect, CONST RECT *pDestRect, HWND hDestWindowOverride,
CONST RGNDATA *pDirtyRegion )
{
if( SUCCEEDED( SF->getRender()->BeginRender() && lol == true))
if (rTimer >= GetTickCount())
{
float sx, sy;
SF->getGame()->convert3DCoordsToScreen(SF->getSAMP()->getPlayers()->GetOnFootData(iPlayerID)->fPosition[0],SF->getSAMP()->getPlayers()->GetOnFootData(iPlayerID)->fPosition[1],SF->getSAMP()->getPlayers()->GetOnFootData(iPlayerID)->fPosition[2]+1,&sx,&sy);
pFont->Print(buf, sx, sy, false );
SF->getRender()->EndRender();
};
return true;
};
void CALLBACK testt( std::string param )
{
lol ^= true;
if(lol)
SF->Log("{006400}ON");
else
SF->Log("{8b0000}OFF");
}
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->getRakNet()->registerRakNetCallback( RakNetScriptHookType::RAKHOOK_TYPE_OUTCOMING_RPC, outcomingRPC );
pFont = SF->getRender()->CreateNewFont("Tahoma", 5, FCR_BORDER );
SF->getRender()->registerD3DCallback( eDirect3DDeviceMethods::D3DMETHOD_PRESENT, Present );
SF->getSAMP()->registerChatCommand( "dinf", testt );
init = true;
}
}
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;
}