- Операционная система
- Linux
#include <sdktools>
#include <dhooks>
#include <morecolors>
public Plugin myinfo =
{
name = "Призыватель дропа",
author = "Phoenix (˙·٠●Феникс●٠·˙)",
version = "1.0.3",
url = "ZiZT"
};
Handle g_hRewardMatchEndDrops = null;
Handle g_hTimerWaitDrops = null;
char g_sLogFile[256];
int g_iOS = -1;
Address g_pDropForAllPlayersPatch = Address_Null;
ConVar g_hDSWaitTimer = null;
ConVar g_hDSInfo = null;
ConVar g_hDSPlaySound = null;
public void OnPluginStart()
{
GameData hGameData = LoadGameConfigFile("DropsSummoner.games");
if (!hGameData)
{
SetFailState("Failed to load DropsSummoner gamedata.");
return;
}
g_iOS = hGameData.GetOffset("OS");
if(g_iOS == -1)
{
SetFailState("Failed to get OS offset");
return;
}
if(g_iOS == 1)
{
StartPrepSDKCall(SDKCall_Raw);
}
else
{
StartPrepSDKCall(SDKCall_Static);
}
PrepSDKCall_SetFromConf(hGameData, SDKConf_Signature, "CCSGameRules::RewardMatchEndDrops");
PrepSDKCall_AddParameter(SDKType_Bool, SDKPass_Plain);
if (!(g_hRewardMatchEndDrops = EndPrepSDKCall()))
{
SetFailState("Failed to create SDKCall for CCSGameRules::RewardMatchEndDrops");
return;
}
DynamicDetour hCCSGameRules_RecordPlayerItemDrop = DynamicDetour.FromConf(hGameData, "CCSGameRules::RecordPlayerItemDrop");
if (!hCCSGameRules_RecordPlayerItemDrop)
{
SetFailState("Failed to setup detour for CCSGameRules::RecordPlayerItemDrop");
return;
}
if(!hCCSGameRules_RecordPlayerItemDrop.Enable(Hook_Post, Detour_RecordPlayerItemDrop))
{
SetFailState("Failed to detour CCSGameRules::RecordPlayerItemDrop.");
return;
}
g_pDropForAllPlayersPatch = hGameData.GetAddress("DropForAllPlayersPatch");
if(g_pDropForAllPlayersPatch != Address_Null)
{
// 83 F8 01 ?? [cmp eax, 1]
if((LoadFromAddress(g_pDropForAllPlayersPatch, NumberType_Int32) & 0xFFFFFF) == 0x1F883)
{
g_pDropForAllPlayersPatch += view_as<Address>(2);
StoreToAddress(g_pDropForAllPlayersPatch, 0xFF, NumberType_Int8);
}
else
{
g_pDropForAllPlayersPatch = Address_Null;
LogError("At address g_pDropForAllPlayersPatch received not what we expected, drop for all players will be unavailable.");
}
}
else
{
LogError("Failed to get address DropForAllPlayersPatch, drop for all players will be unavailable.");
}
delete hGameData;
BuildPath(Path_SM, g_sLogFile, sizeof g_sLogFile, "logs/DropsSummoner.log");
g_hDSWaitTimer = CreateConVar("sm_drops_summoner_wait_timer", "182", "Длительность между попытками призвать дроп в секундах", _, true, 60.0);
g_hDSInfo = CreateConVar("sm_drops_summoner_info", "1", "Уведомлять в чате о попытках призыва дропа", _, true, 0.0, true, 1.0);
g_hDSPlaySound = CreateConVar("sm_drops_summoner_play_sound", "2", "Воспроизводить звук при получении дропа [0 - нет | 1 - только получившему | 2 - всем]", _, true, 0.0, true, 2.0);
}
public void OnPluginEnd()
{
if(g_pDropForAllPlayersPatch != Address_Null)
{
StoreToAddress(g_pDropForAllPlayersPatch, 0x01, NumberType_Int8);
}
}
public void OnMapStart()
{
PrecacheSound("ui/panorama/case_awarded_1_uncommon_01.wav");
CreateTimer(g_hDSWaitTimer.FloatValue, Timer_SendRewardMatchEndDrops, _, TIMER_REPEAT|TIMER_FLAG_NO_MAPCHANGE);
}
MRESReturn Detour_RecordPlayerItemDrop(DHookParam hParams)
{
if(g_hTimerWaitDrops)
{
delete g_hTimerWaitDrops;
}
int iAccountID = hParams.GetObjectVar(1, 16, ObjectValueType_Int);
int iClient = GetClientFromAccountID(iAccountID);
if(iClient != -1)
{
int iDefIndex = hParams.GetObjectVar(1, 20, ObjectValueType_Int);
int iPaintIndex = hParams.GetObjectVar(1, 24, ObjectValueType_Int);
int iRarity = hParams.GetObjectVar(1, 28, ObjectValueType_Int);
int iQuality = hParams.GetObjectVar(1, 32, ObjectValueType_Int);
LogToFile(g_sLogFile, "Игроку %L выпало [%u-%u-%u-%u]", iClient, iDefIndex, iPaintIndex, iRarity, iQuality);
Protobuf hSendPlayerItemFound = view_as<Protobuf>(StartMessageAll("SendPlayerItemFound", USERMSG_RELIABLE));
hSendPlayerItemFound.SetInt("entindex", iClient);
Protobuf hIteminfo = hSendPlayerItemFound.ReadMessage("iteminfo");
hIteminfo.SetInt("defindex", iDefIndex);
hIteminfo.SetInt("paintindex", iPaintIndex);
hIteminfo.SetInt("rarity", iRarity);
hIteminfo.SetInt("quality", iQuality);
hIteminfo.SetInt("inventory", 6); //UNACK_ITEM_GIFTED
EndMessage();
SetHudTextParams(-1.0, 0.4, 3.0, 0, 255, 255, 255);
ShowHudText(iClient, -1, "\x04Вам выпал дроп, смотрите свой инвентарь");
int iPlaySound = g_hDSPlaySound.IntValue;
if(iPlaySound == 2)
{
EmitSoundToAll("ui/panorama/case_awarded_1_uncommon_01.wav", SOUND_FROM_LOCAL_PLAYER, _, SNDLEVEL_NONE);
}
else if(iPlaySound == 1)
{
EmitSoundToClient(iClient, "ui/panorama/case_awarded_1_uncommon_01.wav", SOUND_FROM_LOCAL_PLAYER, _, SNDLEVEL_NONE);
}
}
return MRES_Ignored;
}
int GetClientFromAccountID(int iAccountID)
{
for(int i = 1; i <= MaxClients; i++)
{
if(IsClientConnected(i) && !IsFakeClient(i) && IsClientAuthorized(i))
{
if(GetSteamAccountID(i) == iAccountID)
{
return i;
}
}
}
return -1;
}
Action Timer_SendRewardMatchEndDrops(Handle hTimer)
{
if(g_hDSInfo.BoolValue)
{
g_hTimerWaitDrops = CreateTimer(1.2, Timer_WaitDrops);
PrintToChatAll("{purple}( Ghoul ) \x07Пытаемся призвать дроп");
}
if(g_iOS == 1)
{
SDKCall(g_hRewardMatchEndDrops, 0xDEADC0DE, false);
}
else
{
SDKCall(g_hRewardMatchEndDrops, false);
}
return Plugin_Continue;
}
Action Timer_WaitDrops(Handle hTimer)
{
g_hTimerWaitDrops = null;
PrintToChatAll("{purple}( Ghoul ) \x07Попытка провалилась :(");
}
#include <dhooks>
#include <morecolors>
public Plugin myinfo =
{
name = "Призыватель дропа",
author = "Phoenix (˙·٠●Феникс●٠·˙)",
version = "1.0.3",
url = "ZiZT"
};
Handle g_hRewardMatchEndDrops = null;
Handle g_hTimerWaitDrops = null;
char g_sLogFile[256];
int g_iOS = -1;
Address g_pDropForAllPlayersPatch = Address_Null;
ConVar g_hDSWaitTimer = null;
ConVar g_hDSInfo = null;
ConVar g_hDSPlaySound = null;
public void OnPluginStart()
{
GameData hGameData = LoadGameConfigFile("DropsSummoner.games");
if (!hGameData)
{
SetFailState("Failed to load DropsSummoner gamedata.");
return;
}
g_iOS = hGameData.GetOffset("OS");
if(g_iOS == -1)
{
SetFailState("Failed to get OS offset");
return;
}
if(g_iOS == 1)
{
StartPrepSDKCall(SDKCall_Raw);
}
else
{
StartPrepSDKCall(SDKCall_Static);
}
PrepSDKCall_SetFromConf(hGameData, SDKConf_Signature, "CCSGameRules::RewardMatchEndDrops");
PrepSDKCall_AddParameter(SDKType_Bool, SDKPass_Plain);
if (!(g_hRewardMatchEndDrops = EndPrepSDKCall()))
{
SetFailState("Failed to create SDKCall for CCSGameRules::RewardMatchEndDrops");
return;
}
DynamicDetour hCCSGameRules_RecordPlayerItemDrop = DynamicDetour.FromConf(hGameData, "CCSGameRules::RecordPlayerItemDrop");
if (!hCCSGameRules_RecordPlayerItemDrop)
{
SetFailState("Failed to setup detour for CCSGameRules::RecordPlayerItemDrop");
return;
}
if(!hCCSGameRules_RecordPlayerItemDrop.Enable(Hook_Post, Detour_RecordPlayerItemDrop))
{
SetFailState("Failed to detour CCSGameRules::RecordPlayerItemDrop.");
return;
}
g_pDropForAllPlayersPatch = hGameData.GetAddress("DropForAllPlayersPatch");
if(g_pDropForAllPlayersPatch != Address_Null)
{
// 83 F8 01 ?? [cmp eax, 1]
if((LoadFromAddress(g_pDropForAllPlayersPatch, NumberType_Int32) & 0xFFFFFF) == 0x1F883)
{
g_pDropForAllPlayersPatch += view_as<Address>(2);
StoreToAddress(g_pDropForAllPlayersPatch, 0xFF, NumberType_Int8);
}
else
{
g_pDropForAllPlayersPatch = Address_Null;
LogError("At address g_pDropForAllPlayersPatch received not what we expected, drop for all players will be unavailable.");
}
}
else
{
LogError("Failed to get address DropForAllPlayersPatch, drop for all players will be unavailable.");
}
delete hGameData;
BuildPath(Path_SM, g_sLogFile, sizeof g_sLogFile, "logs/DropsSummoner.log");
g_hDSWaitTimer = CreateConVar("sm_drops_summoner_wait_timer", "182", "Длительность между попытками призвать дроп в секундах", _, true, 60.0);
g_hDSInfo = CreateConVar("sm_drops_summoner_info", "1", "Уведомлять в чате о попытках призыва дропа", _, true, 0.0, true, 1.0);
g_hDSPlaySound = CreateConVar("sm_drops_summoner_play_sound", "2", "Воспроизводить звук при получении дропа [0 - нет | 1 - только получившему | 2 - всем]", _, true, 0.0, true, 2.0);
}
public void OnPluginEnd()
{
if(g_pDropForAllPlayersPatch != Address_Null)
{
StoreToAddress(g_pDropForAllPlayersPatch, 0x01, NumberType_Int8);
}
}
public void OnMapStart()
{
PrecacheSound("ui/panorama/case_awarded_1_uncommon_01.wav");
CreateTimer(g_hDSWaitTimer.FloatValue, Timer_SendRewardMatchEndDrops, _, TIMER_REPEAT|TIMER_FLAG_NO_MAPCHANGE);
}
MRESReturn Detour_RecordPlayerItemDrop(DHookParam hParams)
{
if(g_hTimerWaitDrops)
{
delete g_hTimerWaitDrops;
}
int iAccountID = hParams.GetObjectVar(1, 16, ObjectValueType_Int);
int iClient = GetClientFromAccountID(iAccountID);
if(iClient != -1)
{
int iDefIndex = hParams.GetObjectVar(1, 20, ObjectValueType_Int);
int iPaintIndex = hParams.GetObjectVar(1, 24, ObjectValueType_Int);
int iRarity = hParams.GetObjectVar(1, 28, ObjectValueType_Int);
int iQuality = hParams.GetObjectVar(1, 32, ObjectValueType_Int);
LogToFile(g_sLogFile, "Игроку %L выпало [%u-%u-%u-%u]", iClient, iDefIndex, iPaintIndex, iRarity, iQuality);
Protobuf hSendPlayerItemFound = view_as<Protobuf>(StartMessageAll("SendPlayerItemFound", USERMSG_RELIABLE));
hSendPlayerItemFound.SetInt("entindex", iClient);
Protobuf hIteminfo = hSendPlayerItemFound.ReadMessage("iteminfo");
hIteminfo.SetInt("defindex", iDefIndex);
hIteminfo.SetInt("paintindex", iPaintIndex);
hIteminfo.SetInt("rarity", iRarity);
hIteminfo.SetInt("quality", iQuality);
hIteminfo.SetInt("inventory", 6); //UNACK_ITEM_GIFTED
EndMessage();
SetHudTextParams(-1.0, 0.4, 3.0, 0, 255, 255, 255);
ShowHudText(iClient, -1, "\x04Вам выпал дроп, смотрите свой инвентарь");
int iPlaySound = g_hDSPlaySound.IntValue;
if(iPlaySound == 2)
{
EmitSoundToAll("ui/panorama/case_awarded_1_uncommon_01.wav", SOUND_FROM_LOCAL_PLAYER, _, SNDLEVEL_NONE);
}
else if(iPlaySound == 1)
{
EmitSoundToClient(iClient, "ui/panorama/case_awarded_1_uncommon_01.wav", SOUND_FROM_LOCAL_PLAYER, _, SNDLEVEL_NONE);
}
}
return MRES_Ignored;
}
int GetClientFromAccountID(int iAccountID)
{
for(int i = 1; i <= MaxClients; i++)
{
if(IsClientConnected(i) && !IsFakeClient(i) && IsClientAuthorized(i))
{
if(GetSteamAccountID(i) == iAccountID)
{
return i;
}
}
}
return -1;
}
Action Timer_SendRewardMatchEndDrops(Handle hTimer)
{
if(g_hDSInfo.BoolValue)
{
g_hTimerWaitDrops = CreateTimer(1.2, Timer_WaitDrops);
PrintToChatAll("{purple}( Ghoul ) \x07Пытаемся призвать дроп");
}
if(g_iOS == 1)
{
SDKCall(g_hRewardMatchEndDrops, 0xDEADC0DE, false);
}
else
{
SDKCall(g_hRewardMatchEndDrops, false);
}
return Plugin_Continue;
}
Action Timer_WaitDrops(Handle hTimer)
{
g_hTimerWaitDrops = null;
PrintToChatAll("{purple}( Ghoul ) \x07Попытка провалилась :(");
}