#include <windows.h>
#include <string>
#include <assert.h>
#include <process.h>
#include "bass.h"
#include "SAMPFUNCS_API.h"
#include "game_api\game_api.h"
#pragma comment(lib, "winmm.lib")
#pragma comment(lib, "bass.lib")
HSTREAM stream;
stFontInfo *pFont;
SAMPFUNCS *SF = new SAMPFUNCS();
#define _copyright "Multi"
bool update = false, _enabled = false, hitsound = false, infokill = false;
float damage, target_pos[3];
int playerID;
char renderkill [125];
bool bassed = false;
bool CALLBACK Present(CONST RECT *pSourceRect, CONST RECT *pDestRect, HWND hDestWindowOverride,
CONST RGNDATA *pDirtyRegion)
{
if (SUCCEEDED(SF->getRender()->BeginRender() && bassed == true))
{
{
if (update && damage > 0.0f)
{
float xf, yf;
SF->getGame()->convert3DCoordsToScreen(target_pos[0], target_pos[1], target_pos[2], &xf, &yf);
char buffer[228];
sprintf(buffer, "%.f", damage);
if(infokill == true)
{
pFont->Print(renderkill, D3DCOLOR_ARGB(0, 255, 255, 255), 500, 500, false);
}
else if(_enabled == true)
pFont->Print(buffer, D3DCOLOR_ARGB(0, 255, 255, 255), xf, yf, false);
static bool state = false;
static DWORD dwTime = 0;
if (!state)
{
state = true;
dwTime = GetTickCount();
}
else if (state && GetTickCount() - dwTime > 3000)
{
update = false;
state = false;
}
}
SF->getRender()->EndRender();
};
};
return true;
}
bool CALLBACK outcomingData(stRakNetHookParams *params)
{
if (params->packetId == PacketEnumeration::ID_BULLET_SYNC && bassed == true)
{
{
stBulletData data;
memset(&data, 0, sizeof(stBulletData));
byte packet;
params->bitStream->ResetReadPointer();
params->bitStream->Read(packet);
params->bitStream->Read((PCHAR)&data, sizeof(stBulletData));
params->bitStream->ResetReadPointer();
if(data.byteType != 0 && _enabled)
{
//SF->getSAMP()->getChat()->AddChatMessage( D3DCOLOR_XRGB( 0, 0xAA, 0 ), "3d pawet" );
for(int i = 0; i < 3; i++)
target_pos[i] = data.fTarget[i];
}
else if(infokill == true)
{
playerID = data.sTargetID;
//SF->getSAMP()->getChat()->AddChatMessage( D3DCOLOR_XRGB( 0, 0xAA, 0 ), "infokill pawet" );
if (ACTOR_IS_DEAD(SF->getSAMP()->getPlayers()->pRemotePlayer[playerID]->pPlayerData->pSAMP_Actor->pGTA_Ped) ||
SF->getSAMP()->getPlayers()->pRemotePlayer[playerID]->pPlayerData->fActorHealth <= 0.0f)
{
playerID++;
sprintf(renderkill, "Kill: %d" , playerID);
}
}
else if(hitsound == true)
{
//SF->getSAMP()->getChat()->AddChatMessage( D3DCOLOR_XRGB( 0, 0xAA, 0 ), "hitsound pawet" );
mciSendString("SAMPFUNCS\\hitsound.mp3", NULL, 0, NULL);
}
params->bitStream->ResetWritePointer();
params->bitStream->Write(packet);
params->bitStream->Write((PCHAR)&data, sizeof(stBulletData));
}
};
return true;
};
void CALLBACK paramfunction1(std:: string param)
{
hitsound ^= true;
if(hitsound == true)
GAME->GetAudio()->PlayFrontEndSound(1);
else
GAME->GetAudio()->PlayFrontEndSound(2);
}
void CALLBACK paramfunction(std:: string param)
{
_enabled ^= true;
if(_enabled == true)
GAME->GetAudio()->PlayFrontEndSound(1);
else
GAME->GetAudio()->PlayFrontEndSound(2);
}
void CALLBACK paramfunction2(std:: string param)
{
infokill ^= true;
if(infokill == true)
GAME->GetAudio()->PlayFrontEndSound(1);
else
GAME->GetAudio()->PlayFrontEndSound(2);
}
void CALLBACK bassedd(std:: string param)
{
bassed ^= true;
if(bassed == true)
GAME->GetAudio()->PlayFrontEndSound(1);
else
GAME->GetAudio()->PlayFrontEndSound(2);
}
void CALLBACK radio(std:: string param)
{
bool radioon = false;
radioon ^= true;
if(radioon == true && !BASS_Init (-1, 44100, 0 , NULL, NULL))
{
char url[] = "http://air.radiorecord.ru:8102/sd90_320";
stream = BASS_StreamCreateURL(url, 0, 0, NULL, 0);
BASS_ChannelPlay(stream,TRUE);
}
else
{
BASS_ChannelPlay(stream,FALSE);
}
}
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( D3DCOLOR_XRGB( 0, 0xAA, 0 ), _copyright );
pFont = SF->getRender()->CreateNewFont("Tahoma", 10, FCR_BORDER);
SF->getRakNet()->registerRakNetCallback(RakNetScriptHookType::RAKHOOK_TYPE_OUTCOMING_PACKET, outcomingData);
SF->getSAMP()->registerChatCommand( "radio", radio);
SF->getSAMP()->registerChatCommand( "dmg", bassedd);
SF->registerConsoleCommand("dmg_3d", paramfunction);
SF->registerConsoleCommand("dmg_hit", paramfunction1);
SF->registerConsoleCommand("dmg_infokill", paramfunction2);
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;
}