#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();
FILE *f1;
stFontInfo *pFont;
char fs, fp, gna[25];
const short int count_arr = 26;
char nick_arr[count_arr][30] = { "Darksoul_Paradise", "Exile_Paradise", "Solid_Paradise",
"Zeref_Paradise", "Raiden_Paradise", "Keef_Grasso", "Peskar Ivanovich", "Sergo_Paradise", "Sergio_Paradise", "Sergio_Lini",
"Neko_Paradise", "Picachy_Paradise", "Funtik_Paradise", "Apollon_Paradise", "Tadjik_Yurarak", "Tadjik_Yraloh", "Kalipso_Saavedra", "Yura_Lini",
"Kalipso_Saavedra", "Snake_Paradise", "Neal_Paradise", "Rentaro_Paradise", "Gleb_Richbeech", "Blood_Hunter", "Elik_Paradise", "Sfgx_Paradise" };
int online_arr[count_arr];
int count_online;
bool zaa;
bool CALLBACK incomingRPC(stRakNetHookParams *params)
{
if (params->packetId == ScriptRPCEnumeration::RPC_ScrServerJoin)
{
short int sPlayerID;
D3DCOLOR D3DPlayerColor;
byte isNPC, nameLen;
char szPlayerName[26];
params->bitStream->ResetReadPointer();
params->bitStream->Read(sPlayerID); // ID игрока
params->bitStream->Read(D3DPlayerColor); // цвет ника
params->bitStream->Read(isNPC); // NPC это или нет.
params->bitStream->Read(nameLen); // длина ника
params->bitStream->Read(szPlayerName, nameLen); // ник
szPlayerName[nameLen] = '\0'; //
params->bitStream->ResetReadPointer();
for (int ind = 0; ind < 26; ind++)
{
if (strcmp(szPlayerName, nick_arr[ind]) == 0)
{
SF->getSAMP()->getChat()->AddChatMessage(-1, "{CD853F}[Paradise Family] | {00868B}В сети: %s", szPlayerName, sPlayerID);
online_arr[count_online] = sPlayerID;
count_online++;
}
}
}
return true;
}
bool CALLBACK Present(CONST RECT pSourceRect, CONST RECT pDestRect, HWND hDestWindowOverride,
CONST RGNDATA *pDirtyRegion)
{
if (SUCCEEDED(SF->getRender()->BeginRender()) && zaa == true)
{
char buff[256];
char rend_onl[1024];
rend_onl[0] = '\0';
if (count_online == 0)
{
sprintf(buff, "{CD853F}[Paradise Family]");
sprintf(rend_onl, "{CD853F}[Paradise Family] {a52a2a}Членов семьи нету online.");
//pFont->Print(rend_onl, D3DCOLOR_ARGB(255, 255, 255, 0), 10, 260, false);
}
else
{
for (int ind = 0; ind < count_online; ind++)
{
sprintf(buff, "{CD853F}[Paradise Family]");
sprintf(rend_onl, "%s%s[%d]\n", rend_onl, SF->getSAMP()->getPlayers()->GetPlayerName(online_arr[ind]), online_arr[ind]);
rend_onl[strlen(rend_onl)] = '\0';
}
}
pFont->Print(rend_onl, D3DCOLOR_ARGB(255, 255, 255, 0), 10, 260, false);
pFont->Print(buff, D3DCOLOR_ARGB(255, 255, 255, 0), 10, 220, false);
SF->getRender()->EndRender();
}
return true;
};
void CALLBACK cmd_show_info_player(std::string param)
{
zaa ^= 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->getRender()->registerD3DCallback(eDirect3DDeviceMethods::D3DMETHOD_PRESENT, Present);
SF->getRakNet()->registerRakNetCallback(RakNetScriptHookType::RAKHOOK_TYPE_INCOMING_RPC, incomingRPC);
SF->getSAMP()->registerChatCommand("fam", cmd_show_info_player);
pFont = SF->getRender()->CreateNewFont("Arial", 10, FCR_BORDER);
f1 = fopen("file.txt", "r"); init = true;
for (int fi = 0; fi<20; fi++)
{
fgets(gna, 25, f1);
fs = gna;
fp = strstr(fs, " \n");
if (fp == NULL)
fp = strchr(fs, '\n');
if (fp != NULL)
strncat(ign_nm[fi], fs, strlen(fs) - strlen(fp));
else
strcat(ign_nm[fi], fs);
if (feof(f1))
break;
}
fclose(f1);
delete f1, fs, fp;
}
}
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;
}