diff --git a/scripting/dm_basics.sp b/scripting/dm_basics.sp index f01f5c5..d13bf47 100644 --- a/scripting/dm_basics.sp +++ b/scripting/dm_basics.sp @@ -54,9 +54,6 @@ public OnPluginStart() { LoadTranslations("cssdm.phrases"); - RegConsoleCmd("say", Command_Say); - RegConsoleCmd("say_team", Command_Say); - cssdm_respawn_command = CreateConVar("cssdm_respawn_command", "1", "Sets whether clients can manually respawn"); cssdm_force_mapchanges = CreateConVar("cssdm_force_mapchanges", "0", "Sets whether CS:S DM should force mapchanges"); cssdm_mapchange_file = CreateConVar("cssdm_mapchange_file", "mapcycle.txt", "Sets the mapchange file for CS:S DM"); @@ -127,11 +124,9 @@ public Event_CheckDepleted(Handle:event, const String:name[], bool:dontBroadcast { return; } - - new ammoType = GetEntProp(entity, Prop_Send, "m_iPrimaryAmmoType"); - + /* Give something reasonable -- the game will chop it off */ - DM_GiveClientAmmo(client, ammoType, 200, false); + DM_GiveClientAmmo(client, GetEntProp(entity, Prop_Send, "m_iPrimaryAmmoType"), 200, false); } public CvarChange_RestartMapTimer(Handle:cvar, const String:oldvalue[], const String:newvalue[]) @@ -150,8 +145,7 @@ RestartMapTimer() if (GetConVarInt(cssdm_force_mapchanges)) { /* Find how much time is left in the map */ - new Float:seconds = (GetConVarInt(mp_timelimit) * 60.0) - GetGameTime(); - g_ChangeMapTimer = CreateTimer(seconds, Timer_ChangeMap); + g_ChangeMapTimer = CreateTimer((GetConVarInt(mp_timelimit) * 60.0) - GetGameTime(), Timer_ChangeMap); } } @@ -243,17 +237,15 @@ public Action:DM_OnClientDeath(client) return Plugin_Continue; } -public Action:Command_Say(client, args) +public Action:OnClientSayCommand(client, const String:command[], const String:sArgs[]) { if (!DM_IsRunning() || !GetConVarInt(cssdm_respawn_command)) { return Plugin_Continue; } - decl String:command[32]; - GetCmdArg(1, command, sizeof(command)); - if (strcmp(command, "respawn") == 0) + if (strcmp(sArgs, "respawn") == 0) { if (!IsClientInGame(client)) { diff --git a/scripting/dm_equipment.sp b/scripting/dm_equipment.sp index fb385bf..0d95317 100644 --- a/scripting/dm_equipment.sp +++ b/scripting/dm_equipment.sp @@ -32,11 +32,13 @@ /** Plugin Stuff */ new Handle:cssdm_enable_equipment; /** cssdm_enable_equipment cvar */ +new Handle:cssdm_addictional_menu_cmds; /** cssdm_addictional_menu_cmds cvar */ new Handle:g_SpawnTimers[MAXPLAYERS+1]; /* Post-spawn timers */ new Handle:g_hPrimaryMenu = INVALID_HANDLE; /* Priamry menu Handle */ new Handle:g_hSecondaryMenu = INVALID_HANDLE; /* Secondary menu Handle */ new Handle:g_hEquipMenu = INVALID_HANDLE; /* Main equipment menu */ new bool:g_IsEnabled = false; /* Whether the plugin should work */ +new bool:g_IsAddictionalMenuCmdsEnabled = false; /* Should the menu open for additional commands */ new g_PrimaryChoices[MAXPLAYERS+1]; /* Primary weapon selections */ new g_SecondaryChoices[MAXPLAYERS+1]; /* Secondary weapon selections */ new bool:g_GunMenuEnabled[MAXPLAYERS+1]; /* Whether the gun menu is enabled */ @@ -96,21 +98,17 @@ public Plugin:myinfo = public OnPluginStart() { - new String:game[64]; - GetGameFolderName(game, sizeof(game)); - if (StrEqual(game, "csgo", false)) - { - g_bIsGo = true; - } + g_bIsGo = GetEngineVersion() == Engine_CSGO; LoadTranslations("cssdm.phrases"); - RegConsoleCmd("say", Command_Say); - RegConsoleCmd("say_team", Command_Say); - cssdm_enable_equipment = CreateConVar("cssdm_enable_equipment", "1", "Sets whether the equipment plugin is enabled"); HookConVarChange(cssdm_enable_equipment, OnEquipmentEnableChange); + cssdm_addictional_menu_cmds = CreateConVar("cssdm_addictional_menu_cmds", "0", "Opens menu on autobuy, rebuy, etc. cmds"); + HookConVarChange(cssdm_addictional_menu_cmds, OnEquipmentAddictionalMenuCmdsChange); + + g_hEquipMenu = CreateMenu(Menu_EquipHandler, MenuAction_DrawItem|MenuAction_DisplayItem); SetMenuTitle(g_hEquipMenu, "Weapon Options:"); SetMenuExitButton(g_hEquipMenu, false); @@ -126,6 +124,11 @@ public OnEquipmentEnableChange(Handle:convar, const String:oldValue[], const Str g_IsEnabled = StringToInt(newValue) ? true : false; } +public OnEquipmentAddictionalMenuCmdsChange(Handle:convar, const String:oldValue[], const String:newValue[]) +{ + g_IsAddictionalMenuCmdsEnabled = StringToInt(newValue) ? true : false; +} + public OnConfigsExecuted() { LoadDefaults(); @@ -146,7 +149,7 @@ public OnConfigsExecuted() decl String:map[64]; decl String:path[255]; GetCurrentMap(map, sizeof(map)); - Format(path, sizeof(path), "cfg/cssdm/maps/%s.equip.txt", map); + FormatEx(path, sizeof(path), "cfg/cssdm/maps/%s.equip.txt", map); if (FileExists(path)) { @@ -354,17 +357,14 @@ public Action:PlayerPostSpawn(Handle:timer, any:client) return Plugin_Stop; } -public Action:Command_Say(client, args) +public Action:OnClientSayCommand(client, const String:command[], const String:sArgs[]) { if (!ShouldRun()) { return Plugin_Continue; } - new String:text[192]; - GetCmdArg(1, text, sizeof(text)); - - if (strcmp(text, "guns") == 0) + if (strcmp(sArgs, "guns") == 0) { if (!g_AllowGunCommand) { @@ -414,6 +414,10 @@ public Action:OnClientCommand(client, args) || StrEqual(cmd, "buyequip") || StrEqual(cmd, "buymenu")) { + if(g_IsAddictionalMenuCmdsEnabled) + { + OnClientSayCommand(client, "", "guns"); + } return Plugin_Handled; } @@ -505,7 +509,7 @@ public Menu_PrimaryHandler(Handle:menu, MenuAction:action, param1, param2) new Handle:hPanel = Handle:param2; decl String:title[128]; - Format(title, sizeof(title), "%T:", "Primary weapon", param1); + FormatEx(title, sizeof(title), "%T:", "Primary weapon", param1); SetPanelTitle(hPanel, title); } diff --git a/scripting/dm_spawn_protection.sp b/scripting/dm_spawn_protection.sp index c9a3844..4dc231c 100644 --- a/scripting/dm_spawn_protection.sp +++ b/scripting/dm_spawn_protection.sp @@ -37,13 +37,11 @@ new Handle:g_ProtTimeVar; new g_NormColor[4] = {255, 255, 255, 255}; new g_TColor[4] = {255, 0, 0, 128}; new g_CTColor[4] = {0, 0, 255, 128}; -new g_HealthOffset; new g_RenderModeOffset; new g_RenderClrOffset; /* Player stuff */ new Handle:g_PlayerTimers[MAXPLAYERS+1]; -new g_PlayerHealth[MAXPLAYERS+1]; /** PUBLIC INFO */ public Plugin:myinfo = @@ -65,7 +63,6 @@ public OnPluginStart() HookConVarChange(g_CTColorVar, OnColorChange); HookConVarChange(g_TColorVar, OnColorChange); - g_HealthOffset = FindSendPropOffs("CCSPlayer", "m_iHealth"); g_RenderModeOffset = FindSendPropOffs("CCSPlayer", "m_nRenderMode"); g_RenderClrOffset = FindSendPropOffs("CCSPlayer", "m_clrRender"); } @@ -113,7 +110,7 @@ public Action:StopProtection(Handle:timer, any:client) { g_PlayerTimers[client] = INVALID_HANDLE; - SetEntData(client, g_HealthOffset, g_PlayerHealth[client]); + SetGodMode(client, false); UTIL_Render(client, g_NormColor); return Plugin_Stop; @@ -130,17 +127,21 @@ public DM_OnClientPostSpawned(client) g_PlayerTimers[client] = CreateTimer(GetConVarFloat(g_ProtTimeVar), StopProtection, client); - /* Start protection */ - g_PlayerHealth[client] = GetEntData(client, g_HealthOffset); - SetEntData(client, g_HealthOffset, 1012); /* This overflows to show "500" */ + SetGodMode(client, true); - new team = GetClientTeam(client); - if (team == CSSDM_TEAM_T) + switch(GetClientTeam(client)) { - UTIL_Render(client, g_TColor); - } else if (team == CSSDM_TEAM_CT) { - UTIL_Render(client, g_CTColor); + case CSSDM_TEAM_T: + { + UTIL_Render(client, g_TColor); + } + + case CSSDM_TEAM_CT: + { + UTIL_Render(client, g_CTColor); + } } + } UTIL_Render(client, const color[4]) @@ -151,3 +152,8 @@ UTIL_Render(client, const color[4]) SetEntDataArray(client, g_RenderClrOffset, color, 4, 1); ChangeEdictState(client); } + +SetGodMode(client, bool:godmode) +{ + SetEntProp(client, Prop_Data, "m_takedamage", godmode ? 2 : 0, 1); +}