2019-07-16 16:31:58 +02:00
# 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 ] ;
2020-09-30 15:29:44 +02:00
bool g_bZombiesSpawned ;
2019-07-16 16:31:58 +02:00
/* CONVARS */
ConVar g_hCVar_ZAmmo_Enabled ;
ConVar g_hCVar_ZAmmo_Duration ;
ConVar g_hCVar_ZAmmo_Cost ;
2020-07-03 13:30:33 +02:00
ConVar g_hCVar_ZAmmo_Cooldown ;
2019-07-16 16:31:58 +02:00
ConVar g_hCVar_ZCleanse_Enabled ;
ConVar g_hCVar_ZCleanse_Duration ;
ConVar g_hCVar_ZCleanse_Uses ;
2020-05-19 21:38:39 +02:00
ConVar g_hCVar_ZCleanse_Cooldown ;
2020-08-10 14:08:15 +02:00
ConVar g_hCVar_ZCleanse_Delay ;
2019-07-16 16:31:58 +02:00
/* INTEGERS */
int g_bZCleanse_Uses [ MAXPLAYERS + 1 ] ;
2020-05-19 21:38:39 +02:00
int g_iLastZCleanse_Used [ MAXPLAYERS + 1 ] ;
2020-08-10 14:08:15 +02:00
int g_iLastInfection [ MAXPLAYERS + 1 ] ;
2020-07-03 13:30:33 +02:00
int g_iLastZAmmo_Used [ MAXPLAYERS + 1 ] ;
2019-07-16 16:31:58 +02:00
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
public Plugin myinfo =
{
name = " ZSkills " ,
2020-09-30 15:29:44 +02:00
author = " Neon + Dogan " ,
2019-07-16 16:31:58 +02:00
description = " Skills?! " ,
2020-09-30 15:29:44 +02:00
version = " 1.0.3 "
2019-07-16 16:31:58 +02:00
} ;
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
public void OnPluginStart ( )
{
2020-08-10 14:08:15 +02:00
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 ) ;
2020-07-03 13:30:33 +02:00
g_hCVar_ZAmmo_Cooldown = CreateConVar ( " zr_zammo_cooldown " , " 8 " , " " , FCVAR_NONE , true , 1.0 ) ;
2020-08-10 14:08:15 +02:00
g_bZAmmo_Enabled = g_hCVar_ZAmmo_Enabled . BoolValue ;
2019-07-16 16:31:58 +02:00
g_hCVar_ZAmmo_Enabled . AddChangeHook ( ConVarChanged ) ;
2020-08-10 14:08:15 +02:00
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 " , " 4 " , " " , FCVAR_NONE , true , 1.0 ) ;
g_hCVar_ZCleanse_Uses = CreateConVar ( " zr_zcleanse_uses " , " 2 " , " " , FCVAR_NONE , true , 1.0 ) ;
g_hCVar_ZCleanse_Cooldown = CreateConVar ( " zr_zcleanse_cooldown " , " 8 " , " " , FCVAR_NONE , true , 1.0 ) ;
g_hCVar_ZCleanse_Delay = CreateConVar ( " zr_zcleanse_delay " , " 4 " , " " , FCVAR_NONE , true , 1.0 ) ;
g_bZCleanse_Enabled = g_hCVar_ZCleanse_Enabled . BoolValue ;
2019-07-16 16:31:58 +02:00
g_hCVar_ZCleanse_Enabled . AddChangeHook ( ConVarChanged ) ;
2020-03-15 15:50:10 +01:00
HookEvent ( " weapon_fire " , Event_WeaponFire ) ;
HookEvent ( " round_start " , Event_RoundStart ) ;
2020-09-30 15:29:44 +02:00
HookEvent ( " round_end " , Event_RoundEnd ) ;
2019-07-16 16:31:58 +02:00
RegConsoleCmd ( " sm_zammo " , Command_ZAmmo ) ;
RegConsoleCmd ( " sm_zcleanse " , Command_ZCleanse ) ;
AutoExecConfig ( ) ;
}
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
public void OnMapStart ( )
{
2019-07-29 15:29:17 +02:00
PrecacheSound ( " items/ammopickup.wav " ) ;
2019-07-16 16:31:58 +02:00
PrecacheSound ( " unloze/extinguish.wav " ) ;
AddFileToDownloadsTable ( " sound/unloze/extinguish.wav " ) ;
}
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
public void ConVarChanged ( ConVar convar , const char [ ] oldValue , const char [ ] newValue )
{
2019-07-29 15:50:37 +02:00
g_bZAmmo_Enabled = g_hCVar_ZAmmo_Enabled . BoolValue ;
2019-07-16 16:31:58 +02:00
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 ;
}
2020-09-30 15:29:44 +02:00
if ( ! g_bZombiesSpawned )
{
PrintToChat ( client , " [ZAmmo] Not available before Motherzombies spawn. " ) ;
return Plugin_Handled ;
}
2019-07-16 16:31:58 +02:00
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 ;
}
2020-07-03 13:30:33 +02:00
int iTimeSinceLastZAmmo = GetTime ( ) - g_iLastZAmmo_Used [ client ] ;
int iCooldown = g_hCVar_ZAmmo_Cooldown . IntValue ;
if ( iTimeSinceLastZAmmo < iCooldown )
{
PrintToChat ( client , " [ZCleanse] You need to wait another %d Seconds before you can use ZAmmo again. " , iCooldown - iTimeSinceLastZAmmo ) ;
return Plugin_Handled ;
}
2019-07-16 16:31:58 +02:00
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 ;
2020-07-03 13:30:33 +02:00
g_iLastZAmmo_Used [ client ] = GetTime ( ) ;
2019-07-16 16:31:58 +02:00
PrintToChat ( client , " [ZAmmo] Enabling Infinite Ammo for %d seconds in exchange for %d$. " , iDuration , iCost ) ;
2019-07-29 15:29:17 +02:00
EmitSoundToAll ( " items/ammopickup.wav " , . entity = client , . volume = 0.4 ) ;
2019-07-16 16:31:58 +02:00
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 ;
}
2020-08-10 14:08:15 +02:00
int iTimeSinceLastInfection = GetTime ( ) - g_iLastInfection [ client ] ;
int iCooldown = g_hCVar_ZCleanse_Delay . IntValue ;
if ( iTimeSinceLastInfection < iCooldown )
{
PrintToChat ( client , " [ZCleanse] You need to wait another %d Seconds before you can use ZCleanse right after an infection. " , iCooldown - iTimeSinceLastInfection ) ;
return Plugin_Handled ;
}
2020-05-19 21:38:39 +02:00
int iTimeSinceLastZCleanse = GetTime ( ) - g_iLastZCleanse_Used [ client ] ;
2020-08-10 14:08:15 +02:00
iCooldown = g_hCVar_ZCleanse_Cooldown . IntValue ;
2020-05-19 21:38:39 +02:00
if ( iTimeSinceLastZCleanse < iCooldown )
{
PrintToChat ( client , " [ZCleanse] You need to wait another %d Seconds before you can use ZCleanse again. " , iCooldown - iTimeSinceLastZCleanse ) ;
return Plugin_Handled ;
}
2019-07-16 16:31:58 +02:00
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 ] + + ;
2020-05-19 21:38:39 +02:00
g_iLastZCleanse_Used [ client ] = GetTime ( ) ;
2019-07-16 16:31:58 +02:00
PrintToChat ( client , " [ZCleanse] You are immune against napalm for the next %d seconds. (%d/%d) uses. " , iDuration , g_bZCleanse_Uses [ client ] , iMaxUses ) ;
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 ;
2020-05-19 21:38:39 +02:00
g_iLastZCleanse_Used [ client ] = 0 ;
2020-08-10 14:08:15 +02:00
g_iLastInfection [ client ] = 0 ;
2020-07-03 13:30:33 +02:00
g_iLastZAmmo_Used [ client ] = 0 ;
2019-07-16 16:31:58 +02:00
}
//----------------------------------------------------------------------------------------------------
// 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 ;
2020-05-19 21:38:39 +02:00
g_iLastZCleanse_Used [ client ] = 0 ;
2020-08-10 14:08:15 +02:00
g_iLastInfection [ client ] = 0 ;
2020-07-03 13:30:33 +02:00
g_iLastZAmmo_Used [ client ] = 0 ;
2019-07-16 16:31:58 +02:00
}
}
2020-09-30 15:29:44 +02:00
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
public void Event_RoundEnd ( Handle hEvent , char [ ] name , bool dontBroadcast )
{
g_bZombiesSpawned = false ;
}
2019-07-16 16:31:58 +02:00
//----------------------------------------------------------------------------------------------------
// 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 )
{
2020-09-30 15:29:44 +02:00
if ( ! g_bZombiesSpawned & & motherInfect )
g_bZombiesSpawned = true ;
2020-08-10 14:08:15 +02:00
g_iLastInfection [ client ] = GetTime ( ) ;
2019-07-16 16:31:58 +02:00
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 ) )
2019-07-29 15:29:17 +02:00
{
2019-07-16 16:31:58 +02:00
char sClassName [ 64 ] ;
GetEdictClassname ( iFire , sClassName , sizeof ( sClassName ) ) ;
if ( StrEqual ( sClassName , " entityflame " , false ) )
2019-07-29 15:29:17 +02:00
SetEntPropFloat ( iFire , Prop_Data , " m_flLifetime " , 0.0 ) ;
2019-07-16 16:31:58 +02:00
}
}
//----------------------------------------------------------------------------------------------------
// 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 ;
}