This commit is contained in:
neon 2019-07-16 16:31:58 +02:00
parent c3d63b0245
commit 6982207601
3 changed files with 359 additions and 203 deletions

View File

@ -1,203 +0,0 @@
#include <zombiereloaded>
#include <sourcemod>
#include <sdktools>
/* BOOLS */
bool g_bEnabled;
bool g_bActive[MAXPLAYERS+1];
/* CONVARS */
ConVar g_hCVar_Enabled;
ConVar g_hCVar_Duration;
ConVar g_hCVar_Cost ;
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
public Plugin myinfo =
{
name = "ZAmmo",
author = "Neon",
description = "Unlimited ammo for a short period of time",
version = "1.0.0"
};
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
public void OnPluginStart()
{
g_hCVar_Enabled = CreateConVar("zr_zammo_enabled", "1", "", FCVAR_NONE, true, 0.0, true, 1.0);
g_hCVar_Duration = CreateConVar("zr_zammo_duration", "5", "", FCVAR_NONE, true, 1.0);
g_hCVar_Cost = CreateConVar("zr_zammo_cost", "5000", "", FCVAR_NONE, true, 1.0);
g_bEnabled = g_hCVar_Enabled.BoolValue;
if (g_bEnabled)
HookEvent("weapon_fire", Event_WeaponFire);
g_hCVar_Enabled.AddChangeHook(ConVarChanged);
HookEvent("round_start", Event_RoundStart);
RegConsoleCmd("sm_zammo", Command_ZAmmo);
AutoExecConfig();
}
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
public void ConVarChanged(ConVar convar, const char[] oldValue, const char[] newValue)
{
g_bEnabled = convar.BoolValue;
if (g_bEnabled)
HookEvent("weapon_fire", Event_WeaponFire);
else
UnhookEvent("weapon_fire", Event_WeaponFire);
}
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
public Action Command_ZAmmo(int client, int args)
{
if (!g_bEnabled)
{
ReplyToCommand(client, "[ZAmmo] is currently disabled.");
return Plugin_Handled;
}
if (client == 0)
{
ReplyToCommand(client, "[ZAmmo] Can't use this from console.");
return Plugin_Handled;
}
if (!IsPlayerAlive(client))
{
ReplyToCommand(client, "[ZAmmo] This feature requires you to be alive.");
return Plugin_Handled;
}
if (!ZR_IsClientHuman(client))
{
ReplyToCommand(client, "[ZAmmo] This feature requires you to be Human.");
return Plugin_Handled;
}
if(g_bActive[client])
{
ReplyToCommand(client, "[ZAmmo] is already active for you.");
return Plugin_Handled;
}
int iCost = g_hCVar_Cost.IntValue;
if (GetEntProp(client, Prop_Send, "m_iAccount") < iCost)
{
ReplyToCommand(client, "[ZAmmo] Insufficent funds (%d).", iCost);
return Plugin_Handled;
}
int iDuration = g_hCVar_Duration.IntValue;
SetEntProp(client, Prop_Send, "m_iAccount", GetEntProp(client, Prop_Send, "m_iAccount") - iCost);
SetEntPropFloat(client, Prop_Send, "m_flProgressBarStartTime", GetGameTime());
SetEntProp(client, Prop_Send, "m_iProgressBarDuration", iDuration);
CreateTimer(float(iDuration), Timer_Disable, GetClientSerial(client), TIMER_FLAG_NO_MAPCHANGE);
g_bActive[client] = true;
ReplyToCommand(client, "[ZAmmo] Enabling Infinite Ammo for %d seconds in exchange for %d$.", iDuration, iCost);
return Plugin_Handled;
}
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
public void OnClientDisconnect(int client)
{
g_bActive[client] = false;
}
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
public void Event_RoundStart(Handle hEvent, char[] name, bool dontBroadcast)
{
for (int client = 1; client <= MaxClients; client++)
{
g_bActive[client] = false;
}
}
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
public void Event_WeaponFire(Handle hEvent, char[] name, bool dontBroadcast)
{
int client = GetClientOfUserId(GetEventInt(hEvent, "userid"));
if(!g_bActive[client])
return;
int weapon = GetEntPropEnt(client, Prop_Data, "m_hActiveWeapon", 0);
if(IsValidEntity(weapon))
{
if(weapon == GetPlayerWeaponSlot(client, 0) || weapon == GetPlayerWeaponSlot(client, 1))
{
if(GetEntProp(weapon, Prop_Send, "m_iState", 4, 0) == 2 && GetEntProp(weapon, Prop_Send, "m_iClip1", 4, 0))
{
int toAdd = 1;
char weaponClassname[128];
GetEntityClassname(weapon, weaponClassname, sizeof(weaponClassname));
if(StrEqual(weaponClassname, "weapon_glock", true) || StrEqual(weaponClassname, "weapon_famas", true))
{
if(GetEntProp(weapon, Prop_Send, "m_bBurstMode"))
{
switch (GetEntProp(weapon, Prop_Send, "m_iClip1"))
{
case 1:
{
toAdd = 1;
}
case 2:
{
toAdd = 2;
}
default:
{
toAdd = 3;
}
}
}
}
SetEntProp(weapon, Prop_Send, "m_iClip1", GetEntProp(weapon, Prop_Send, "m_iClip1", 4, 0) + toAdd, 4, 0);
}
}
}
return;
}
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
public void ZR_OnClientInfected(int client, int attacker, bool motherInfect, bool respawnOverride, bool respawn)
{
if (!g_bActive[client])
return;
SetEntPropFloat(client, Prop_Send, "m_flProgressBarStartTime", GetGameTime()-1);
SetEntProp(client, Prop_Send, "m_iProgressBarDuration", 0);
g_bActive[client] = false;
}
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
public Action Timer_Disable(Handle timer, int iSerial)
{
g_bActive[client] = false;
int client;
if ((client = GetClientFromSerial(iSerial)) == 0)
return;
SetEntPropFloat(client, Prop_Send, "m_flProgressBarStartTime", GetGameTime()-1);
SetEntProp(client, Prop_Send, "m_iProgressBarDuration", 0);
}

Binary file not shown.

View File

@ -0,0 +1,359 @@
#include <zombiereloaded>
#include <sourcemod>
#include <sdktools>
/* BOOLS */
bool g_bZAmmo_Enabled;
bool g_bZAmmo_Active[MAXPLAYERS+1];
bool g_bZCleanse_Enabled;
bool g_bZCleanse_Active[MAXPLAYERS+1];
bool g_bLastButtonReload[MAXPLAYERS+1];
/* CONVARS */
ConVar g_hCVar_ZAmmo_Enabled;
ConVar g_hCVar_ZAmmo_Duration;
ConVar g_hCVar_ZAmmo_Cost;
ConVar g_hCVar_ZCleanse_Enabled;
ConVar g_hCVar_ZCleanse_Duration;
ConVar g_hCVar_ZCleanse_Uses;
/* INTEGERS */
int g_bZCleanse_Uses[MAXPLAYERS+1];
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
public Plugin myinfo =
{
name = "ZSkills",
author = "Neon",
description = "Skills?!",
version = "1.0.0"
};
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
public void OnPluginStart()
{
g_hCVar_ZAmmo_Enabled = CreateConVar("zr_zammo_enabled", "1", "", FCVAR_NONE, true, 0.0, true, 1.0);
g_hCVar_ZAmmo_Duration = CreateConVar("zr_zammo_duration", "6", "", FCVAR_NONE, true, 1.0);
g_hCVar_ZAmmo_Cost = CreateConVar("zr_zammo_cost", "4500", "", FCVAR_NONE, true, 1.0);
g_bZAmmo_Enabled = g_hCVar_ZAmmo_Enabled.BoolValue;
if (g_bZAmmo_Enabled)
HookEvent("weapon_fire", Event_WeaponFire);
g_hCVar_ZAmmo_Enabled.AddChangeHook(ConVarChanged);
g_hCVar_ZCleanse_Enabled = CreateConVar("zr_zcleanse_enabled", "1", "", FCVAR_NONE, true, 0.0, true, 1.0);
g_hCVar_ZCleanse_Duration = CreateConVar("zr_zcleanse_duration", "5", "", FCVAR_NONE, true, 1.0);
g_hCVar_ZCleanse_Uses = CreateConVar("zr_zcleanse_uses", "5", "", FCVAR_NONE, true, 1.0);
g_bZCleanse_Enabled = g_hCVar_ZCleanse_Enabled.BoolValue;
g_hCVar_ZCleanse_Enabled.AddChangeHook(ConVarChanged);
RegConsoleCmd("sm_zammo", Command_ZAmmo);
RegConsoleCmd("sm_zcleanse", Command_ZCleanse);
HookEvent("round_start", Event_RoundStart);
AutoExecConfig();
}
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
public void OnMapStart()
{
PrecacheSound("unloze/extinguish.wav");
AddFileToDownloadsTable("sound/unloze/extinguish.wav");
}
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
public void ConVarChanged(ConVar convar, const char[] oldValue, const char[] newValue)
{
g_bZAmmo_Enabled = convar.BoolValue;
if (g_bZAmmo_Enabled)
HookEvent("weapon_fire", Event_WeaponFire);
else
UnhookEvent("weapon_fire", Event_WeaponFire);
g_bZCleanse_Enabled = g_hCVar_ZCleanse_Enabled.BoolValue;
}
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
public Action Command_ZAmmo(int client, int args)
{
if (client == 0)
{
ReplyToCommand(client, "[ZAmmo] Can't use this from console.");
return Plugin_Handled;
}
if (!g_bZAmmo_Enabled)
{
PrintToChat(client, "[ZAmmo] is currently disabled.");
return Plugin_Handled;
}
if (!IsPlayerAlive(client))
{
PrintToChat(client, "[ZAmmo] This feature requires you to be alive.");
return Plugin_Handled;
}
if (!ZR_IsClientHuman(client))
{
PrintToChat(client, "[ZAmmo] This feature requires you to be Human.");
return Plugin_Handled;
}
if(g_bZAmmo_Active[client])
{
PrintToChat(client, "[ZAmmo] is already active on you.");
return Plugin_Handled;
}
int iCost = g_hCVar_ZAmmo_Cost.IntValue;
if (GetEntProp(client, Prop_Send, "m_iAccount") < iCost)
{
PrintToChat(client, "[ZAmmo] Insufficent funds (%d).", iCost);
return Plugin_Handled;
}
int iDuration = g_hCVar_ZAmmo_Duration.IntValue;
SetEntProp(client, Prop_Send, "m_iAccount", GetEntProp(client, Prop_Send, "m_iAccount") - iCost);
SetEntPropFloat(client, Prop_Send, "m_flProgressBarStartTime", GetGameTime());
SetEntProp(client, Prop_Send, "m_iProgressBarDuration", iDuration);
CreateTimer(float(iDuration), Timer_Disable_ZAmmo, GetClientSerial(client), TIMER_FLAG_NO_MAPCHANGE);
g_bZAmmo_Active[client] = true;
PrintToChat(client, "[ZAmmo] Enabling Infinite Ammo for %d seconds in exchange for %d$.", iDuration, iCost);
return Plugin_Handled;
}
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
public Action Command_ZCleanse(int client, int args)
{
if (client == 0)
{
ReplyToCommand(client, "[ZCleanse] Can't use this from console.");
return Plugin_Handled;
}
if (!g_bZCleanse_Enabled)
{
PrintToChat(client, "[ZCleanse] is currently disabled.");
return Plugin_Handled;
}
if (!IsPlayerAlive(client))
{
PrintToChat(client, "[ZCleanse] This feature requires you to be alive.");
return Plugin_Handled;
}
if (!ZR_IsClientZombie(client))
{
PrintToChat(client, "[ZCleanse] This feature requires you to be Zombie.");
return Plugin_Handled;
}
if(g_bZCleanse_Active[client])
{
PrintToChat(client, "[ZCleanse] is already active on you.");
return Plugin_Handled;
}
int iMaxUses = g_hCVar_ZCleanse_Uses.IntValue;
if (g_bZCleanse_Uses[client] >= iMaxUses)
{
PrintToChat(client, "[ZCleanse] Already used (%d/%d) times this round.", g_bZCleanse_Uses[client], iMaxUses);
return Plugin_Handled;
}
int iDuration = g_hCVar_ZCleanse_Duration.IntValue;
SetEntPropFloat(client, Prop_Send, "m_flProgressBarStartTime", GetGameTime());
SetEntProp(client, Prop_Send, "m_iProgressBarDuration", iDuration);
NapalmExtinguishEntity(client);
CreateTimer(float(iDuration), Timer_Disable_ZCleanse, GetClientSerial(client), TIMER_FLAG_NO_MAPCHANGE);
g_bZCleanse_Active[client] = true;
g_bZCleanse_Uses[client]++;
PrintToChat(client, "[ZCleanse] You are immune against napalm for the next %d seconds. (%d/%d) uses.", iDuration, g_bZCleanse_Uses[client], iMaxUses);
//EmitSoundToClient(client, "unloze/extinguish.wav", .volume=1.0);
EmitSoundToAll("unloze/extinguish.wav", .entity=client, .volume=0.4);
return Plugin_Handled;
}
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
public void OnClientDisconnect(int client)
{
g_bZAmmo_Active[client] = false;
g_bZCleanse_Active[client] = false;
g_bZCleanse_Uses[client] = 0;
}
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
public void Event_RoundStart(Handle hEvent, char[] name, bool dontBroadcast)
{
for (int client = 1; client <= MaxClients; client++)
{
g_bZAmmo_Active[client] = false;
g_bZCleanse_Active[client] = false;
g_bZCleanse_Uses[client] = 0;
}
}
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
public void Event_WeaponFire(Handle hEvent, char[] name, bool dontBroadcast)
{
int client = GetClientOfUserId(GetEventInt(hEvent, "userid"));
if(!g_bZAmmo_Active[client])
return;
int weapon = GetEntPropEnt(client, Prop_Data, "m_hActiveWeapon", 0);
if(IsValidEntity(weapon))
{
if(weapon == GetPlayerWeaponSlot(client, 0) || weapon == GetPlayerWeaponSlot(client, 1))
{
if(GetEntProp(weapon, Prop_Send, "m_iState", 4, 0) == 2 && GetEntProp(weapon, Prop_Send, "m_iClip1", 4, 0))
{
int toAdd = 1;
char weaponClassname[128];
GetEntityClassname(weapon, weaponClassname, sizeof(weaponClassname));
if(StrEqual(weaponClassname, "weapon_glock", true) || StrEqual(weaponClassname, "weapon_famas", true))
{
if(GetEntProp(weapon, Prop_Send, "m_bBurstMode"))
{
switch (GetEntProp(weapon, Prop_Send, "m_iClip1"))
{
case 1:
{
toAdd = 1;
}
case 2:
{
toAdd = 2;
}
default:
{
toAdd = 3;
}
}
}
}
SetEntProp(weapon, Prop_Send, "m_iClip1", GetEntProp(weapon, Prop_Send, "m_iClip1", 4, 0) + toAdd, 4, 0);
}
}
}
return;
}
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
public void ZR_OnClientInfected(int client, int attacker, bool motherInfect, bool respawnOverride, bool respawn)
{
if (!g_bZAmmo_Active[client])
return;
SetEntPropFloat(client, Prop_Send, "m_flProgressBarStartTime", GetGameTime()-1);
SetEntProp(client, Prop_Send, "m_iProgressBarDuration", 0);
g_bZAmmo_Active[client] = false;
}
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
public void NapalmExtinguishEntity(int client)
{
int iFire = GetEntPropEnt(client, Prop_Data, "m_hEffectEntity");
if (IsValidEntity(iFire))
{
char sClassName[64];
GetEdictClassname(iFire, sClassName, sizeof(sClassName));
if (StrEqual(sClassName, "entityflame", false))
SetEntPropFloat(iFire, Prop_Data, "m_flLifetime", 0.0);
}
}
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
public Action ZR_OnClientIgnite(int &client, float &duration)
{
if(g_bZCleanse_Active[client])
return Plugin_Handled;
return Plugin_Continue;
}
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
public Action Timer_Disable_ZAmmo(Handle timer, int iSerial)
{
int client;
if ((client = GetClientFromSerial(iSerial)) == 0)
return;
SetEntPropFloat(client, Prop_Send, "m_flProgressBarStartTime", GetGameTime()-1);
SetEntProp(client, Prop_Send, "m_iProgressBarDuration", 0);
g_bZAmmo_Active[client] = false;
}
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
public Action Timer_Disable_ZCleanse(Handle timer, int iSerial)
{
int client;
if ((client = GetClientFromSerial(iSerial)) == 0)
return;
SetEntPropFloat(client, Prop_Send, "m_flProgressBarStartTime", GetGameTime()-1);
SetEntProp(client, Prop_Send, "m_iProgressBarDuration", 0);
g_bZCleanse_Active[client] = false;
}
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
public Action OnPlayerRunCmd(int client, int &buttons)
{
if(!IsPlayerAlive(client))
return Plugin_Continue;
if(!ZR_IsClientZombie(client))
return Plugin_Continue;
if (g_bZCleanse_Active[client])
return Plugin_Continue;
bool bPressingReload = view_as<bool>(buttons & IN_RELOAD);
if (!bPressingReload)
{
g_bLastButtonReload[client] = false;
return Plugin_Continue;
}
if (!g_bLastButtonReload[client])
{
g_bLastButtonReload[client] = true;
Command_ZCleanse(client, 0);
}
return Plugin_Continue;
}