This commit is contained in:
zaCade 2018-11-12 19:03:51 +01:00
commit 83d186bb6f

View File

@ -1,5 +1,6 @@
#include <sourcemod>
#include <BossHP>
#include <zombiereloaded>
#include "loghelper.inc"
@ -9,6 +10,8 @@
ArrayList g_hStats[MAXPLAYERS+1];
bool g_bZRLoaded;
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
@ -25,6 +28,8 @@ public Plugin myinfo =
//----------------------------------------------------------------------------------------------------
public void OnPluginStart()
{
HookEvent("player_death", EventHook_PlayerDeath, EventHookMode_Pre);
for (int client = 1; client <= MaxClients; client++)
{
if (!IsClientInGame(client))
@ -34,6 +39,32 @@ public void OnPluginStart()
}
}
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
public void OnAllPluginsLoaded()
{
g_bZRLoaded = LibraryExists("zombiereloaded");
}
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
public void OnLibraryAdded(const char[] sName)
{
if (strcmp(sName, "zombiereloaded", false) == 0)
g_bZRLoaded = true;
}
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
public void OnLibraryRemoved(const char[] sName)
{
if (strcmp(sName, "zombiereloaded", false) == 0)
g_bZRLoaded = false;
}
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
@ -58,10 +89,12 @@ public void OnBossDamaged(any Boss, any Config, int client)
if (!IsValidClient(client))
return;
int iCurrentCash = GetEntProp(client, Prop_Send, "m_iAccount");
//int iCurrentCash = GetEntProp(client, Prop_Send, "m_iAccount");
if (iCurrentCash < 16000)
SetEntProp(client, Prop_Send, "m_iAccount", iCurrentCash + 1);
//if (iCurrentCash < 16000)
// SetEntProp(client, Prop_Send, "m_iAccount", iCurrentCash + 1);
SetEntProp(client, Prop_Send, "m_iAccount", GetEntProp(client, Prop_Send, "m_iAccount") + 1);
for (int index = 0; index < g_hStats[client].Length; index++)
{
@ -228,6 +261,37 @@ public void OnBossKilled(any Boss, any Config, int reason)
}
}
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
public Action EventHook_PlayerDeath(Event hEvent, const char[] sEventName, bool bDontBroadcast)
{
if (!g_bZRLoaded)
return Plugin_Continue;
int iAttacker = GetClientOfUserId(hEvent.GetInt("attacker"));
if (!IsValidClient(iAttacker) || !ZR_IsClientHuman(iAttacker))
return Plugin_Continue;
int iPacked = (iAttacker<<16) | (GetEntProp(iAttacker, Prop_Send, "m_iAccount")&0xFFFF);
RequestFrame(RequestFrame_Callback, iPacked);
return Plugin_Continue;
}
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
void RequestFrame_Callback(int iPacked)
{
int iOldCash = iPacked&0xFFFF;
int iAttacker = iPacked>>16;
SetEntProp(iAttacker, Prop_Send, "m_iAccount", iOldCash);
}
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------