From fe5ed637cc024a4f0ed9ac1c0b30175ad09992cf Mon Sep 17 00:00:00 2001 From: Greyscale Date: Tue, 21 Jul 2009 13:25:11 -0700 Subject: [PATCH] Fixed napalm error. Fixed specatators/invalid players showing up in force zspawn/ztele. Fixed knife alpha (untested) --- src/zr/infect.inc | 69 ++++++++++++++++++------------------- src/zr/menu.inc | 39 +++++++++++++++++++-- src/zr/napalm.inc | 2 +- src/zr/roundstart.inc | 10 +++--- src/zr/weapons/restrict.inc | 8 ++++- src/zr/zadmin.inc | 4 +-- src/zr/zspawn.inc | 2 +- src/zr/ztele.inc | 2 +- 8 files changed, 86 insertions(+), 50 deletions(-) diff --git a/src/zr/infect.inc b/src/zr/infect.inc index 26c2a60..627e21e 100644 --- a/src/zr/infect.inc +++ b/src/zr/infect.inc @@ -597,42 +597,6 @@ InfectHumanToZombie(client, attacker = -1, bool:motherinfect = false, bool:respa ZHPOnHealthInfectGain(attacker); } - // Switch the player to terrorists. - // TODO: A solution to stop confusing bots? Respawn and teleport? - CS_SwitchTeam(client, CS_TEAM_T); - - // If respawn is enabled, then teleport mother zombie back to spawnpoint. - if (motherinfect) - { - new bool:zombierespawn = GetConVarBool(g_hCvarsList[CVAR_INFECT_MZOMBIE_RESPAWN]); - if(zombierespawn) - { - ZTeleTeleportClient(client); - } - } - // Check override. - else - { - if (respawnoverride && respawn) - { - ZTeleTeleportClient(client); - } - } - - // Set client as translation target. - SetGlobalTransTarget(client); - - // Print message to client. - TranslationPrintToChat(client, "Infect infected"); - - // Forward event to modules. - ClassOnClientInfected(client, motherinfect); - RoundEndOnClientInfected(); - DamageOnClientInfected(client, motherinfect); - SEffectsOnClientInfected(client); - ZTeleOnClientInfected(client); - ZHPOnClientInfected(client); - // Get a list of all client's weapon indexes. new weapons[WeaponsSlot]; WeaponsGetClientWeapons(client, weapons); @@ -674,6 +638,39 @@ InfectHumanToZombie(client, attacker = -1, bool:motherinfect = false, bool:respa // Give zombie a new knife. (If you leave the old one there will be glitches with the knife positioning) GivePlayerItem(client, "weapon_knife"); + + // Switch the player to terrorists. + // TODO: A solution to stop confusing bots? Respawn and teleport? + CS_SwitchTeam(client, CS_TEAM_T); + + // If respawn is enabled, then teleport mother zombie back to spawnpoint. + if (motherinfect) + { + new bool:zombierespawn = GetConVarBool(g_hCvarsList[CVAR_INFECT_MZOMBIE_RESPAWN]); + if(zombierespawn) + { + ZTeleTeleportClient(client); + } + } + // Check override. + else + { + if (respawnoverride && respawn) + { + ZTeleTeleportClient(client); + } + } + + // Print message to client. + TranslationPrintToChat(client, "Infect infected"); + + // Forward event to modules. + ClassOnClientInfected(client, motherinfect); + RoundEndOnClientInfected(); + DamageOnClientInfected(client, motherinfect); + SEffectsOnClientInfected(client); + ZTeleOnClientInfected(client); + ZHPOnClientInfected(client); } /** diff --git a/src/zr/menu.inc b/src/zr/menu.inc index 11fe0a0..4c0d28b 100644 --- a/src/zr/menu.inc +++ b/src/zr/menu.inc @@ -202,9 +202,12 @@ public ZMenuMainHandle(Handle:menu, MenuAction:action, client, slot) * * @param client The client index. * @param handler The menu handler. + * @param team If true, only clients on a team will be displayed. + * @param alive If true, only clients that are alive will be displayed. + * @param dead If true, only clients that are dead will be displayed. * @param any Title is a translations phrase. */ -stock MenuClientList(client, MenuHandler:handler, any:...) +stock MenuClientList(client, MenuHandler:handler, bool:team = false, bool:alive = false, bool:dead = false, any:...) { // Create menu handle. new Handle:menu_clients = CreateMenu(handler); @@ -214,7 +217,7 @@ stock MenuClientList(client, MenuHandler:handler, any:...) // Translate phrase. decl String:translation[TRANSLATION_MAX_LENGTH_CHAT]; - VFormat(translation, sizeof(translation), "%t", 3); + VFormat(translation, sizeof(translation), "%t", 6); // Set menu title to the translated phrase. SetMenuTitle(menu_clients, translation); @@ -222,6 +225,8 @@ stock MenuClientList(client, MenuHandler:handler, any:...) decl String:clientoption[MAX_NAME_LENGTH]; decl String:clientuserid[8]; + new count = 0; + // x = Client index. for (new x = 1; x <= MaxClients; x++) { @@ -231,12 +236,42 @@ stock MenuClientList(client, MenuHandler:handler, any:...) continue; } + // If client isn't on a team, then stop. + if (team && !ZRIsClientOnTeam(x)) + { + continue; + } + + // If client is dead, then stop. + if (alive && !IsPlayerAlive(x)) + { + continue; + } + + // If client is alive, then stop. + if (dead && IsPlayerAlive(x)) + { + continue; + } + // Get client info. GetClientName(x, clientoption, sizeof(clientoption)); IntToString(GetClientUserId(x), clientuserid, sizeof(clientuserid)); // Add option to menu. AddMenuItem(menu_clients, clientuserid, clientoption); + + // Increment count. + count++; + } + + // If there are no clients, add an "(Empty)" line. + if (count == 0) + { + decl String:empty[64]; + Format(empty, sizeof(empty), "%t", "Menu empty"); + + AddMenuItem(menu_clients, "empty", empty, ITEMDRAW_DISABLED); } // Create a "Back" button to the main admin menu. diff --git a/src/zr/napalm.inc b/src/zr/napalm.inc index c36d6d1..8057998 100644 --- a/src/zr/napalm.inc +++ b/src/zr/napalm.inc @@ -198,7 +198,7 @@ public Action:NapalmIgniteGrenade(Handle:timer) for (new x = 0; x <= maxentities; x++) { // If entity is invalid, then stop. - if(!IsValidEdict(x)) + if(!IsValidEntity(x)) { continue; } diff --git a/src/zr/roundstart.inc b/src/zr/roundstart.inc index f5c69f2..071a8a6 100644 --- a/src/zr/roundstart.inc +++ b/src/zr/roundstart.inc @@ -72,7 +72,7 @@ RoundStartOnRoundStart() /** * Kills all objective entities. */ -RoundStartKillObjectives() +stock RoundStartKillObjectives() { decl String:classname[64]; @@ -92,12 +92,10 @@ RoundStartKillObjectives() GetEdictClassname(x, classname, sizeof(classname)); // Check if it matches any objective entities, then stop if it doesn't. - if(StrContains(ROUNDSTART_OBJECTIVE_ENTITIES, classname) == -1) + if(StrContains(ROUNDSTART_OBJECTIVE_ENTITIES, classname) > -1) { - continue; + // Entity is an objective, kill it. + RemoveEdict(x); } - - // Entity is an objective, kill it. - RemoveEdict(x); } } diff --git a/src/zr/weapons/restrict.inc b/src/zr/weapons/restrict.inc index 280e3b6..d4196f8 100644 --- a/src/zr/weapons/restrict.inc +++ b/src/zr/weapons/restrict.inc @@ -222,6 +222,12 @@ RestrictOnRoundEnd() */ public Action:RestrictBuyCommand(client, argc) { + // If client isn't in-game, then stop. + if (!IsClientInGame(client)) + { + return Plugin_Continue; + } + // If player is a zombie, then block command. if (InfectIsClientInfected(client)) { @@ -242,7 +248,7 @@ public Action:RestrictBuyCommand(client, argc) // If weapon isn't configged, then allow pickup. if (index == -1) { - // Allow pickup. + // Allow command. return Plugin_Continue; } diff --git a/src/zr/zadmin.inc b/src/zr/zadmin.inc index c40ab52..f0e7dca 100644 --- a/src/zr/zadmin.inc +++ b/src/zr/zadmin.inc @@ -165,7 +165,7 @@ public ZAdminMenuHandle(Handle:menu_zadmin, MenuAction:action, client, slot) resend = false; // Send list of clients to infect. - MenuClientList(client, ZSpawnForceHandle, "ZSpawn clients title"); + MenuClientList(client, ZSpawnForceHandle, true, false, true, "ZSpawn clients title"); } // Force ZTele. case 5: @@ -174,7 +174,7 @@ public ZAdminMenuHandle(Handle:menu_zadmin, MenuAction:action, client, slot) resend = false; // Send list of clients to infect. - MenuClientList(client, ZTeleForceHandle, "ZTele clients title"); + MenuClientList(client, ZTeleForceHandle, true, true, false, "ZTele clients title"); } } diff --git a/src/zr/zspawn.inc b/src/zr/zspawn.inc index 6982484..ecee380 100644 --- a/src/zr/zspawn.inc +++ b/src/zr/zspawn.inc @@ -302,7 +302,7 @@ public ZSpawnForceHandle(Handle:menu_zspawn_force, MenuAction:action, client, sl } // Re-send the menu. - MenuClientList(client, ZSpawnForceHandle, "ZSpawn clients title"); + MenuClientList(client, ZSpawnForceHandle, true, false, true, "ZSpawn clients title"); } // Client closed the menu. if (action == MenuAction_Cancel) diff --git a/src/zr/ztele.inc b/src/zr/ztele.inc index c7917e8..33aec78 100644 --- a/src/zr/ztele.inc +++ b/src/zr/ztele.inc @@ -271,7 +271,7 @@ public ZTeleForceHandle(Handle:menu_ztele_force, MenuAction:action, client, slot } // Re-send the menu. - MenuClientList(client, ZTeleForceHandle, "ZTele clients title"); + MenuClientList(client, ZTeleForceHandle, true, true, false, "ZTele clients title"); } // Client closed the menu. if (action == MenuAction_Cancel)