remade for CSS zr. csgo is no more anyways. dont need the gamedata over here

This commit is contained in:
jenz 2024-01-28 00:49:36 +01:00
parent e8dcfb5048
commit de83c59171
2 changed files with 267 additions and 266 deletions
ZombieRiot

View File

@ -1,14 +0,0 @@
"Games"
{
"csgo"
{
"Offsets"
{
"GetPlayerMaxSpeed"
{
"windows" "498"
"linux" "499"
}
}
}
}

View File

@ -12,6 +12,7 @@
#include <dhooks> #include <dhooks>
#include <clientprefs> #include <clientprefs>
#include <smlib> #include <smlib>
#pragma newdecls required #pragma newdecls required
//#pragma dynamic 131072 //#pragma dynamic 131072
static char g_cPathsClassHuman[PLATFORM_MAX_PATH]; static char g_cPathsClassHuman[PLATFORM_MAX_PATH];
@ -38,6 +39,7 @@ char g_cZMSounds[g_dIndexes][g_dLength];
char g_cWeaponEntity[g_dIndexes][g_dLength]; char g_cWeaponEntity[g_dIndexes][g_dLength];
char g_cWeaponNames[g_dIndexes][g_dLength]; char g_cWeaponNames[g_dIndexes][g_dLength];
char g_cWeaponCommand[g_dIndexes][g_dLength]; char g_cWeaponCommand[g_dIndexes][g_dLength];
int g_iLength = g_dLength - 1; int g_iLength = g_dLength - 1;
int g_iWave; int g_iWave;
int g_iZMScaleability; int g_iZMScaleability;
@ -56,6 +58,7 @@ int g_iZMBeginindex;
int g_iSoundIndexes; int g_iSoundIndexes;
int g_iWeaponIndex; int g_iWeaponIndex;
int g_iBotStuckCounts; int g_iBotStuckCounts;
float g_fKnockBackIndex[g_dIndexes]; float g_fKnockBackIndex[g_dIndexes];
float g_fJumpHeightIndex[g_dIndexes]; float g_fJumpHeightIndex[g_dIndexes];
float g_fJumpDistanceIndex[g_dIndexes]; float g_fJumpDistanceIndex[g_dIndexes];
@ -66,15 +69,17 @@ float g_fZMHealthScaleability;
float g_fRespawnTimer; float g_fRespawnTimer;
float g_fZMSounds; float g_fZMSounds;
float g_fBotStuckPush; float g_fBotStuckPush;
bool g_bSwitchingIndex; bool g_bSwitchingIndex;
bool g_bRoundInProgress; bool g_bRoundInProgress;
bool g_bShouldBeHuman[g_dIndexes]; bool g_bShouldBeHuman[g_dIndexes];
bool g_bShouldBeZM[g_dIndexes]; bool g_bShouldBeZM[g_dIndexes];
bool g_bFallDamage[g_dIndexes]; bool g_bFallDamage[g_dIndexes];
bool g_bClientProtection[g_dIndexes]; bool g_bClientProtection[g_dIndexes];
Handle g_hGetPlayerMaxSpeed = INVALID_HANDLE;
Handle g_hClientZMCookie; Handle g_hClientZMCookie;
Handle g_hClientHumanCookie; Handle g_hClientHumanCookie;
//---------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------
// Purpose: // Purpose:
//---------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------
@ -82,108 +87,109 @@ public Plugin myinfo =
{ {
name = "Unloze Zombie Riot", name = "Unloze Zombie Riot",
author = PLUGIN_AUTHOR, author = PLUGIN_AUTHOR,
description = "Zombie Riot mod for CSGO", description = "Zombie Riot mod. originally for csgo but remade for css",
version = PLUGIN_VERSION, version = PLUGIN_VERSION,
url = "www.unloze.com" url = "www.unloze.com"
}; };
public void OnPluginStart() public void OnPluginStart()
{ {
//gamedata //processstring
if (LibraryExists("dhooks")) LoadTranslations("common.phrases.txt");
{
Handle hGameData = LoadGameConfigFile("zombieriot"); //cookies
if (hGameData != null) if (g_hClientZMCookie == null)
{ g_hClientZMCookie = RegClientCookie("unloze_zr_classprefZM", "Cookie for ZM classes", CookieAccess_Protected);
int iOffset = GameConfGetOffset(hGameData, "GetPlayerMaxSpeed");
if (iOffset != -1) if (g_hClientHumanCookie == null)
g_hGetPlayerMaxSpeed = DHookCreate(iOffset, HookType_Entity, ReturnType_Float, ThisPointer_CBaseEntity, DHook_GetPlayerMaxSpeed); g_hClientHumanCookie = RegClientCookie("unloze_zr_classprefHuman", "Cookie for Human classes", CookieAccess_Protected);
delete hGameData;
} BuildPath(Path_SM, g_cPathsClassZM, sizeof(g_cPathsClassZM), "configs/unloze_zr/classeszm.txt");
} BuildPath(Path_SM, g_cPathsClassHuman, sizeof(g_cPathsClassHuman), "configs/unloze_zr/classeshuman.txt");
//processstring BuildPath(Path_SM, g_cPathsExtra, sizeof(g_cPathsExtra), "configs/unloze_zr/extra.txt");
LoadTranslations("common.phrases.txt"); BuildPath(Path_SM, g_cPathsDownload, sizeof(g_cPathsDownload), "configs/unloze_zr/download.txt");
//cookies BuildPath(Path_SM, g_cPathsWaveSettings, sizeof(g_cPathsWaveSettings), "configs/unloze_zr/wavesettings.txt");
if (g_hClientZMCookie == null) BuildPath(Path_SM, g_cPathsWeapons, sizeof(g_cPathsWeapons), "configs/unloze_zr/weapons.txt");
g_hClientZMCookie = RegClientCookie("unloze_zr_classprefZM", "Cookie for ZM classes", CookieAccess_Protected);
if (g_hClientHumanCookie == null) //hooks
g_hClientHumanCookie = RegClientCookie("unloze_zr_classprefHuman", "Cookie for Human classes", CookieAccess_Protected); HookEvent("player_spawn", ApplySettings, EventHookMode_Post);
BuildPath(Path_SM, g_cPathsClassZM, sizeof(g_cPathsClassZM), "configs/unloze_zr/classeszm.txt"); HookEvent("round_start", Event_roundStart, EventHookMode_Post);
BuildPath(Path_SM, g_cPathsClassHuman, sizeof(g_cPathsClassHuman), "configs/unloze_zr/classeshuman.txt"); HookEvent("player_death", Event_OnPlayerDeath, EventHookMode_Post);
BuildPath(Path_SM, g_cPathsExtra, sizeof(g_cPathsExtra), "configs/unloze_zr/extra.txt"); HookEvent("player_connect", Event_OnFullConnect, EventHookMode_Pre);
BuildPath(Path_SM, g_cPathsDownload, sizeof(g_cPathsDownload), "configs/unloze_zr/download.txt"); HookEvent("player_hurt", EventPlayerHurt, EventHookMode_Pre);
BuildPath(Path_SM, g_cPathsWaveSettings, sizeof(g_cPathsWaveSettings), "configs/unloze_zr/wavesettings.txt"); HookEvent("player_jump", EventPlayerJump, EventHookMode_Post);
BuildPath(Path_SM, g_cPathsWeapons, sizeof(g_cPathsWeapons), "configs/unloze_zr/weapons.txt");
//hooks //commands
HookEvent("player_spawn", ApplySettings, EventHookMode_Post); RegConsoleCmd("say", Cmd_Say);
HookEvent("round_start", Event_roundStart, EventHookMode_Post); RegConsoleCmd("sm_zclass", Cmd_Zclass, "Class Prefferences"); //named like zombiereloaded for ease of use
HookEvent("player_death", Event_OnPlayerDeath, EventHookMode_Post); RegConsoleCmd("sm_zmarket", Cmd_zmarket, "weapon Prefferences"); //named like zombiereloaded for ease of use
HookEvent("player_connect_full", Event_OnFullConnect, EventHookMode_Pre); RegAdminCmd("sm_LoadClasses", Cmd_LoadManually, ADMFLAG_RCON);
HookEvent("player_hurt", EventPlayerHurt, EventHookMode_Pre); RegAdminCmd("sm_wave", Cmd_ChangeWave, ADMFLAG_RCON);
HookEvent("player_jump", EventPlayerJump, EventHookMode_Post); RegAdminCmd("sm_human", Cmd_Humanize, ADMFLAG_BAN);
//commands RegAdminCmd("sm_infect", Cmd_Zombienize, ADMFLAG_BAN);
RegConsoleCmd("say", Cmd_Say);
RegConsoleCmd("sm_zclass", Cmd_Zclass, "Class Prefferences"); //named like zombiereloaded for ease of use
RegConsoleCmd("sm_zmarket", Cmd_zmarket, "weapon Prefferences"); //named like zombiereloaded for ease of use
RegAdminCmd("sm_LoadClasses", Cmd_LoadManually, ADMFLAG_RCON);
RegAdminCmd("sm_wave", Cmd_ChangeWave, ADMFLAG_RCON);
RegAdminCmd("sm_human", Cmd_Humanize, ADMFLAG_BAN);
RegAdminCmd("sm_infect", Cmd_Zombienize, ADMFLAG_BAN);
} }
//---------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------
// Purpose: // Purpose:
//---------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------
public Action Cmd_LoadManually(int client, int args) public Action Cmd_LoadManually(int client, int args)
{ {
//LoadClasses(); //LoadClasses();
AddDownloadContent(); AddDownloadContent();
return Plugin_Handled;
} }
//---------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------
// Purpose: // Purpose:
//---------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------
public Action Cmd_zmarket(int client, int args) public Action Cmd_zmarket(int client, int args)
{ {
Zmarket(client); Zmarket(client);
return Plugin_Handled;
} }
//---------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------
// Purpose: // Purpose:
//---------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------
public Action Cmd_Humanize(int client, int args) public Action Cmd_Humanize(int client, int args)
{ {
InfectionSlashHumanHandling(client, args, 0); InfectionSlashHumanHandling(client, args, 0);
return Plugin_Handled;
} }
//---------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------
// Purpose: // Purpose:
//---------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------
public Action Cmd_Zombienize(int client, int args) public Action Cmd_Zombienize(int client, int args)
{ {
InfectionSlashHumanHandling(client, args, 1); InfectionSlashHumanHandling(client, args, 1);
return Plugin_Handled;
} }
//---------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------
// Purpose: // Purpose:
//---------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------
public Action Cmd_Zclass(int client, int args) public Action Cmd_Zclass(int client, int args)
{ {
Zclass(client); Zclass(client);
return Plugin_Handled;
} }
//---------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------
// Purpose: // Purpose:
//---------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------
public Action Cmd_ChangeWave(int client, int args) public Action Cmd_ChangeWave(int client, int args)
{ {
char l_cChangeWave[4]; char l_cChangeWave[4];
int l_iWave; int l_iWave;
GetCmdArg(1, l_cChangeWave, sizeof(l_cChangeWave)); GetCmdArg(1, l_cChangeWave, sizeof(l_cChangeWave));
l_iWave = StringToInt(l_cChangeWave); l_iWave = StringToInt(l_cChangeWave);
if (l_iWave > 0) if (l_iWave > 0)
{ {
g_iWave = l_iWave; g_iWave = l_iWave;
PrintToChatAll("Admin %N Changing wave to: %i", client, g_iWave); PrintToChatAll("Admin %N Changing wave to: %i", client, g_iWave);
CS_TerminateRound(4.0, CSRoundEnd_Draw, false); CS_TerminateRound(4.0, CSRoundEnd_Draw, false);
} }
else else
{ {
ReplyToCommand(client, "Incorrect input"); ReplyToCommand(client, "Incorrect input");
} }
return Plugin_Handled;
} }
//---------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------
// Purpose: // Purpose:
@ -328,33 +334,36 @@ static void Zclass(int client)
ZclassMenu.ExitBackButton = true; ZclassMenu.ExitBackButton = true;
ZclassMenu.Display(client, 0); ZclassMenu.Display(client, 0);
} }
//---------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------
// Purpose: // Purpose:
//---------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------
public int Zmarket_menu(Menu menu, MenuAction action, int client, int selection) public int Zmarket_menu(Menu menu, MenuAction action, int client, int selection)
{ {
if (action == MenuAction_Select && IsValidClient(client)) if (action == MenuAction_Select && IsValidClient(client))
{ {
ZmarketGetWeapon(client, selection); ZmarketGetWeapon(client, selection);
} }
else if (action == MenuAction_End) else if (action == MenuAction_End)
{ {
delete(menu); delete(menu);
} }
return 0;
} }
//---------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------
// Purpose: // Purpose:
//---------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------
public int Zclass_Menu(Menu menu, MenuAction action, int client, int selection) public int Zclass_Menu(Menu menu, MenuAction action, int client, int selection)
{ {
if (action == MenuAction_Select && IsValidClient(client)) if (action == MenuAction_Select && IsValidClient(client))
{ {
ZclassTeamMenu(client, selection); ZclassTeamMenu(client, selection);
} }
else if (action == MenuAction_End) else if (action == MenuAction_End)
{ {
delete(menu); delete(menu);
} }
return 0;
} }
//---------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------
// Purpose: //https://forums.alliedmods.net/showthread.php?t=305092 // Purpose: //https://forums.alliedmods.net/showthread.php?t=305092
@ -504,42 +513,44 @@ static void ZclassTeamMenu(int client, int state)
//---------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------
public int Zombieclass_Menu(Menu menu, MenuAction action, int client, int selection) public int Zombieclass_Menu(Menu menu, MenuAction action, int client, int selection)
{ {
if (action == MenuAction_Select && IsValidClient(client)) if (action == MenuAction_Select && IsValidClient(client))
{ {
char l_cInfo[4]; char l_cInfo[4];
g_iClientZMClasses[client] = selection + g_iZMBeginindex; g_iClientZMClasses[client] = selection + g_iZMBeginindex;
IntToString(g_iClientZMClasses[client], l_cInfo, sizeof(l_cInfo)); IntToString(g_iClientZMClasses[client], l_cInfo, sizeof(l_cInfo));
SetClientCookie(client, g_hClientZMCookie, l_cInfo); SetClientCookie(client, g_hClientZMCookie, l_cInfo);
if (g_bSwitchingIndex && GetClientTeam(client) == CS_TEAM_T) if (g_bSwitchingIndex && GetClientTeam(client) == CS_TEAM_T)
{ {
SelectWaveBasedZM(client, 1); SelectWaveBasedZM(client, 1);
} }
} }
else if (action == MenuAction_End) else if (action == MenuAction_End)
{ {
delete(menu); delete(menu);
} }
return 0;
} }
//---------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------
// Purpose: // Purpose:
//---------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------
public int Humanclass_Menu(Menu menu, MenuAction action, int client, int selection) public int Humanclass_Menu(Menu menu, MenuAction action, int client, int selection)
{ {
if (action == MenuAction_Select && IsValidClient(client)) if (action == MenuAction_Select && IsValidClient(client))
{ {
char l_cInfo[4]; char l_cInfo[4];
IntToString(selection, l_cInfo, sizeof(l_cInfo)); IntToString(selection, l_cInfo, sizeof(l_cInfo));
SetClientCookie(client, g_hClientHumanCookie, l_cInfo); SetClientCookie(client, g_hClientHumanCookie, l_cInfo);
g_iClientHumanClasses[client] = selection; g_iClientHumanClasses[client] = selection;
if (g_bSwitchingIndex && GetClientTeam(client) == CS_TEAM_CT) if (g_bSwitchingIndex && GetClientTeam(client) == CS_TEAM_CT)
{ {
SelectWavebasedHuman(client); SelectWavebasedHuman(client);
} }
} }
else if (action == MenuAction_End) else if (action == MenuAction_End)
{ {
delete(menu); delete(menu);
} }
return 0;
} }
//---------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------
// Purpose: // Purpose:
@ -850,8 +861,6 @@ public void Event_roundStart(Handle event, const char[] name, bool dontBroadcast
} }
} }
} }
if (l_iHumanPlayers < 1)
ServerCommand("bot_kick");
} }
//---------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------
// Purpose: // Purpose:
@ -876,7 +885,8 @@ public Action RetrieveWaveSettings(int wave)
//---------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------
public Action Timer_switchingModel(Handle timer, any data) public Action Timer_switchingModel(Handle timer, any data)
{ {
g_bSwitchingIndex = false; g_bSwitchingIndex = false;
return Plugin_Handled;
} }
//---------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------
// Purpose: // Purpose:
@ -1064,7 +1074,7 @@ public void SettingBotQoute(int botscale)
int l_iPlayers; int l_iPlayers;
for (int i = 1; i < MaxClients; i++) for (int i = 1; i < MaxClients; i++)
{ {
if (IsValidClient(i) && !IsFakeClient(i)) if (IsValidClient(i) && !IsFakeClient(i) && CS_TEAM_CT == GetClientTeam(i))
{ {
l_iPlayers++; l_iPlayers++;
} }
@ -1076,10 +1086,10 @@ public void SettingBotQoute(int botscale)
//---------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------
public void addBots(int botcount) public void addBots(int botcount)
{ {
ServerCommand("bot_kick"); //ServerCommand("bot_kick");
for (int i = 0; i < botcount; i++) for (int i = 0; i < botcount; i++)
{ {
if (i > 32) if (i > 44) //probably will be turned into a convar somewhen.
continue; continue;
ServerCommand("bot_add_t"); ServerCommand("bot_add_t");
} }
@ -1338,8 +1348,9 @@ public Action Event_OnFullConnect(Event event, const char[] name, bool dontBroad
//---------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------
public Action ApplySettings(Event event, const char[] name, bool dontBroadcast) public Action ApplySettings(Event event, const char[] name, bool dontBroadcast)
{ {
int client = GetClientOfUserId(event.GetInt("userid")); int client = GetClientOfUserId(event.GetInt("userid"));
ApplySettingsEvent(client); ApplySettingsEvent(client);
return Plugin_Handled;
} }
//---------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------
// Purpose: // Purpose:
@ -1459,149 +1470,151 @@ public Action SelectWaveBasedZM(int client, int state)
//---------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------
public Action ModelSelection(int client, int state, int modelIndex) public Action ModelSelection(int client, int state, int modelIndex)
{ {
//state 0 = zombie bots, state 1 = zombie players, state 2 = human players //state 0 = zombie bots, state 1 = zombie players, state 2 = human players
char l_cUniqueModel[g_dLength]; char l_cUniqueModel[g_dLength];
int l_iModelIndex; int l_iModelIndex;
l_iModelIndex = modelIndex; l_iModelIndex = modelIndex;
if (state < 2) if (state < 2)
{ {
Format(l_cUniqueModel, sizeof(l_cUniqueModel), g_cZMRoundClasses[l_iModelIndex][g_iLength]); Format(l_cUniqueModel, sizeof(l_cUniqueModel), g_cZMRoundClasses[l_iModelIndex][g_iLength]);
} }
else if (state == 2) else if (state == 2)
{ {
Format(l_cUniqueModel, sizeof(l_cUniqueModel), g_cHumanClasses[l_iModelIndex][g_iLength]); Format(l_cUniqueModel, sizeof(l_cUniqueModel), g_cHumanClasses[l_iModelIndex][g_iLength]);
} }
for (int i = 0; i < g_dIndexes; i++) for (int i = 0; i < g_dIndexes; i++)
{ {
if (strlen(g_cUniqueName[i][g_iLength]) < 1) if (strlen(g_cUniqueName[i][g_iLength]) < 1)
{ {
continue; continue;
} }
if (StrContains(g_cUniqueName[i][g_iLength], l_cUniqueModel, false) > -1) if (StrContains(g_cUniqueName[i][g_iLength], l_cUniqueModel, false) > -1)
{ {
if (StrContains(g_cModelPath[i][g_iLength], "mdl") == -1) if (StrContains(g_cModelPath[i][g_iLength], "mdl") == -1)
{ {
//incorrect modelpaths crash at SetEntityModel //incorrect modelpaths crash at SetEntityModel
LoadClasses(); LoadClasses();
ForcePlayerSuicide(client); ForcePlayerSuicide(client);
return Plugin_Continue; return Plugin_Continue;
} }
SetEntityModel(client, g_cModelPath[i][g_iLength]); SetEntityModel(client, g_cModelPath[i][g_iLength]);
SDKUnhook(client, SDKHook_OnTakeDamage, OnTakeDamage); SDKUnhook(client, SDKHook_OnTakeDamage, OnTakeDamage);
SDKHook(client, SDKHook_OnTakeDamage, OnTakeDamage); SDKHook(client, SDKHook_OnTakeDamage, OnTakeDamage);
g_bClientProtection[client] = true; g_bClientProtection[client] = true;
if (StrContains(g_cNoFallDmg[i][g_iLength], "YES") > -1) if (StrContains(g_cNoFallDmg[i][g_iLength], "YES") > -1)
g_bFallDamage[client] = true; g_bFallDamage[client] = true;
else else
g_bFallDamage[client] = false; g_bFallDamage[client] = false;
if (state < 2) if (state < 2)
{ {
CreateTimer(g_fZMSpawnProtection, Timer_StopProtection, client); CreateTimer(g_fZMSpawnProtection, Timer_StopProtection, client);
Client_SetActiveWeapon(client, GetPlayerWeaponSlot(client, 2)); Client_SetActiveWeapon(client, GetPlayerWeaponSlot(client, 2));
} }
else else
{ {
CreateTimer(g_fHumanSpawnProtection, Timer_StopProtection, client); CreateTimer(g_fHumanSpawnProtection, Timer_StopProtection, client);
Client_SetActiveWeapon(client, GetPlayerWeaponSlot(client, 1)); Client_SetActiveWeapon(client, GetPlayerWeaponSlot(client, 1));
} }
if (state < 2 && RoundFloat(g_fZMHealthScaleability * 10.0) > 0.0) if (state < 2 && RoundFloat(g_fZMHealthScaleability * 10.0) > 0.0)
SetEntityHealth(client, StringToInt(g_cHealth[i][g_iLength]) * RoundFloat(g_fZMHealthScaleability * 10.0) / 10); SetEntityHealth(client, StringToInt(g_cHealth[i][g_iLength]) * RoundFloat(g_fZMHealthScaleability * 10.0) / 10);
else else
SetEntityHealth(client, StringToInt(g_cHealth[i][g_iLength])); SetEntityHealth(client, StringToInt(g_cHealth[i][g_iLength]));
g_iSpeedIndex[client] = i; g_iSpeedIndex[client] = i;
DHookEntity(g_hGetPlayerMaxSpeed, true, client); g_fKnockBackIndex[client] = StringToFloat(g_cKnockback[i][g_iLength]);
g_fKnockBackIndex[client] = StringToFloat(g_cKnockback[i][g_iLength]); g_fJumpHeightIndex[client] = StringToFloat(g_cJumpHeight[i][g_iLength]);
g_fJumpHeightIndex[client] = StringToFloat(g_cJumpHeight[i][g_iLength]); g_fJumpDistanceIndex[client] = StringToFloat(g_cJumpDistance[i][g_iLength]);
g_fJumpDistanceIndex[client] = StringToFloat(g_cJumpDistance[i][g_iLength]); return Plugin_Handled;
return Plugin_Handled; }
} }
} return Plugin_Handled;
return Plugin_Handled;
} }
//---------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------
// Purpose: // Purpose:
//---------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------
public Action Timer_restrictWeapons(Handle timer, any userid) public Action Timer_restrictWeapons(Handle timer, any userid)
{ {
int l_iWeapon; int l_iWeapon;
for(int j = 1; j <= MaxClients; j++) for(int j = 1; j <= MaxClients; j++)
{ {
if (IsValidClient(j) && GetClientTeam(j) == CS_TEAM_T) if (IsValidClient(j) && GetClientTeam(j) == CS_TEAM_T)
{ {
for (int i = 0; i < 5; i++) for (int i = 0; i < 5; i++)
{ {
l_iWeapon = GetPlayerWeaponSlot(j, i); l_iWeapon = GetPlayerWeaponSlot(j, i);
if (l_iWeapon != -1 && i != 2) if (l_iWeapon != -1 && i != 2)
{ {
RemovePlayerItem(j, l_iWeapon); RemovePlayerItem(j, l_iWeapon);
} }
} }
} }
} }
return Plugin_Handled;
} }
//---------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------
// Purpose: // Purpose:
//---------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------
public Action Timer_CheckIfBotsStuck(Handle timer, any userid) public Action Timer_CheckIfBotsStuck(Handle timer, any userid)
{ {
float l_fClientVelocity[3]; float l_fClientVelocity[3];
for (int i = 1; i < MaxClients; i++) for (int i = 1; i < MaxClients; i++)
{ {
if (IsValidClient(i) && IsFakeClient(i) && IsPlayerAlive(i)) if (IsValidClient(i) && IsFakeClient(i) && IsPlayerAlive(i))
{ {
GetEntPropVector(i, Prop_Data, "m_vecAbsVelocity", l_fClientVelocity); GetEntPropVector(i, Prop_Data, "m_vecAbsVelocity", l_fClientVelocity);
if (l_fClientVelocity[0] < 30.0 && l_fClientVelocity[0] > -30.0 && if (l_fClientVelocity[0] < 30.0 && l_fClientVelocity[0] > -30.0 &&
l_fClientVelocity[1] < 30.0 && l_fClientVelocity[1] > -30.0) l_fClientVelocity[1] < 30.0 && l_fClientVelocity[1] > -30.0)
{ {
g_iBotStuckindex[i]++; g_iBotStuckindex[i]++;
} }
else else
{ {
g_iBotStuckindex[i] = 0; g_iBotStuckindex[i] = 0;
} }
if (g_iBotStuckindex[i] > g_iBotStuckCounts) if (g_iBotStuckindex[i] > g_iBotStuckCounts)
{ {
l_fClientVelocity[0] -= GetRandomInt(50, 250); l_fClientVelocity[0] -= GetRandomInt(50, 250);
l_fClientVelocity[1] -= GetRandomInt(50, 250); l_fClientVelocity[1] -= GetRandomInt(50, 250);
l_fClientVelocity[2] = g_fBotStuckPush * 5; l_fClientVelocity[2] = g_fBotStuckPush * 5;
Entity_SetAbsVelocity(i, l_fClientVelocity); Entity_SetAbsVelocity(i, l_fClientVelocity);
g_iBotStuckindex[i] = 0; g_iBotStuckindex[i] = 0;
} }
} }
} }
return Plugin_Handled;
} }
//---------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------
// Purpose: // Purpose:
//---------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------
public Action Timer_zombieSounds(Handle timer, any userid) public Action Timer_zombieSounds(Handle timer, any userid)
{ {
int[] l_clients = new int[MaxClients + 1]; int[] l_clients = new int[MaxClients + 1];
int l_client; int l_client;
int l_iclientCount; int l_iclientCount;
int l_iSoundIndexes; int l_iSoundIndexes;
for (int i = 1; i < MaxClients; i++) for (int i = 1; i < MaxClients; i++)
{ {
if (IsValidClient(i) && GetClientTeam(i) == CS_TEAM_T) if (IsValidClient(i) && GetClientTeam(i) == CS_TEAM_T)
{ {
l_clients[l_iclientCount++] = i; l_clients[l_iclientCount++] = i;
} }
} }
l_client = l_clients[GetRandomInt(0, l_iclientCount - 1)]; l_client = l_clients[GetRandomInt(0, l_iclientCount - 1)];
l_iSoundIndexes = GetRandomInt(0, g_iSoundIndexes - 1); l_iSoundIndexes = GetRandomInt(0, g_iSoundIndexes - 1);
/* /*
PrintToChatAll("emitting sound from client: %N", l_client); PrintToChatAll("emitting sound from client: %N", l_client);
PrintToChatAll("with l_iSoundIndexes: %i", l_iSoundIndexes); PrintToChatAll("with l_iSoundIndexes: %i", l_iSoundIndexes);
PrintToChatAll("g_cZMSounds[l_iSoundIndexes][g_iLength]: %s", g_cZMSounds[l_iSoundIndexes][g_iLength]); PrintToChatAll("g_cZMSounds[l_iSoundIndexes][g_iLength]: %s", g_cZMSounds[l_iSoundIndexes][g_iLength]);
EmitSound(l_clients, l_iclientCount, g_cZMSounds[l_iSoundIndexes][g_iLength], l_client, SNDCHAN_BODY, SNDLEVEL_NORMAL, SND_NOFLAGS, 0.45, SNDPITCH_NORMAL); EmitSound(l_clients, l_iclientCount, g_cZMSounds[l_iSoundIndexes][g_iLength], l_client, SNDCHAN_BODY, SNDLEVEL_NORMAL, SND_NOFLAGS, 0.45, SNDPITCH_NORMAL);
EmitSoundToAll(g_cZMSounds[l_iSoundIndexes][g_iLength]); EmitSoundToAll(g_cZMSounds[l_iSoundIndexes][g_iLength]);
*/ */
for (int i = 1; i < MaxClients; i++) for (int i = 1; i < MaxClients; i++)
{ {
if (IsValidClient(i) && !IsFakeClient(i)) if (IsValidClient(i) && !IsFakeClient(i))
{ {
EmitSoundToClient(i, g_cZMSounds[l_iSoundIndexes][g_iLength], l_client); EmitSoundToClient(i, g_cZMSounds[l_iSoundIndexes][g_iLength], l_client);
} }
} }
return Plugin_Handled;
} }
//---------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------
// Purpose: // Purpose:
@ -1637,8 +1650,9 @@ public Action Timer_Respawn(Handle timer, any userid)
//---------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------
public Action Timer_StopProtection(Handle timer, int client) public Action Timer_StopProtection(Handle timer, int client)
{ {
if (IsValidClient(client)) if (IsValidClient(client))
g_bClientProtection[client] = false; g_bClientProtection[client] = false;
return Plugin_Handled;
} }
//---------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------
// Purpose: // Purpose:
@ -1786,7 +1800,7 @@ public void KnockbackSetVelocity(int client, const float startpoint[3], const fl
vector[2] = CSGO_KNOCKBACK_BOOST; vector[2] = CSGO_KNOCKBACK_BOOST;
} }
} }
// ADD the given vector to the client's current velocity. tools_functions.inc // ADD the given vector to the clients current velocity. tools_functions.inc
ToolsClientVelocity(client, vector); ToolsClientVelocity(client, vector);
} }
//---------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------
@ -1815,7 +1829,7 @@ public int KnockbackFindExplodingGrenade(float heLoc[3])
{ {
continue; continue;
} }
// If entity isn't a grenade, then stop. // If entity isnt a grenade, then stop.
GetEdictClassname(x, l_cClassname, sizeof(l_cClassname)); GetEdictClassname(x, l_cClassname, sizeof(l_cClassname));
if (!StrEqual(l_cClassname, "hegrenade_projectile", false)) if (!StrEqual(l_cClassname, "hegrenade_projectile", false))
{ {
@ -1831,7 +1845,7 @@ public int KnockbackFindExplodingGrenade(float heLoc[3])
return x; return x;
} }
} }
// Didn't find the grenade. // Didnt find the grenade.
return -1; return -1;
} }
//---------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------
@ -1843,10 +1857,11 @@ public Action EventPlayerJump(Handle event, const char[] name, bool dontBroadcas
int index = GetClientOfUserId(GetEventInt(event, "userid")); int index = GetClientOfUserId(GetEventInt(event, "userid"));
// Fire post player_jump event. // Fire post player_jump event.
CreateTimer(0.0, EventPlayerJumpPost, index); CreateTimer(0.0, EventPlayerJumpPost, index);
return Plugin_Handled;
} }
public Action EventPlayerJumpPost(Handle timer, int client) public Action EventPlayerJumpPost(Handle timer, int client)
{ {
// If client isn't in-game, then stop. // If client isnt in-game, then stop.
if (!IsClientInGame(client)) if (!IsClientInGame(client))
{ {
return Plugin_Handled; return Plugin_Handled;
@ -1861,7 +1876,7 @@ public Action EventPlayerJumpPost(Handle timer, int client)
return Plugin_Continue; return Plugin_Continue;
} }
float vecVelocity[3]; float vecVelocity[3];
// Get client's current velocity. // Get clients current velocity.
ToolsClientVelocity(client, vecVelocity, false); ToolsClientVelocity(client, vecVelocity, false);
//maybe check JumpBoostIsBHop here //maybe check JumpBoostIsBHop here
@ -1894,17 +1909,17 @@ stock void ToolsGetClientVelocity(int client, float vecVelocity[3])
//---------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------
stock void ToolsClientVelocity(int client, float vecVelocity[3], bool apply = true, bool stack = true) stock void ToolsClientVelocity(int client, float vecVelocity[3], bool apply = true, bool stack = true)
{ {
// If retrieve is true, then get client's velocity. // If retrieve is true, then get clients velocity.
if (!apply) if (!apply)
{ {
ToolsGetClientVelocity(client, vecVelocity); ToolsGetClientVelocity(client, vecVelocity);
// Stop here. // Stop here.
return; return;
} }
// If stack is true, then add client's velocity. // If stack is true, then add clients velocity.
if (stack) if (stack)
{ {
// Get client's velocity. // Get clients velocity.
float vecClientVelocity[3]; float vecClientVelocity[3];
ToolsGetClientVelocity(client, vecClientVelocity); ToolsGetClientVelocity(client, vecClientVelocity);
AddVectors(vecClientVelocity, vecVelocity, vecVelocity); AddVectors(vecClientVelocity, vecVelocity, vecVelocity);
@ -1930,4 +1945,4 @@ stock void ReplaceStrings(char[] str, char[] strReplace)
stock void FakePrecacheSound(const char[] szPath) stock void FakePrecacheSound(const char[] szPath)
{ {
AddToStringTable(FindStringTable("soundprecache"), szPath); AddToStringTable(FindStringTable("soundprecache"), szPath);
} }