Removed antistick force cvar, removed more tHandle defines, moved respawn to its own module, moved market menu send function to markethandler.inc, fixed some run-on timers in zhp and spawn protect

This commit is contained in:
Greyscale 2009-04-16 05:30:26 +02:00
parent 872e41e6d2
commit 5b9f8d364d
15 changed files with 308 additions and 187 deletions

View File

@ -25,8 +25,13 @@
#include "zr/ambience" #include "zr/ambience"
#include "zr/models" #include "zr/models"
#include "zr/overlays" #include "zr/overlays"
// Class system
#include "zr/playerclasses/playerclasses" #include "zr/playerclasses/playerclasses"
// Antistick
#include "zr/antistick" #include "zr/antistick"
#include "zr/anticamp" #include "zr/anticamp"
#include "zr/teleport" #include "zr/teleport"
#include "zr/zombie" #include "zr/zombie"
@ -45,6 +50,9 @@
// Spawn protect // Spawn protect
#include "zr/spawnprotect" #include "zr/spawnprotect"
// Respawn
#include "zr/respawn"
// ZHP // ZHP
#include "zr/zhp" #include "zr/zhp"
@ -173,12 +181,11 @@ public OnClientPutInServer(client)
gBlockMotherInfect[client] = false; gBlockMotherInfect[client] = false;
gKilledByWorld[client] = false; gKilledByWorld[client] = false;
bZVision[client] = !IsFakeClient(client);
// Forward event to modules. // Forward event to modules.
ClassClientInit(client); ClassClientInit(client);
WeaponsClientInit(client); WeaponsClientInit(client);
SpawnProtectClientInit(client); SpawnProtectClientInit(client);
RespawnClientInit(client);
ZHPClientInit(client); ZHPClientInit(client);
if (!IsFakeClient(client)) AmbienceStart(client); if (!IsFakeClient(client)) AmbienceStart(client);

View File

@ -62,8 +62,7 @@ AntiStickIsStuck(client)
GetClientAbsOrigin(client, clientloc); GetClientAbsOrigin(client, clientloc);
// x = client index. // x = client index.
new maxplayers = GetMaxClients(); for (new x = 1; x <= MaxClients; x++)
for (new x = 1; x <= maxplayers; x++)
{ {
// Validate player is in-game, alive, and isn't the player being checked. ('client') // Validate player is in-game, alive, and isn't the player being checked. ('client')
if (!IsClientInGame(x) || !IsPlayerAlive(x) || x == client) if (!IsClientInGame(x) || !IsPlayerAlive(x) || x == client)
@ -104,8 +103,7 @@ AntiStickIsStuck(client)
public Action:AntiStickTimer(Handle:timer) public Action:AntiStickTimer(Handle:timer)
{ {
// x = client index // x = client index
new maxplayers = GetMaxClients(); for (new x = 1; x <= MaxClients; x++)
for (new x = 1; x <= maxplayers; x++)
{ {
// Validate player is in-game and alive. // Validate player is in-game and alive.
if (!IsClientInGame(x) || !IsPlayerAlive(x)) if (!IsClientInGame(x) || !IsPlayerAlive(x))

View File

@ -128,7 +128,7 @@ public Action:Command_Respawn(client, argc)
ZR_LogMessageFormatted(targets[x], "admin commands", "spawn", "\"%s\" spawned player \"%s\".", true, client_name, target_name); ZR_LogMessageFormatted(targets[x], "admin commands", "spawn", "\"%s\" spawned player \"%s\".", true, client_name, target_name);
} }
RespawnPlayer(targets[x]); RespawnSpawnClient(targets[x]);
} }
} }

View File

@ -50,7 +50,7 @@ enum ZRSettings
Handle:CVAR_MOTHER_ZOMBIE_RATIO, Handle:CVAR_MOTHER_ZOMBIE_RATIO,
Handle:CVAR_MOTHER_ZOMBIE_RESPAWN, Handle:CVAR_MOTHER_ZOMBIE_RESPAWN,
Handle:CVAR_RESPAWN, Handle:CVAR_RESPAWN,
Handle:CVAR_RESPAWN_TEAM, Handle:CVAR_RESPAWN_ZOMBIE,
Handle:CVAR_RESPAWN_DELAY, Handle:CVAR_RESPAWN_DELAY,
Handle:CVAR_SUICIDE_ZOMBIE, Handle:CVAR_SUICIDE_ZOMBIE,
Handle:CVAR_SUICIDE_HUMAN, Handle:CVAR_SUICIDE_HUMAN,
@ -88,7 +88,6 @@ enum ZRSettings
Handle:CVAR_INFECT_SHAKE_AMP, Handle:CVAR_INFECT_SHAKE_AMP,
Handle:CVAR_INFECT_SHAKE_FREQUENCY, Handle:CVAR_INFECT_SHAKE_FREQUENCY,
Handle:CVAR_INFECT_SHAKE_DURATION, Handle:CVAR_INFECT_SHAKE_DURATION,
Handle:CVAR_INFECT_ANTISTICK_FORCE,
Handle:CVAR_ANTICAMP, Handle:CVAR_ANTICAMP,
Handle:CVAR_ANTICAMP_UPDATE_INTERVAL, Handle:CVAR_ANTICAMP_UPDATE_INTERVAL,
Handle:CVAR_ANTICAMP_ECHO Handle:CVAR_ANTICAMP_ECHO
@ -140,7 +139,7 @@ CreateCvars()
gCvars[CVAR_MOTHER_ZOMBIE_RATIO] = CreateConVar("zr_mother_zombie_ratio", "5", "For every 'x' number of humans, there will be 1 zombie (0: Always only 1 mother zombie)"); gCvars[CVAR_MOTHER_ZOMBIE_RATIO] = CreateConVar("zr_mother_zombie_ratio", "5", "For every 'x' number of humans, there will be 1 zombie (0: Always only 1 mother zombie)");
gCvars[CVAR_MOTHER_ZOMBIE_RESPAWN] = CreateConVar("zr_mother_zombie_respawn", "0", "First zombie(s) will be teleported back to spawn when infected (0: Disable)"); gCvars[CVAR_MOTHER_ZOMBIE_RESPAWN] = CreateConVar("zr_mother_zombie_respawn", "0", "First zombie(s) will be teleported back to spawn when infected (0: Disable)");
gCvars[CVAR_RESPAWN] = CreateConVar("zr_respawn", "0", "When player is killed, player will respawn"); gCvars[CVAR_RESPAWN] = CreateConVar("zr_respawn", "0", "When player is killed, player will respawn");
gCvars[CVAR_RESPAWN_TEAM] = CreateConVar("zr_respawn_team", "zombie", "Which team to respawn player as (Choices: zombie, human)"); gCvars[CVAR_RESPAWN_ZOMBIE] = CreateConVar("zr_respawn_zombie", "1", "Respawn player as zombie (0: Respawn as human)");
gCvars[CVAR_RESPAWN_DELAY] = CreateConVar("zr_respawn_delay", "1", "How long to wait after death to respawn, in seconds"); gCvars[CVAR_RESPAWN_DELAY] = CreateConVar("zr_respawn_delay", "1", "How long to wait after death to respawn, in seconds");
gCvars[CVAR_SUICIDE_ZOMBIE] = CreateConVar("zr_suicide_zombie", "1", "Stops zombies from suiciding"); gCvars[CVAR_SUICIDE_ZOMBIE] = CreateConVar("zr_suicide_zombie", "1", "Stops zombies from suiciding");
gCvars[CVAR_SUICIDE_HUMAN] = CreateConVar("zr_suicide_human", "1", "Stops humans from suiciding"); gCvars[CVAR_SUICIDE_HUMAN] = CreateConVar("zr_suicide_human", "1", "Stops humans from suiciding");
@ -178,7 +177,6 @@ CreateCvars()
gCvars[CVAR_INFECT_SHAKE_AMP] = CreateConVar("zr_infect_shake_amp", "15.0", "Amplitude of the shake, when zr_infect_shake is 1"); gCvars[CVAR_INFECT_SHAKE_AMP] = CreateConVar("zr_infect_shake_amp", "15.0", "Amplitude of the shake, when zr_infect_shake is 1");
gCvars[CVAR_INFECT_SHAKE_FREQUENCY] = CreateConVar("zr_infect_shake_frequency", "1.0", "Frequency of the shake, when zr_infect_shake is 1"); gCvars[CVAR_INFECT_SHAKE_FREQUENCY] = CreateConVar("zr_infect_shake_frequency", "1.0", "Frequency of the shake, when zr_infect_shake is 1");
gCvars[CVAR_INFECT_SHAKE_DURATION] = CreateConVar("zr_infect_shake_duration", "5.0", "Duration of the shake, when zr_infect_shake is 1"); gCvars[CVAR_INFECT_SHAKE_DURATION] = CreateConVar("zr_infect_shake_duration", "5.0", "Duration of the shake, when zr_infect_shake is 1");
gCvars[CVAR_INFECT_ANTISTICK_FORCE] = CreateConVar("zr_infect_antistick_force", "-160.0", "Force to push away players from eachother on infection. Negative values push away, positive values pull. (0: Disable)");
gCvars[CVAR_ANTICAMP] = CreateConVar("zr_anticamp", "1", "Enables or disables hurt volumes for preventing unfair camping. (0: Disable)"); gCvars[CVAR_ANTICAMP] = CreateConVar("zr_anticamp", "1", "Enables or disables hurt volumes for preventing unfair camping. (0: Disable)");
gCvars[CVAR_ANTICAMP_UPDATE_INTERVAL] = CreateConVar("zr_anticamp_update_interval", "1", "How often to update player locations (in seconds)."); gCvars[CVAR_ANTICAMP_UPDATE_INTERVAL] = CreateConVar("zr_anticamp_update_interval", "1", "How often to update player locations (in seconds).");
gCvars[CVAR_ANTICAMP_ECHO] = CreateConVar("zr_anticamp_echo", "1", "Log kills done by anticamp to admin chat."); gCvars[CVAR_ANTICAMP_ECHO] = CreateConVar("zr_anticamp_echo", "1", "Log kills done by anticamp to admin chat.");

View File

@ -94,8 +94,7 @@ public Action:RoundEnd(Handle:event, const String:name[], bool:dontBroadcast)
zombieSpawned = false; zombieSpawned = false;
new maxplayers = GetMaxClients(); for (new x = 1; x<= MaxClients; x++)
for (new x = 1; x<= maxplayers; x++)
{ {
if (!IsClientInGame(x)) if (!IsClientInGame(x))
{ {
@ -150,11 +149,6 @@ public Action:PlayerSpawn(Handle:event, const String:name[], bool:dontBroadcast)
for (new x = 0; x < MAXTIMERS; x++) for (new x = 0; x < MAXTIMERS; x++)
{ {
if (x == TRESPAWN)
{
continue;
}
if (tHandles[index][x] != INVALID_HANDLE) if (tHandles[index][x] != INVALID_HANDLE)
{ {
KillTimer(tHandles[index][x]); KillTimer(tHandles[index][x]);
@ -169,6 +163,11 @@ public Action:PlayerSpawn(Handle:event, const String:name[], bool:dontBroadcast)
SetPlayerFOV(index, 90); SetPlayerFOV(index, 90);
ClientCommand(index, "r_screenoverlay \"\""); ClientCommand(index, "r_screenoverlay \"\"");
// Forward event to modules.
SpawnProtectOnClientSpawn(index);
RespawnOnClientSpawn(index);
ZHPOnClientSpawn(index);
// Stop here if client isn't on a team. // Stop here if client isn't on a team.
new team = GetClientTeam(index); new team = GetClientTeam(index);
if (team != CS_TEAM_T && team != CS_TEAM_CT) if (team != CS_TEAM_T && team != CS_TEAM_CT)
@ -202,7 +201,6 @@ public Action:PlayerSpawn(Handle:event, const String:name[], bool:dontBroadcast)
// Forward event to modules. // Forward event to modules.
ClassOnClientSpawn(index); ClassOnClientSpawn(index);
SpawnProtectPlayerSpawn(index);
ZTeleClientSpawned(index); ZTeleClientSpawned(index);
ZR_PrintToChat(index, "!zmenu reminder"); ZR_PrintToChat(index, "!zmenu reminder");
@ -227,7 +225,7 @@ public Action:PlayerHurt(Handle:event, const String:name[], bool:dontBroadcast)
if (IsPlayerHuman(index) && IsPlayerZombie(attacker)) if (IsPlayerHuman(index) && IsPlayerZombie(attacker))
{ {
// Check if spawn protection is disabled and the weapon is a knife. // Check if spawn protection is disabled and the weapon is a knife.
if (!pProtect[index] && StrEqual(weapon, "knife")) if (!pSpawnProtect[index] && StrEqual(weapon, "knife"))
{ {
InfectPlayer(index, attacker); InfectPlayer(index, attacker);
} }
@ -321,15 +319,8 @@ public Action:PlayerDeath(Handle:event, const String:name[], bool:dontBroadcast)
AddPlayerScore(attacker, bonus); AddPlayerScore(attacker, bonus);
} }
// Check if the player was killed by world damage. // Set gKilledByWorld to true if attacker is not a valid client.
if (!ZRIsValidClient(attacker)) gKilledByWorld[index] = !ZRIsValidClient(attacker);
{
gKilledByWorld[index] = true;
}
else
{
gKilledByWorld[index] = false;
}
} }
// Kill various timers. // Kill various timers.
@ -341,18 +332,13 @@ public Action:PlayerDeath(Handle:event, const String:name[], bool:dontBroadcast)
tHandles[index][x] = INVALID_HANDLE; tHandles[index][x] = INVALID_HANDLE;
} }
} }
// Create respawn timer if enabled.
new bool:respawn = GetConVarBool(gCvars[CVAR_RESPAWN]);
if (respawn)
{
new Float:delay = GetConVarFloat(gCvars[CVAR_RESPAWN_DELAY]);
tHandles[index][TRESPAWN] = CreateTimer(delay, RespawnTimer, index, TIMER_FLAG_NO_MAPCHANGE);
}
} }
// Forward event to modules. // Forward event to modules.
ClassOnClientDeath(index); ClassOnClientDeath(index);
SpawnProtectOnClientDeath(index);
RespawnOnClientDeath(index);
ZHPOnClientDeath(index);
new ZTeam:team = IsRoundOver(); new ZTeam:team = IsRoundOver();
RoundWin(team); RoundWin(team);

View File

@ -67,7 +67,7 @@ public MainMenuHandle(Handle:menu_main, MenuAction:action, client, slot)
} }
case 2: case 2:
{ {
if (!ZMarket(client)) if (!ZMarketSend(client))
{ {
MainMenu(client); MainMenu(client);
} }

View File

@ -21,8 +21,7 @@ ShowOverlays(Float:time, ZTeam:winner)
GetConVarString(gCvars[CVAR_OVERLAYS_ZOMBIE], overlay, sizeof(overlay)); GetConVarString(gCvars[CVAR_OVERLAYS_ZOMBIE], overlay, sizeof(overlay));
} }
new maxplayers = GetMaxClients(); for (new x = 1; x <= MaxClients; x++)
for (new x = 1; x <= maxplayers; x++)
{ {
if (IsClientInGame(x)) if (IsClientInGame(x))
{ {
@ -36,8 +35,7 @@ ShowOverlays(Float:time, ZTeam:winner)
public Action:KillOverlays(Handle:timer) public Action:KillOverlays(Handle:timer)
{ {
new maxplayers = GetMaxClients(); for (new x = 1; x <= MaxClients; x++)
for (new x = 1; x <= maxplayers; x++)
{ {
if (IsClientInGame(x)) if (IsClientInGame(x))
{ {

144
src/zr/respawn.inc Normal file
View File

@ -0,0 +1,144 @@
/*
* ============================================================================
*
* Zombie:Reloaded
*
* File: respawn.inc
* Description: Players come back to life
*
* ============================================================================
*/
/**
* Array for storing respawn timer handles per client.
*/
new Handle:tRespawn[MAXPLAYERS + 1];
/**
* Client is joining the server.
*/
RespawnClientInit(client)
{
// Reset timer handle.
tRespawn[client] = INVALID_HANDLE;
// Init gKilledByWorld for client.
gKilledByWorld[client] = false;
}
/**
* Client is spawning into the game.
*
* @param client The client index.
*/
RespawnOnClientSpawn(client)
{
// If timer is running, kill it.
if (tRespawn[client] != INVALID_HANDLE)
{
KillTimer(tRespawn[client]);
}
// Reset timer handle.
tRespawn[client] = INVALID_HANDLE;
}
/**
* Client has been killed.
*
* @param client The client index.
*/
RespawnOnClientDeath(client)
{
// If timer is running, kill it.
if (tRespawn[client] != INVALID_HANDLE)
{
KillTimer(tRespawn[client]);
}
// If respawn is disabled, stop here.
new bool:respawn = GetConVarBool(gCvars[CVAR_RESPAWN]);
if (!respawn)
{
return;
}
// Start respawn timer.
new Float:delay = GetConVarFloat(gCvars[CVAR_RESPAWN_DELAY]);
tRespawn[client] = CreateTimer(delay, RespawnTimer, client, TIMER_FLAG_NO_MAPCHANGE);
}
/**
* Spawns a player into the round.
*
* @param client The client index.
*/
RespawnSpawnClient(client)
{
// If client isn't in-game, then stop.
if (!IsClientInGame(client))
{
return;
}
// Spawn player.
CS_RespawnPlayer(client);
// Stop here if the first zombie hasn't spawned yet.
if (!zombieSpawned)
{
return;
}
// Get respawn team.
new bool:respawn_zombie = GetConVarBool(gCvars[CVAR_RESPAWN_ZOMBIE]);
// Get suicide respawn cvar
if (respawn_zombie)
{
InfectPlayer(client);
return;
}
if (GetConVarBool(gCvars[CVAR_SUICIDE_WORLD_DAMAGE]) && gKilledByWorld[client])
{
InfectPlayer(client);
gKilledByWorld[client] = false;
}
}
/**
* Timer callback, respawns a player.
*
* @param timer The timer handle.
* @param client The client index.
*/
public Action:RespawnTimer(Handle:timer, any:client)
{
// Reset timer handle.
tRespawn[client] = INVALID_HANDLE;
// If client isn't in-game, then stop.
if (!IsClientInGame(client))
{
return;
}
// If player isn't alive, then stop.
if (!IsPlayerAlive(client))
{
return;
}
// Get client team.
new team = GetClientTeam(client);
// If player isn't on a team, then stop.
if (team != CS_TEAM_T && team != CS_TEAM_CT)
{
return;
}
// Spawn player.
RespawnSpawnClient(client);
}

View File

@ -42,7 +42,8 @@ public Action:SayCommand(client, argc)
else if (StrEqual(args, "!zmarket", false)) else if (StrEqual(args, "!zmarket", false))
{ {
ZMarket(client); // Send market menu.
ZMarketSend(client);
} }
else if (StrEqual(args, "!zspawn", false)) else if (StrEqual(args, "!zspawn", false))
@ -78,66 +79,6 @@ public Action:SayCommand(client, argc)
return Plugin_Continue; return Plugin_Continue;
} }
/*bool:ZClass(client)
{
new bool:classes = GetConVarBool(gCvars[CVAR_CLASSES]);
if (!classes)
{
ZR_PrintToChat(client, "Feature is disabled");
return false;
}
new bool:randomclass = GetConVarBool(gCvars[CVAR_CLASSES_RANDOM]);
if (randomclass)
{
ZR_PrintToChat(client, "Random class is enabled");
return false;
}
ClassMenu(client);
return true;
}*/
bool:ZMarket(client)
{
if (!market)
{
ZR_PrintToChat(client, "Feature is disabled");
return false;
}
if (!IsPlayerAlive(client))
{
ZR_PrintToChat(client, "Must be alive");
return false;
}
new bool:buyzone = GetConVarBool(gCvars[CVAR_ZMARKET_BUYZONE]);
if (!IsClientInBuyZone(client) && buyzone)
{
ZR_PrintCenterText(client, "Market out of buyzone");
return false;
}
SetGlobalTransTarget(client);
decl String:title[64];
decl String:rebuy[64];
Format(title, sizeof(title), "%t\n ", "Market title");
Format(rebuy, sizeof(rebuy), "%t\n ", "Market rebuy");
Market_Send(client, title, rebuy);
return true;
}
ZSpawn(client) ZSpawn(client)
{ {
new bool:spawn = GetConVarBool(gCvars[CVAR_ZSPAWN]); new bool:spawn = GetConVarBool(gCvars[CVAR_ZSPAWN]);
@ -163,7 +104,7 @@ ZSpawn(client)
return; return;
} }
RespawnPlayer(client); RespawnSpawnClient(client);
AddPlayerToList(client); AddPlayerToList(client);
} }

View File

@ -36,15 +36,31 @@ SpawnProtectClientInit(client)
} }
/** /**
* Player is spawning into the game. * Client is spawning into the game.
* *
* @param client The client index. * @param client The client index.
*/ */
SpawnProtectPlayerSpawn(client) SpawnProtectOnClientSpawn(client)
{ {
// Disable spawn protection on client. // Disable spawn protection on client.
pSpawnProtect[client] = false; pSpawnProtect[client] = false;
// If timer is currently running, kill it.
if (tSpawnProtect[client] != INVALID_HANDLE)
{
KillTimer(tSpawnProtect[client]);
}
// Reset timer handle.
tSpawnProtect[client] = INVALID_HANDLE;
// If client isn't on a team, then stop.
new team = GetClientTeam(client);
if (team != CS_TEAM_T && team != CS_TEAM_CT)
{
return;
}
// If zombie hasn't spawned, then stop. // If zombie hasn't spawned, then stop.
if (!zombieSpawned) if (!zombieSpawned)
{ {
@ -58,13 +74,10 @@ SpawnProtectPlayerSpawn(client)
return; return;
} }
// Get respawn team. // If player respawns as human, and either cvar zr_suicide_world_damage or the client
decl String:respawnteam[32]; // wasn't killed by world is false, then continue on to protect client.
GetConVarString(gCvars[CVAR_RESPAWN_TEAM], respawnteam, sizeof(respawnteam)); new bool:respawn_zombie = GetConVarBool(gCvars[CVAR_RESPAWN_ZOMBIE]);
if (!respawn_zombie && !(GetConVarBool(gCvars[CVAR_SUICIDE_WORLD_DAMAGE]) && gKilledByWorld[client]))
// If the respawn team is not set to zombie, and either cvar zr_suicide_world_damage or the client
// wasn't killed by world is false, then continue to protect client.
if (!StrEqual(respawnteam, "zombie", false) && !(GetConVarBool(gCvars[CVAR_SUICIDE_WORLD_DAMAGE]) && gKilledByWorld[client]))
{ {
// Set spawn protect flag on client. // Set spawn protect flag on client.
pSpawnProtect[client] = true; pSpawnProtect[client] = true;
@ -83,15 +96,26 @@ SpawnProtectPlayerSpawn(client)
// Send time left in a hud message. // Send time left in a hud message.
ZR_HudHint(client, "Spawn Protect", pSpawnProtectTime[client]); ZR_HudHint(client, "Spawn Protect", pSpawnProtectTime[client]);
// If timer is currently running, kill it. // Start repeating timer.
tSpawnProtect[client] = CreateTimer(1.0, SpawnProtectTimer, client, TIMER_FLAG_NO_MAPCHANGE|TIMER_REPEAT);
}
}
/**
* Client has been killed.
*
* @param client The client index.
*/
SpawnProtectOnClientDeath(client)
{
// If timer is running, kill it.
if (tSpawnProtect[client] != INVALID_HANDLE) if (tSpawnProtect[client] != INVALID_HANDLE)
{ {
KillTimer(tSpawnProtect[client]); KillTimer(tSpawnProtect[client]);
} }
// Start repeating timer. // Reset timer handle.
tSpawnProtect[client] = CreateTimer(1.0, SpawnProtectTimer, client, TIMER_FLAG_NO_MAPCHANGE|TIMER_REPEAT); tSpawnProtect[client] = INVALID_HANDLE;
}
} }
/** /**

View File

@ -41,8 +41,7 @@ stock ZR_PrintToChat(client, any:...)
PrintToServer(phrase); PrintToServer(phrase);
new maxplayers = GetMaxClients(); for (new x = 1; x <= MaxClients; x++)
for (new x = 1; x <= maxplayers; x++)
{ {
if (IsClientInGame(x)) if (IsClientInGame(x))
{ {

View File

@ -6,6 +6,55 @@
* ==================== * ====================
*/ */
/**
* Sends market menu to client.
*
* @param client The client index.
*/
bool:ZMarketSend(client)
{
// If market is disabled, then stop.
if (!market)
{
// Tell client market is disabled.
ZR_PrintToChat(client, "Feature is disabled");
return false;
}
// If player is dead, then stop.
if (!IsPlayerAlive(client))
{
// Tell player they must be alive.
ZR_PrintToChat(client, "Must be alive");
return false;
}
// Check buyzone cvar to see if client has to be in a buyzone to use.
new bool:buyzone = GetConVarBool(gCvars[CVAR_ZMARKET_BUYZONE]);
if (!IsClientInBuyZone(client) && buyzone)
{
// Tell client they must be in a buyzone.
ZR_PrintCenterText(client, "Market out of buyzone");
return false;
}
// Set translate target to client.
SetGlobalTransTarget(client);
// Format title and rebuy lines.
decl String:title[64];
decl String:rebuy[64];
Format(title, sizeof(title), "%t\n ", "Market title");
Format(rebuy, sizeof(rebuy), "%t\n ", "Market rebuy");
// Send market menu.
Market_Send(client, title, rebuy);
// Successfully sent the market menu.
return true;
}
/** /**
* (Market) Forward called when a client selects a weapon from the market. * (Market) Forward called when a client selects a weapon from the market.
* *
@ -83,5 +132,5 @@ public Market_PostOnWeaponSelected(client, &bool:allowed)
} }
// Resend market menu. // Resend market menu.
ZMarket(client); ZMarketSend(client);
} }

View File

@ -37,6 +37,40 @@ ZHPClientInit(client)
tZHP[client] = INVALID_HANDLE; tZHP[client] = INVALID_HANDLE;
} }
/**
* Client is spawning into the game.
*
* @param client The client index.
*/
ZHPOnClientSpawn(client)
{
// If timer is running, kill it.
if (tZHP[client] != INVALID_HANDLE)
{
KillTimer(tZHP[client]);
}
// Reset timer handle.
tZHP[client] = INVALID_HANDLE;
}
/**
* Client has been killed.
*
* @param client The client index.
*/
ZHPOnClientDeath(client)
{
// If timer is running, kill it.
if (tZHP[client] != INVALID_HANDLE)
{
KillTimer(tZHP[client]);
}
// Reset timer handle.
tZHP[client] = INVALID_HANDLE;
}
/** /**
* Toggle ZHP on a client. * Toggle ZHP on a client.
* *

View File

@ -46,7 +46,6 @@ public Action:Command_NightVision(client, argc)
return; return;
} }
//bZVisionOn[client] = !bZVisionOn[client];
bClientOverlayOn[client] = !bClientOverlayOn[client]; bClientOverlayOn[client] = !bClientOverlayOn[client];
decl String:overlay[256]; decl String:overlay[256];
@ -379,8 +378,7 @@ PlayerLeft(client)
new Handle:aClients = CreateArray(); new Handle:aClients = CreateArray();
new maxplayers = GetMaxClients(); for (new x = 1; x <= MaxClients; x++)
for (new x = 1; x <= maxplayers; x++)
{ {
if (!IsClientInGame(x) || !IsPlayerAlive(x) || client == x || GetClientTeam(x) != CS_TEAM_CT || gBlockMotherInfect[x]) if (!IsClientInGame(x) || !IsPlayerAlive(x) || client == x || GetClientTeam(x) != CS_TEAM_CT || gBlockMotherInfect[x])
{ {
@ -408,8 +406,7 @@ GetZTeamCount(ZTeam:team)
{ {
new count = 0; new count = 0;
new maxplayers = GetMaxClients(); for (new x = 1; x <= MaxClients; x++)
for (new x = 1; x <= maxplayers; x++)
{ {
if (!IsClientInGame(x) || !IsPlayerAlive(x)) if (!IsClientInGame(x) || !IsPlayerAlive(x))
{ {
@ -431,8 +428,7 @@ ZTeam:IsRoundOver()
new bool:zombies = false; new bool:zombies = false;
new bool:humans = false; new bool:humans = false;
new maxplayers = GetMaxClients(); for (new x = 1; x <= MaxClients; x++)
for (new x = 1; x <= maxplayers; x++)
{ {
if (!IsClientInGame(x) || !IsPlayerAlive(x)) if (!IsClientInGame(x) || !IsPlayerAlive(x))
{ {
@ -482,8 +478,7 @@ BalanceTeams()
new count = 0; new count = 0;
new cPlayers[MAXPLAYERS]; new cPlayers[MAXPLAYERS];
new maxplayers = GetMaxClients(); for (new x = 1; x <= MaxClients; x++)
for (new x = 1; x <= maxplayers; x++)
{ {
if (!IsClientInGame(x) || GetClientTeam(x) <= 1) if (!IsClientInGame(x) || GetClientTeam(x) <= 1)
{ {
@ -554,50 +549,6 @@ public Action:ZombieMoanTimer(Handle:timer, any:index)
return Plugin_Continue; return Plugin_Continue;
} }
RespawnPlayer(client)
{
if (!IsClientInGame(client))
{
return;
}
CS_RespawnPlayer(client);
if (!zombieSpawned)
{
return;
}
decl String:team[32];
GetConVarString(gCvars[CVAR_RESPAWN_TEAM], team, sizeof(team));
if (StrEqual(team, "zombie", false))
{
InfectPlayer(client);
return;
}
if (GetConVarBool(gCvars[CVAR_SUICIDE_WORLD_DAMAGE]) && gKilledByWorld[client])
{
InfectPlayer(client);
gKilledByWorld[client] = false;
}
}
public Action:RespawnTimer(Handle:timer, any:index)
{
new team = GetClientTeam(index);
if (!IsClientInGame(index) || IsPlayerAlive(index) || team != CS_TEAM_T && team != CS_TEAM_CT)
{
tHandles[index][TRESPAWN] = INVALID_HANDLE;
return;
}
RespawnPlayer(index);
tHandles[index][TRESPAWN] = INVALID_HANDLE;
}
public Action:RoundOver(Handle:timer) public Action:RoundOver(Handle:timer)
{ {
tRound = INVALID_HANDLE; tRound = INVALID_HANDLE;

View File

@ -70,11 +70,7 @@ new bool:zombieSpawned;
new bool:motherZombie[MAXPLAYERS + 1]; new bool:motherZombie[MAXPLAYERS + 1];
new bool:gZombie[MAXPLAYERS + 1]; new bool:gZombie[MAXPLAYERS + 1];
new bool:gBlockMotherInfect[MAXPLAYERS + 1]; new bool:gBlockMotherInfect[MAXPLAYERS + 1];
new bool:bZVision[MAXPLAYERS + 1]; new bool:gKilledByWorld[MAXPLAYERS + 1];
//new bool:bZVisionOn[MAXPLAYERS + 1];
//new String:ZVisionOverlay[MAXPLAYERS + 1][PLATFORM_MAX_PATH];
new bool:pProtect[MAXPLAYERS + 1];
new bool:gKilledByWorld[MAXPLAYERS + 1] = {false, ...};
new Float:spawnLoc[MAXPLAYERS + 1][3]; new Float:spawnLoc[MAXPLAYERS + 1][3];
new Float:bufferLoc[MAXPLAYERS + 1][3]; new Float:bufferLoc[MAXPLAYERS + 1][3];
@ -92,13 +88,10 @@ new Handle:tInfect = INVALID_HANDLE;
new Handle:pList = INVALID_HANDLE; new Handle:pList = INVALID_HANDLE;
#define MAXTIMERS 5 #define MAXTIMERS 2
#define TMOAN 0 #define TMOAN 0
#define TREGEN 1 #define TTELE 1
#define TTELE 2
#define TRESPAWN 3
#define TZVISION 4
new Handle:tHandles[MAXPLAYERS + 1][MAXTIMERS]; new Handle:tHandles[MAXPLAYERS + 1][MAXTIMERS];
@ -178,8 +171,7 @@ RefreshList()
pList = CreateArray(); pList = CreateArray();
new maxplayers = GetMaxClients(); for (new x = 1; x <= MaxClients; x++)
for (new x = 1; x <= maxplayers; x++)
{ {
if (IsClientInGame(x) && IsPlayerAlive(x)) if (IsClientInGame(x) && IsPlayerAlive(x))
{ {