kill me
This commit is contained in:
parent
cdce32ac42
commit
e1ad359361
324
UNLOZE_KnifeMadness/scripting/UNLOZE_KnifeMadness.sp
Normal file
324
UNLOZE_KnifeMadness/scripting/UNLOZE_KnifeMadness.sp
Normal file
@ -0,0 +1,324 @@
|
||||
#include <sourcemod>
|
||||
#include <sdktools>
|
||||
#include <multicolors>
|
||||
#include <zombiereloaded>
|
||||
|
||||
#pragma semicolon 1
|
||||
#pragma newdecls required
|
||||
|
||||
/* CONVARS */
|
||||
ConVar g_hCVar_Delay;
|
||||
|
||||
Handle g_hTriggerTimer = INVALID_HANDLE;
|
||||
Handle g_hTriggerResetTimer = INVALID_HANDLE;
|
||||
|
||||
/* BOOLS */
|
||||
bool g_bZMwasKnifed[MAXPLAYERS+1];
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
public Plugin myinfo =
|
||||
{
|
||||
name = "UNLOZE Knife Madness",
|
||||
author = "Neon",
|
||||
description = "UNLOZE Knife Madness",
|
||||
version = "1.0",
|
||||
url = "https://steamcommunity.com/id/n3ontm"
|
||||
};
|
||||
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
public void OnPluginStart()
|
||||
{
|
||||
g_hCVar_Delay = CreateConVar("sm_knife_madness_kill_delay", "3", "Delay before ZMs die after being knifed by a human.", 0, true, 0.0);
|
||||
|
||||
HookEvent("player_spawn", OnClientSpawn);
|
||||
HookEvent("player_hurt", OnClientHurt);
|
||||
HookEvent("round_start", OnRoundStart);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
public void OnClientSpawn(Event hEvent, const char[] sEvent, bool bDontBroadcast)
|
||||
{
|
||||
int client = GetClientOfUserId(hEvent.GetInt("userid"));
|
||||
g_bZMwasKnifed[client] = false;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
public void OnClientHurt(Event hEvent, const char[] sEvent, bool bDontBroadcast)
|
||||
{
|
||||
int attacker = GetClientOfUserId(hEvent.GetInt("attacker"));
|
||||
int victim = GetClientOfUserId(hEvent.GetInt("userid"));
|
||||
|
||||
if (!IsValidClient(attacker, false))
|
||||
return;
|
||||
|
||||
if (!(IsPlayerAlive(attacker) && IsPlayerAlive(victim) && ZR_IsClientHuman(attacker) && ZR_IsClientZombie(victim)))
|
||||
return;
|
||||
|
||||
char sWeapon[32];
|
||||
GetEventString(hEvent, "weapon", sWeapon, sizeof(sWeapon));
|
||||
|
||||
if(!StrEqual(sWeapon, "knife", false))
|
||||
return;
|
||||
|
||||
g_bZMwasKnifed[victim] = true;
|
||||
CPrintToChat(attacker, "{unique}[Knife Madness] {white}You have knifed {lime}%N{white}. He will die in %ds if he doesnt infect a human.", victim, g_hCVar_Delay.IntValue);
|
||||
CPrintToChat(victim, "{unique}[Knife Madness] {white}You have been knifed by {lime}%N{white}. You will die in %ds if you do not infect a human.", attacker, g_hCVar_Delay.IntValue);
|
||||
|
||||
SetEntPropFloat(victim, Prop_Send, "m_flProgressBarStartTime", GetGameTime());
|
||||
SetEntProp(victim, Prop_Send, "m_iProgressBarDuration", g_hCVar_Delay.IntValue);
|
||||
|
||||
DataPack pack;
|
||||
CreateDataTimer(g_hCVar_Delay.FloatValue, KillZM, pack, TIMER_FLAG_NO_MAPCHANGE);
|
||||
pack.WriteCell(GetClientUserId(attacker));
|
||||
pack.WriteCell(GetClientUserId(victim));
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
public void OnRoundStart(Event hEvent, const char[] sEvent, bool bDontBroadcast)
|
||||
{
|
||||
ResetTriggers();
|
||||
|
||||
if (g_hTriggerTimer != INVALID_HANDLE)
|
||||
{
|
||||
PrintToChatAll("trigger active, needs kill");
|
||||
KillTimer(g_hTriggerTimer);
|
||||
g_hTriggerTimer = INVALID_HANDLE;
|
||||
}
|
||||
|
||||
if (g_hTriggerResetTimer != INVALID_HANDLE)
|
||||
{
|
||||
PrintToChatAll("reset active, needs kill");
|
||||
KillTimer(g_hTriggerResetTimer);
|
||||
g_hTriggerResetTimer = INVALID_HANDLE;
|
||||
}
|
||||
|
||||
float fRandomInterval = GetRandomFloat(12.0, 50.0);
|
||||
g_hTriggerTimer = CreateTimer(fRandomInterval, SpecialTrigger, INVALID_HANDLE, TIMER_FLAG_NO_MAPCHANGE);
|
||||
g_hTriggerResetTimer = CreateTimer(fRandomInterval + 10.0, ResetTriggerTimer, INVALID_HANDLE, TIMER_FLAG_NO_MAPCHANGE);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
public Action SpecialTrigger(Handle timer)
|
||||
{
|
||||
int iRandom = GetRandomInt(0, 8);
|
||||
if (iRandom == 0)
|
||||
{
|
||||
ServerCommand("sv_gravity 300");
|
||||
CPrintToChatAll("{unique}[Knife Madness] {white}Low gravity activated!");
|
||||
}
|
||||
else if (iRandom == 1)
|
||||
{
|
||||
for (int client = 1; client <= MaxClients; client++)
|
||||
{
|
||||
if (IsValidClient(client, false) && IsPlayerAlive(client))
|
||||
SetEntPropFloat(client, Prop_Data, "m_flLaggedMovementValue", 3.0);
|
||||
}
|
||||
CPrintToChatAll("{unique}[Knife Madness] {white}Speed activated!");
|
||||
}
|
||||
if (iRandom == 2)
|
||||
{
|
||||
ServerCommand("sm plugins load disabled/autobhop");
|
||||
CPrintToChatAll("{unique}[Knife Madness] {white}Auto-Bhop activated!");
|
||||
}
|
||||
if (iRandom == 3)
|
||||
{
|
||||
for (int client = 1; client <= MaxClients; client++)
|
||||
{
|
||||
if (IsValidClient(client, false) && IsPlayerAlive(client))
|
||||
SetEntPropFloat(client, Prop_Data, "m_flLaggedMovementValue", GetRandomFloat(0.2, 5.0));
|
||||
}
|
||||
CPrintToChatAll("{unique}[Knife Madness] {white}Random speed for everyone!");
|
||||
}
|
||||
if (iRandom == 4)
|
||||
{
|
||||
ServerCommand("sv_friction 0.1");
|
||||
CPrintToChatAll("{unique}[Knife Madness] {white}Slippery ground!");
|
||||
}
|
||||
if (iRandom == 5)
|
||||
{
|
||||
ServerCommand("sv_accelerate -5");
|
||||
ServerCommand("sv_airaccelerate -1");
|
||||
CPrintToChatAll("{unique}[Knife Madness] {white}Inverted controls!");
|
||||
}
|
||||
if (iRandom == 6)
|
||||
{
|
||||
CPrintToChatAll("{unique}[Knife Madness] {white}Seems like we chillin...");
|
||||
}
|
||||
if (iRandom == 7)
|
||||
{
|
||||
for (int client = 1; client <= MaxClients; client++)
|
||||
{
|
||||
if (!(IsValidClient(client, false) && IsPlayerAlive(client)))
|
||||
continue;
|
||||
|
||||
for(int j = 0; j < 5; j++)
|
||||
{
|
||||
int w = -1;
|
||||
|
||||
while ((w = GetPlayerWeaponSlot(client, j)) != -1)
|
||||
{
|
||||
if(IsValidEntity(w) && IsValidEdict(w))
|
||||
{
|
||||
RemovePlayerItem(client, w);
|
||||
AcceptEntityInput(w, "Kill");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
CPrintToChatAll("{unique}[Knife Madness] {white}Time for a break...");
|
||||
}
|
||||
if (iRandom == 8)
|
||||
{
|
||||
iRandom = GetRandomInt(0, 1);
|
||||
|
||||
if (iRandom == 0)
|
||||
CPrintToChatAll("{unique}[Knife Madness] {white}Zombies lost their knives...");
|
||||
else if (iRandom == 1)
|
||||
CPrintToChatAll("{unique}[Knife Madness] {white}Humans lost their knives...");
|
||||
|
||||
for (int client = 1; client <= MaxClients; client++)
|
||||
{
|
||||
if (!(IsValidClient(client, false) && IsPlayerAlive(client)))
|
||||
continue;
|
||||
|
||||
if (iRandom == 0)
|
||||
{
|
||||
if (ZR_IsClientHuman(client))
|
||||
continue;
|
||||
}
|
||||
else if (iRandom == 1)
|
||||
{
|
||||
if (ZR_IsClientZombie(client))
|
||||
continue;
|
||||
}
|
||||
|
||||
for(int j = 0; j < 5; j++)
|
||||
{
|
||||
int w = -1;
|
||||
|
||||
while ((w = GetPlayerWeaponSlot(client, j)) != -1)
|
||||
{
|
||||
if(IsValidEntity(w) && IsValidEdict(w))
|
||||
{
|
||||
RemovePlayerItem(client, w);
|
||||
AcceptEntityInput(w, "Kill");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
EmitGameSoundToAll("Bot.Stuck1");
|
||||
g_hTriggerTimer = INVALID_HANDLE;
|
||||
|
||||
float fRandomInterval = GetRandomFloat(11.0, 60.0);
|
||||
g_hTriggerTimer = CreateTimer(fRandomInterval, SpecialTrigger);
|
||||
g_hTriggerResetTimer = CreateTimer(fRandomInterval + 10.0, ResetTriggerTimer);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
public Action ResetTriggerTimer(Handle timer)
|
||||
{
|
||||
g_hTriggerResetTimer = INVALID_HANDLE;
|
||||
ResetTriggers();
|
||||
EmitGameSoundToAll("Bot.Stuck2");
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
public void ResetTriggers()
|
||||
{
|
||||
ServerCommand("sv_gravity 800");
|
||||
for (int client = 1; client <= MaxClients; client++)
|
||||
{
|
||||
if (IsValidClient(client, false) && IsPlayerAlive(client))
|
||||
{
|
||||
SetEntPropFloat(client, Prop_Data, "m_flLaggedMovementValue", 1.0);
|
||||
|
||||
int w = -1;
|
||||
w = GetPlayerWeaponSlot(client, 2);
|
||||
if(!(IsValidEntity(w) && IsValidEdict(w)))
|
||||
GivePlayerItem(client, "weapon_knife");
|
||||
}
|
||||
}
|
||||
ServerCommand("sm plugins unload disabled/autobhop");
|
||||
ServerCommand("sv_friction 4");
|
||||
ServerCommand("sv_accelerate 5");
|
||||
ServerCommand("sv_airaccelerate 10");
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
public void ZR_OnClientInfected(int client, int attacker, bool motherInfect, bool respawnOverride, bool respawn)
|
||||
{
|
||||
if (!IsValidClient(attacker))
|
||||
return;
|
||||
|
||||
if(g_bZMwasKnifed[attacker])
|
||||
{
|
||||
g_bZMwasKnifed[attacker] = false;
|
||||
SetEntProp(attacker, Prop_Send, "m_iProgressBarDuration", 0);
|
||||
CPrintToChat(attacker, "{unique}[Knife Madness] {white}You have successfully infected a human and prevented your death.");
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
public Action KillZM(Handle timer, DataPack pack)
|
||||
{
|
||||
int attacker = 0;
|
||||
int client = 0;
|
||||
|
||||
pack.Reset();
|
||||
attacker = GetClientOfUserId(pack.ReadCell());
|
||||
client = GetClientOfUserId(pack.ReadCell());
|
||||
|
||||
if (client == 0)
|
||||
return;
|
||||
|
||||
if (!(IsValidClient(client, false) && IsPlayerAlive(client) && ZR_IsClientZombie(client) && g_bZMwasKnifed[client]))
|
||||
return;
|
||||
|
||||
ForcePlayerSuicide(client);
|
||||
|
||||
if (!(IsValidClient(attacker, false)))
|
||||
return;
|
||||
|
||||
Event hEvent = CreateEvent("player_death");
|
||||
if (hEvent == null)
|
||||
return;
|
||||
|
||||
hEvent.SetInt("userid", GetClientUserId(client));
|
||||
hEvent.SetInt("attacker", GetClientUserId(attacker));
|
||||
hEvent.SetString("weapon", "knife");
|
||||
hEvent.SetBool("headshot", false);
|
||||
hEvent.SetInt("dominated", 0);
|
||||
hEvent.SetInt("revenge", 0);
|
||||
hEvent.Fire();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
stock int IsValidClient(int client, bool nobots = true)
|
||||
{
|
||||
if (client <= 0 || client > MaxClients || !IsClientConnected(client) || (nobots && IsFakeClient(client)))
|
||||
return false;
|
||||
|
||||
return IsClientInGame(client);
|
||||
}
|
Loading…
Reference in New Issue
Block a user