Format everything

This commit is contained in:
zaCade 2019-03-17 15:10:27 +01:00
parent 9a2e8b4eb7
commit 7e10e6f019
16 changed files with 391 additions and 403 deletions

View File

@ -17,13 +17,13 @@ LoadAmbienceData()
{ {
return; return;
} }
decl String:sound[64]; decl String:sound[64];
GetConVarString(gCvars[CVAR_AMBIENCE_FILE], sound, sizeof(sound)); GetConVarString(gCvars[CVAR_AMBIENCE_FILE], sound, sizeof(sound));
Format(sound, sizeof(sound), "sound/%s", sound); Format(sound, sizeof(sound), "sound/%s", sound);
soundValid = FileExists(sound, true); soundValid = FileExists(sound, true);
if (soundValid) if (soundValid)
{ {
AddFileToDownloadsTable(sound); AddFileToDownloadsTable(sound);
@ -40,24 +40,24 @@ RestartAmbience()
{ {
CloseHandle(tAmbience); CloseHandle(tAmbience);
} }
CreateTimer(0.0, AmbienceLoop, _, TIMER_FLAG_NO_MAPCHANGE); CreateTimer(0.0, AmbienceLoop, _, TIMER_FLAG_NO_MAPCHANGE);
} }
public Action:AmbienceLoop(Handle:timer) public Action:AmbienceLoop(Handle:timer)
{ {
new bool:ambience = GetConVarBool(gCvars[CVAR_AMBIENCE]); new bool:ambience = GetConVarBool(gCvars[CVAR_AMBIENCE]);
if (!ambience || !soundValid) if (!ambience || !soundValid)
{ {
return; return;
} }
decl String:sound[64]; decl String:sound[64];
GetConVarString(gCvars[CVAR_AMBIENCE_FILE], sound, sizeof(sound)); GetConVarString(gCvars[CVAR_AMBIENCE_FILE], sound, sizeof(sound));
EmitAmbience(sound); EmitAmbience(sound);
new Float:delay = GetConVarFloat(gCvars[CVAR_AMBIENCE_LENGTH]); new Float:delay = GetConVarFloat(gCvars[CVAR_AMBIENCE_LENGTH]);
tAmbience = CreateTimer(delay, AmbienceLoop, _, TIMER_FLAG_NO_MAPCHANGE); tAmbience = CreateTimer(delay, AmbienceLoop, _, TIMER_FLAG_NO_MAPCHANGE);
} }
@ -65,15 +65,15 @@ public Action:AmbienceLoop(Handle:timer)
StopAmbience() StopAmbience()
{ {
new bool:ambience = GetConVarBool(gCvars[CVAR_AMBIENCE]); new bool:ambience = GetConVarBool(gCvars[CVAR_AMBIENCE]);
if (!ambience) if (!ambience)
{ {
return; return;
} }
decl String:sound[64]; decl String:sound[64];
GetConVarString(gCvars[CVAR_AMBIENCE_FILE], sound, sizeof(sound)); GetConVarString(gCvars[CVAR_AMBIENCE_FILE], sound, sizeof(sound));
new maxplayers = GetMaxClients(); new maxplayers = GetMaxClients();
for (new x = 1; x <= maxplayers; x++) for (new x = 1; x <= maxplayers; x++)
{ {
@ -81,7 +81,7 @@ StopAmbience()
{ {
continue; continue;
} }
StopSound(x, SNDCHAN_AUTO, sound); StopSound(x, SNDCHAN_AUTO, sound);
} }
} }
@ -89,9 +89,9 @@ StopAmbience()
EmitAmbience(const String:sound[]) EmitAmbience(const String:sound[])
{ {
PrecacheSound(sound); PrecacheSound(sound);
StopAmbience(); StopAmbience();
new Float:volume = GetConVarFloat(gCvars[CVAR_AMBIENCE_VOLUME]); new Float:volume = GetConVarFloat(gCvars[CVAR_AMBIENCE_VOLUME]);
EmitSoundToAll(sound, SOUND_FROM_PLAYER, SNDCHAN_AUTO, SNDLEVEL_NORMAL, SND_NOFLAGS, volume, SNDPITCH_NORMAL, -1, NULL_VECTOR, NULL_VECTOR, true, 0.0); EmitSoundToAll(sound, SOUND_FROM_PLAYER, SNDCHAN_AUTO, SNDLEVEL_NORMAL, SND_NOFLAGS, volume, SNDPITCH_NORMAL, -1, NULL_VECTOR, NULL_VECTOR, true, 0.0);
} }

View File

@ -5,18 +5,18 @@
* Author: Greyscale * Author: Greyscale
* ==================== * ====================
*/ */
CreateCommands() CreateCommands()
{ {
RegAdminCmd("zriot_restrict", Command_Restrict, ADMFLAG_GENERIC, "Restrict a specified weapon"); RegAdminCmd("zriot_restrict", Command_Restrict, ADMFLAG_GENERIC, "Restrict a specified weapon");
RegAdminCmd("zriot_unrestrict", Command_UnRestrict, ADMFLAG_GENERIC, "Unrestrict a specified weapon"); RegAdminCmd("zriot_unrestrict", Command_UnRestrict, ADMFLAG_GENERIC, "Unrestrict a specified weapon");
RegAdminCmd("zriot_setday", Command_SetDay, ADMFLAG_GENERIC, "Sets the game to a certain day"); RegAdminCmd("zriot_setday", Command_SetDay, ADMFLAG_GENERIC, "Sets the game to a certain day");
RegAdminCmd("zriot_zombie", Command_Zombie, ADMFLAG_GENERIC, "Turns player into zombie"); RegAdminCmd("zriot_zombie", Command_Zombie, ADMFLAG_GENERIC, "Turns player into zombie");
RegAdminCmd("zriot_human", Command_Human, ADMFLAG_GENERIC, "Turns player into human"); RegAdminCmd("zriot_human", Command_Human, ADMFLAG_GENERIC, "Turns player into human");
} }
public Action:Command_Restrict(client, argc) public Action:Command_Restrict(client, argc)
{ {
new bool:enabled = GetConVarBool(gCvars[CVAR_ENABLE]); new bool:enabled = GetConVarBool(gCvars[CVAR_ENABLE]);
@ -24,17 +24,17 @@ public Action:Command_Restrict(client, argc)
{ {
return Plugin_Handled; return Plugin_Handled;
} }
decl String:arg1[32]; decl String:arg1[32];
GetCmdArg(1, arg1, sizeof(arg1)); GetCmdArg(1, arg1, sizeof(arg1));
new WepRestrictQuery:output = RestrictWeapon(arg1); new WepRestrictQuery:output = RestrictWeapon(arg1);
if (output == Existing) if (output == Existing)
{ {
ZRiot_ReplyToCommand(client, "Weapon already restricted", arg1); ZRiot_ReplyToCommand(client, "Weapon already restricted", arg1);
} }
return Plugin_Handled; return Plugin_Handled;
} }
@ -45,17 +45,17 @@ public Action:Command_UnRestrict(client, argc)
{ {
return Plugin_Handled; return Plugin_Handled;
} }
decl String:arg1[32]; decl String:arg1[32];
GetCmdArg(1, arg1, sizeof(arg1)); GetCmdArg(1, arg1, sizeof(arg1));
new WepRestrictQuery:output = UnRestrictWeapon(arg1); new WepRestrictQuery:output = UnRestrictWeapon(arg1);
if (output == Invalid) if (output == Invalid)
{ {
ZRiot_ReplyToCommand(client, "Weapon invalid", arg1); ZRiot_ReplyToCommand(client, "Weapon invalid", arg1);
} }
return Plugin_Handled; return Plugin_Handled;
} }
@ -66,25 +66,25 @@ public Action:Command_SetDay(client, argc)
{ {
return Plugin_Handled; return Plugin_Handled;
} }
decl String:arg1[32]; decl String:arg1[32];
GetCmdArg(1, arg1, sizeof(arg1)); GetCmdArg(1, arg1, sizeof(arg1));
new day = StringToInt(arg1) - 1; new day = StringToInt(arg1) - 1;
day = (day >= 0) ? day : 0; day = (day >= 0) ? day : 0;
gDay = day; gDay = day;
gDay = (gDay + 1 > dCount) ? dCount - 1 : gDay; gDay = (gDay + 1 > dCount) ? dCount - 1 : gDay;
ZRiot_PrintToChat(0, "Skip to day", gDay + 1); ZRiot_PrintToChat(0, "Skip to day", gDay + 1);
if (tHUD == INVALID_HANDLE) if (tHUD == INVALID_HANDLE)
{ {
return Plugin_Handled; return Plugin_Handled;
} }
TerminateRound(3.0, Round_Draw); TerminateRound(3.0, Round_Draw);
return Plugin_Handled; return Plugin_Handled;
} }
@ -95,31 +95,31 @@ public Action:Command_Zombie(client, argc)
{ {
return Plugin_Handled; return Plugin_Handled;
} }
decl String:arg1[32]; decl String:arg1[32];
GetCmdArg(1, arg1, sizeof(arg1)); GetCmdArg(1, arg1, sizeof(arg1));
decl String:target_name[MAX_TARGET_LENGTH]; decl String:target_name[MAX_TARGET_LENGTH];
new targets[MAXPLAYERS]; new targets[MAXPLAYERS];
new bool:tn_is_ml; new bool:tn_is_ml;
new tcount = ProcessTargetString(arg1, client, targets, MAXPLAYERS, COMMAND_FILTER_NO_BOTS, target_name, sizeof(target_name), tn_is_ml); new tcount = ProcessTargetString(arg1, client, targets, MAXPLAYERS, COMMAND_FILTER_NO_BOTS, target_name, sizeof(target_name), tn_is_ml);
if (tcount <= 0) if (tcount <= 0)
{ {
ReplyToTargetError(client, tcount); ReplyToTargetError(client, tcount);
return Plugin_Handled; return Plugin_Handled;
} }
for (new x = 0; x < tcount; x++) for (new x = 0; x < tcount; x++)
{ {
ZRiot_Zombie(targets[x]); ZRiot_Zombie(targets[x]);
} }
if (GetLiveHumanCount() <= 0) if (GetLiveHumanCount() <= 0)
{ {
TerminateRound(5.0, Terrorists_Win); TerminateRound(5.0, Terrorists_Win);
} }
return Plugin_Handled; return Plugin_Handled;
} }
@ -130,25 +130,25 @@ public Action:Command_Human(client, argc)
{ {
return Plugin_Handled; return Plugin_Handled;
} }
decl String:arg1[32]; decl String:arg1[32];
GetCmdArg(1, arg1, sizeof(arg1)); GetCmdArg(1, arg1, sizeof(arg1));
decl String:target_name[MAX_TARGET_LENGTH]; decl String:target_name[MAX_TARGET_LENGTH];
new targets[MAXPLAYERS]; new targets[MAXPLAYERS];
new bool:tn_is_ml; new bool:tn_is_ml;
new tcount = ProcessTargetString(arg1, client, targets, MAXPLAYERS, COMMAND_FILTER_NO_BOTS, target_name, sizeof(target_name), tn_is_ml); new tcount = ProcessTargetString(arg1, client, targets, MAXPLAYERS, COMMAND_FILTER_NO_BOTS, target_name, sizeof(target_name), tn_is_ml);
if (tcount <= 0) if (tcount <= 0)
{ {
ReplyToTargetError(client, tcount); ReplyToTargetError(client, tcount);
return Plugin_Handled; return Plugin_Handled;
} }
for (new x = 0; x < tcount; x++) for (new x = 0; x < tcount; x++)
{ {
ZRiot_Human(targets[x]); ZRiot_Human(targets[x]);
} }
return Plugin_Handled; return Plugin_Handled;
} }

View File

@ -76,9 +76,9 @@ CreateCvars()
gCvars[CVAR_ZMARKET_BUYZONE] = CreateConVar("zriot_zmarket_buyzone", "0", "Must be in buyzone to access !zmarket, if Market is installed (0: Can be used anywhere)"); gCvars[CVAR_ZMARKET_BUYZONE] = CreateConVar("zriot_zmarket_buyzone", "0", "Must be in buyzone to access !zmarket, if Market is installed (0: Can be used anywhere)");
gCvars[CVAR_CASHFILL] = CreateConVar("zriot_cashfill", "1", "Enable the mod to set the players cash to zriot_cashamount (0: Disabled)"); gCvars[CVAR_CASHFILL] = CreateConVar("zriot_cashfill", "1", "Enable the mod to set the players cash to zriot_cashamount (0: Disabled)");
gCvars[CVAR_CASHAMOUNT] = CreateConVar("zriot_cashamount", "12000", "How much money players will have when they spawn when zriot_cashfill is 1"); gCvars[CVAR_CASHAMOUNT] = CreateConVar("zriot_cashamount", "12000", "How much money players will have when they spawn when zriot_cashfill is 1");
HookConVarChange(gCvars[CVAR_ENABLE], EnableHook); HookConVarChange(gCvars[CVAR_ENABLE], EnableHook);
AutoExecConfig(true, "zombieriot", "sourcemod/zombieriot"); AutoExecConfig(true, "zombieriot", "sourcemod/zombieriot");
} }
@ -86,12 +86,12 @@ HookCvars()
{ {
SetConVarBool(FindConVar("mp_autoteambalance"), false); SetConVarBool(FindConVar("mp_autoteambalance"), false);
SetConVarInt(FindConVar("mp_limitteams"), 0); SetConVarInt(FindConVar("mp_limitteams"), 0);
HookConVarChange(FindConVar("mp_autoteambalance"), AutoTeamBalanceHook); HookConVarChange(FindConVar("mp_autoteambalance"), AutoTeamBalanceHook);
HookConVarChange(FindConVar("mp_limitteams"), LimitTeamsHook); HookConVarChange(FindConVar("mp_limitteams"), LimitTeamsHook);
HookConVarChange(gCvars[CVAR_ZOMBIETEAM], ZombieTeamHook); HookConVarChange(gCvars[CVAR_ZOMBIETEAM], ZombieTeamHook);
HookConVarChange(FindConVar("mp_restartgame"), RestartGameHook); HookConVarChange(FindConVar("mp_restartgame"), RestartGameHook);
} }
@ -99,30 +99,30 @@ UnhookCvars()
{ {
UnhookConVarChange(FindConVar("mp_autoteambalance"), AutoTeamBalanceHook); UnhookConVarChange(FindConVar("mp_autoteambalance"), AutoTeamBalanceHook);
UnhookConVarChange(FindConVar("mp_limitteams"), LimitTeamsHook); UnhookConVarChange(FindConVar("mp_limitteams"), LimitTeamsHook);
UnhookConVarChange(gCvars[CVAR_ZOMBIETEAM], ZombieTeamHook); UnhookConVarChange(gCvars[CVAR_ZOMBIETEAM], ZombieTeamHook);
UnhookConVarChange(FindConVar("mp_restartgame"), RestartGameHook); UnhookConVarChange(FindConVar("mp_restartgame"), RestartGameHook);
} }
public EnableHook(Handle:convar, const String:oldValue[], const String:newValue[]) public EnableHook(Handle:convar, const String:oldValue[], const String:newValue[])
{ {
new bool:enable = bool:StringToInt(newValue); new bool:enable = bool:StringToInt(newValue);
if (enable) if (enable)
{ {
FindMapSky(); FindMapSky();
FindHostname(); FindHostname();
UpdateHostname(); UpdateHostname();
HookEvents(); HookEvents();
HookCvars(); HookCvars();
ServerCommand("bot_kick"); ServerCommand("bot_kick");
gDay = 0; gDay = 0;
TerminateRound(3.0, Game_Commencing); TerminateRound(3.0, Game_Commencing);
} }
else else
@ -152,6 +152,6 @@ public ZombieTeamHook(Handle:convar, const String:oldValue[], const String:newVa
public RestartGameHook(Handle:convar, const String:oldValue[], const String:newValue[]) public RestartGameHook(Handle:convar, const String:oldValue[], const String:newValue[])
{ {
gDay = 0; gDay = 0;
ResetZombies(true); ResetZombies(true);
} }

View File

@ -30,54 +30,54 @@ LoadDayData(bool:defaultconfig)
{ {
decl String:path[PLATFORM_MAX_PATH]; decl String:path[PLATFORM_MAX_PATH];
Format(path, sizeof(path), "%s/days.txt", gMapConfig); Format(path, sizeof(path), "%s/days.txt", gMapConfig);
if (!defaultconfig && !FileExists(path)) if (!defaultconfig && !FileExists(path))
{ {
return; return;
} }
if (kvDays != INVALID_HANDLE) if (kvDays != INVALID_HANDLE)
{ {
CloseHandle(kvDays); CloseHandle(kvDays);
} }
kvDays = CreateKeyValues("days"); kvDays = CreateKeyValues("days");
KvSetEscapeSequences(kvDays, true); KvSetEscapeSequences(kvDays, true);
if (!FileToKeyValues(kvDays, path)) if (!FileToKeyValues(kvDays, path))
{ {
SetFailState("\"%s\" failed to load", path); SetFailState("\"%s\" failed to load", path);
} }
KvRewind(kvDays); KvRewind(kvDays);
if (!KvGotoFirstSubKey(kvDays)) if (!KvGotoFirstSubKey(kvDays))
{ {
SetFailState("No day data defined in \"%s\"", path); SetFailState("No day data defined in \"%s\"", path);
} }
decl String:display[32]; decl String:display[32];
decl String:zombieoverride[32*MAXZOMBIES]; decl String:zombieoverride[32*MAXZOMBIES];
decl String:storyline[192]; decl String:storyline[192];
dCount = 0; dCount = 0;
do do
{ {
KvGetSectionName(kvDays, display, sizeof(display)); KvGetSectionName(kvDays, display, sizeof(display));
strcopy(arrayDays[dCount][data_display], 32, display); strcopy(arrayDays[dCount][data_display], 32, display);
KvGetString(kvDays, "zombieoverride", zombieoverride, sizeof(zombieoverride)); KvGetString(kvDays, "zombieoverride", zombieoverride, sizeof(zombieoverride));
strcopy(arrayDays[dCount][data_zombieoverride], 32*MAXZOMBIES, zombieoverride); strcopy(arrayDays[dCount][data_zombieoverride], 32*MAXZOMBIES, zombieoverride);
KvGetString(kvDays, "storyline", storyline, sizeof(storyline)); KvGetString(kvDays, "storyline", storyline, sizeof(storyline));
strcopy(arrayDays[dCount][data_storyline], 192, storyline); strcopy(arrayDays[dCount][data_storyline], 192, storyline);
arrayDays[dCount][data_count] = KvGetNum(kvDays, "count", 25); arrayDays[dCount][data_count] = KvGetNum(kvDays, "count", 25);
arrayDays[dCount][data_healthboost] = KvGetNum(kvDays, "healthboost"); arrayDays[dCount][data_healthboost] = KvGetNum(kvDays, "healthboost");
arrayDays[dCount][data_respawn] = bool:KvGetNum(kvDays, "respawn"); arrayDays[dCount][data_respawn] = bool:KvGetNum(kvDays, "respawn");
arrayDays[dCount][data_deaths_before_zombie] = KvGetNum(kvDays, "deaths_before_zombie"); arrayDays[dCount][data_deaths_before_zombie] = KvGetNum(kvDays, "deaths_before_zombie");
arrayDays[dCount][data_fademin] = KvGetFloat(kvDays, "fademin"); arrayDays[dCount][data_fademin] = KvGetFloat(kvDays, "fademin");
arrayDays[dCount][data_fademax] = KvGetFloat(kvDays, "fademax"); arrayDays[dCount][data_fademax] = KvGetFloat(kvDays, "fademax");
dCount++; dCount++;
} while (KvGotoNextKey(kvDays)); } while (KvGotoNextKey(kvDays));
} }
@ -94,34 +94,34 @@ bool:ExplodeZombieOverrides(day)
CloseHandle(adtZombies); CloseHandle(adtZombies);
adtZombies = INVALID_HANDLE; adtZombies = INVALID_HANDLE;
} }
decl String:zombieoverride[32*MAXZOMBIES]; decl String:zombieoverride[32*MAXZOMBIES];
GetDayZombieOverride(day, zombieoverride, sizeof(zombieoverride)); GetDayZombieOverride(day, zombieoverride, sizeof(zombieoverride));
if (zombieoverride[0]) if (zombieoverride[0])
{ {
adtZombies = CreateArray(); adtZombies = CreateArray();
new String:sZombies[MAXZOMBIES][64]; new String:sZombies[MAXZOMBIES][64];
ExplodeString(zombieoverride, ",", sZombies, MAXZOMBIES, 64); ExplodeString(zombieoverride, ",", sZombies, MAXZOMBIES, 64);
for (new x = 0; x < MAXZOMBIES; x++) for (new x = 0; x < MAXZOMBIES; x++)
{ {
if (!sZombies[x][0]) if (!sZombies[x][0])
continue; continue;
TrimString(sZombies[x]); TrimString(sZombies[x]);
new zombieid = FindZombieIDByName(sZombies[x]); new zombieid = FindZombieIDByName(sZombies[x]);
if (zombieid == -1) if (zombieid == -1)
continue; continue;
PushArrayCell(adtZombies, zombieid); PushArrayCell(adtZombies, zombieid);
} }
return true; return true;
} }
return false; return false;
} }
@ -168,13 +168,13 @@ Float:GetDayMaxFade(day)
BeginDay() BeginDay()
{ {
gZombiesKilled = 0; gZombiesKilled = 0;
new zombiecount = GetDayCount(gDay); new zombiecount = GetDayCount(gDay);
new zombiemax = GetConVarInt(gCvars[CVAR_ZOMBIEMAX]); new zombiemax = GetConVarInt(gCvars[CVAR_ZOMBIEMAX]);
new spawncount; new spawncount;
new bool:respawn = GetDayRespawn(gDay); new bool:respawn = GetDayRespawn(gDay);
if (respawn) if (respawn)
{ {
spawncount = zombiemax; spawncount = zombiemax;
@ -183,14 +183,14 @@ BeginDay()
{ {
spawncount = (zombiecount < zombiemax) ? zombiecount : zombiemax; spawncount = (zombiecount < zombiemax) ? zombiecount : zombiemax;
} }
ServerCommand("bot_quota %d", spawncount); ServerCommand("bot_quota %d", spawncount);
decl String:display[32]; decl String:display[32];
GetDayDisplay(gDay, display, sizeof(display)); GetDayDisplay(gDay, display, sizeof(display));
new bool:override = ExplodeZombieOverrides(gDay); new bool:override = ExplodeZombieOverrides(gDay);
new maxplayers = GetMaxClients(); new maxplayers = GetMaxClients();
for (new x = 1; x <= maxplayers; x++) for (new x = 1; x <= maxplayers; x++)
{ {
@ -198,21 +198,21 @@ BeginDay()
{ {
continue; continue;
} }
ChangeClientDeathCount(x, 0); ChangeClientDeathCount(x, 0);
if (!IsPlayerZombie(x)) if (!IsPlayerZombie(x))
{ {
continue; continue;
} }
if (override) if (override)
{ {
new size = GetArraySize(adtZombies); new size = GetArraySize(adtZombies);
if (size) if (size)
{ {
new zombieid = GetRandomInt(0, size - 1); new zombieid = GetRandomInt(0, size - 1);
Zombify(x, GetArrayCell(adtZombies, zombieid)); Zombify(x, GetArrayCell(adtZombies, zombieid));
} }
} }

View File

@ -42,32 +42,32 @@ public Action:PlayerConnect(Handle:event, const String:name[], bool:dontBroadcas
new bool:botquota_silent = GetConVarBool(gCvars[CVAR_BOTQUOTA_SILENT]); new bool:botquota_silent = GetConVarBool(gCvars[CVAR_BOTQUOTA_SILENT]);
if (!botquota_silent) if (!botquota_silent)
return Plugin_Continue; return Plugin_Continue;
decl String:address[64]; decl String:address[64];
GetEventString(event, "address", address, sizeof(address)); GetEventString(event, "address", address, sizeof(address));
if (pcFire && StrEqual(address, "none")) if (pcFire && StrEqual(address, "none"))
{ {
decl String:pname[64]; decl String:pname[64];
decl String:networkid[64]; decl String:networkid[64];
GetEventString(event, "name", pname, sizeof(pname)); GetEventString(event, "name", pname, sizeof(pname));
GetEventString(event, "networkid", networkid, sizeof(networkid)); GetEventString(event, "networkid", networkid, sizeof(networkid));
new Handle:hPlayerConnect = CreateEvent("player_connect", true); new Handle:hPlayerConnect = CreateEvent("player_connect", true);
SetEventString(hPlayerConnect, "name", pname); SetEventString(hPlayerConnect, "name", pname);
SetEventInt(hPlayerConnect, "index", GetEventInt(event, "index")); SetEventInt(hPlayerConnect, "index", GetEventInt(event, "index"));
SetEventInt(hPlayerConnect, "userid", GetEventInt(event, "userid")); SetEventInt(hPlayerConnect, "userid", GetEventInt(event, "userid"));
SetEventString(hPlayerConnect, "networkid", networkid); SetEventString(hPlayerConnect, "networkid", networkid);
SetEventString(hPlayerConnect, "address", address); SetEventString(hPlayerConnect, "address", address);
pcFire = false; pcFire = false;
FireEvent(hPlayerConnect, true); FireEvent(hPlayerConnect, true);
pcFire = true; pcFire = true;
return Plugin_Handled; return Plugin_Handled;
} }
return Plugin_Continue; return Plugin_Continue;
} }
@ -77,78 +77,78 @@ public Action:PlayerDisconnect(Handle:event, const String:name[], bool:dontBroad
new bool:botquota_silent = GetConVarBool(gCvars[CVAR_BOTQUOTA_SILENT]); new bool:botquota_silent = GetConVarBool(gCvars[CVAR_BOTQUOTA_SILENT]);
if (!botquota_silent) if (!botquota_silent)
return Plugin_Continue; return Plugin_Continue;
new userid = GetEventInt(event, "userid"); new userid = GetEventInt(event, "userid");
new index = GetClientOfUserId(userid); new index = GetClientOfUserId(userid);
if (!index || !IsClientInGame(index)) if (!index || !IsClientInGame(index))
return Plugin_Continue; return Plugin_Continue;
if (pdFire && IsFakeClient(index)) if (pdFire && IsFakeClient(index))
{ {
decl String:reason[192]; decl String:reason[192];
decl String:pname[64]; decl String:pname[64];
decl String:networkid[64]; decl String:networkid[64];
GetEventString(event, "reason", reason, sizeof(reason)); GetEventString(event, "reason", reason, sizeof(reason));
GetEventString(event, "name", pname, sizeof(pname)); GetEventString(event, "name", pname, sizeof(pname));
GetEventString(event, "networkid", networkid, sizeof(networkid)); GetEventString(event, "networkid", networkid, sizeof(networkid));
new Handle:hPlayerDisconnect = CreateEvent("player_disconnect", true); new Handle:hPlayerDisconnect = CreateEvent("player_disconnect", true);
SetEventInt(hPlayerDisconnect, "userid", userid); SetEventInt(hPlayerDisconnect, "userid", userid);
SetEventString(hPlayerDisconnect, "reason", reason); SetEventString(hPlayerDisconnect, "reason", reason);
SetEventString(hPlayerDisconnect, "name", pname); SetEventString(hPlayerDisconnect, "name", pname);
SetEventString(hPlayerDisconnect, "networkid", networkid); SetEventString(hPlayerDisconnect, "networkid", networkid);
pdFire = false; pdFire = false;
FireEvent(hPlayerDisconnect, true); FireEvent(hPlayerDisconnect, true);
pdFire = true; pdFire = true;
return Plugin_Handled; return Plugin_Handled;
} }
return Plugin_Continue; return Plugin_Continue;
} }
public Action:RoundStart(Handle:event, const String:name[], bool:dontBroadcast) public Action:RoundStart(Handle:event, const String:name[], bool:dontBroadcast)
{ {
UpdateHostname(); UpdateHostname();
ChangeLightStyle(); ChangeLightStyle();
RestartAmbience(); RestartAmbience();
ServerCommand("bot_knives_only"); ServerCommand("bot_knives_only");
ZRiot_PrintToChat(0, "Round objective"); ZRiot_PrintToChat(0, "Round objective");
decl String:storyline[192]; decl String:storyline[192];
GetDayStoryLine(gDay, storyline, sizeof(storyline)); GetDayStoryLine(gDay, storyline, sizeof(storyline));
if (storyline[0]) if (storyline[0])
{ {
FormatTextString(storyline, sizeof(storyline)); FormatTextString(storyline, sizeof(storyline));
PrintToChatAll(storyline); PrintToChatAll(storyline);
} }
BeginDay(); BeginDay();
if (tHUD != INVALID_HANDLE) if (tHUD != INVALID_HANDLE)
{ {
CloseHandle(tHUD); CloseHandle(tHUD);
tHUD = INVALID_HANDLE; tHUD = INVALID_HANDLE;
} }
new bool:hud = GetConVarBool(gCvars[CVAR_HUD]); new bool:hud = GetConVarBool(gCvars[CVAR_HUD]);
if (hud) if (hud)
{ {
tHUD = CreateTimer(5.0, HUD, _, TIMER_REPEAT|TIMER_FLAG_NO_MAPCHANGE); tHUD = CreateTimer(5.0, HUD, _, TIMER_REPEAT|TIMER_FLAG_NO_MAPCHANGE);
UpdateHUDAll(); UpdateHUDAll();
} }
if (tFreeze != INVALID_HANDLE) if (tFreeze != INVALID_HANDLE)
{ {
CloseHandle(tFreeze); CloseHandle(tFreeze);
@ -159,35 +159,35 @@ public Action:RoundStart(Handle:event, const String:name[], bool:dontBroadcast)
public Action:RoundFreezeEnd(Handle:event, const String:name[], bool:dontBroadcast) public Action:RoundFreezeEnd(Handle:event, const String:name[], bool:dontBroadcast)
{ {
RemoveObjectives(); RemoveObjectives();
if (tFreeze != INVALID_HANDLE) if (tFreeze != INVALID_HANDLE)
{ {
CloseHandle(tFreeze); CloseHandle(tFreeze);
tFreeze = INVALID_HANDLE; tFreeze = INVALID_HANDLE;
} }
new Float:freeze = GetConVarFloat(gCvars[CVAR_FREEZE]); new Float:freeze = GetConVarFloat(gCvars[CVAR_FREEZE]);
if (freeze > 0) if (freeze > 0)
{ {
FreezeZombies(); FreezeZombies();
tFreeze = CreateTimer(freeze, UnfreezeZombies); tFreeze = CreateTimer(freeze, UnfreezeZombies);
} }
} }
public Action:RoundEnd(Handle:event, const String:name[], bool:dontBroadcast) public Action:RoundEnd(Handle:event, const String:name[], bool:dontBroadcast)
{ {
ResetZombies(false); ResetZombies(false);
ClearTrie(trieDeaths); ClearTrie(trieDeaths);
CreateTimer(0.0, AssignTeamTimer); CreateTimer(0.0, AssignTeamTimer);
new reason = GetEventInt(event, "reason"); new reason = GetEventInt(event, "reason");
if (reason == CTs_Win || reason == Terrorists_Win) if (reason == CTs_Win || reason == Terrorists_Win)
{ {
new winner = GetEventInt(event, "winner"); new winner = GetEventInt(event, "winner");
if (winner == gZombieTeam) if (winner == gZombieTeam)
{ {
ZombiesWin(); ZombiesWin();
@ -207,7 +207,7 @@ public Action:RoundEnd(Handle:event, const String:name[], bool:dontBroadcast)
CloseHandle(tHUD); CloseHandle(tHUD);
tHUD = INVALID_HANDLE; tHUD = INVALID_HANDLE;
} }
if (tFreeze != INVALID_HANDLE) if (tFreeze != INVALID_HANDLE)
{ {
CloseHandle(tFreeze); CloseHandle(tFreeze);
@ -221,19 +221,19 @@ public Action:PlayerTeam_Pre(Handle:event, const String:name[], bool:dontBroadca
if (ptFire) if (ptFire)
{ {
new Handle:hPlayerTeam = CreateEvent("player_team", true); new Handle:hPlayerTeam = CreateEvent("player_team", true);
SetEventInt(hPlayerTeam, "userid", GetEventInt(event, "userid")); SetEventInt(hPlayerTeam, "userid", GetEventInt(event, "userid"));
SetEventInt(hPlayerTeam, "team", GetEventInt(event, "team")); SetEventInt(hPlayerTeam, "team", GetEventInt(event, "team"));
SetEventInt(hPlayerTeam, "oldteam", GetEventInt(event, "oldteam")); SetEventInt(hPlayerTeam, "oldteam", GetEventInt(event, "oldteam"));
SetEventBool(hPlayerTeam, "disconnect", GetEventBool(event, "disconnect")); SetEventBool(hPlayerTeam, "disconnect", GetEventBool(event, "disconnect"));
ptFire = false; ptFire = false;
FireEvent(hPlayerTeam, true); FireEvent(hPlayerTeam, true);
ptFire = true; ptFire = true;
return Plugin_Handled; return Plugin_Handled;
} }
return Plugin_Continue; return Plugin_Continue;
} }
@ -244,27 +244,27 @@ public Action:PlayerTeam_Post(Handle:event, const String:name[], bool:dontBroadc
{ {
return; return;
} }
new index = GetClientOfUserId(GetEventInt(event, "userid")); new index = GetClientOfUserId(GetEventInt(event, "userid"));
new oldteam = GetEventInt(event, "oldteam"); new oldteam = GetEventInt(event, "oldteam");
new team = GetEventInt(event, "team"); new team = GetEventInt(event, "team");
if (team != CS_TEAM_SPECTATOR && oldteam == CS_TEAM_NONE || oldteam == CS_TEAM_SPECTATOR) if (team != CS_TEAM_SPECTATOR && oldteam == CS_TEAM_NONE || oldteam == CS_TEAM_SPECTATOR)
{ {
CreateTimer(0.0, CheckTeam, index); CreateTimer(0.0, CheckTeam, index);
} }
if (team == gHumanTeam) if (team == gHumanTeam)
{ {
StopZVision(index); StopZVision(index);
SetPlayerFOV(index, DEFAULT_FOV); SetPlayerFOV(index, DEFAULT_FOV);
SetEntityGravity(index, DEFAULT_GRAVITY); SetEntityGravity(index, DEFAULT_GRAVITY);
if (IsPlayerAlive(index) || tRespawn[index] != INVALID_HANDLE || tHUD == INVALID_HANDLE) if (IsPlayerAlive(index) || tRespawn[index] != INVALID_HANDLE || tHUD == INVALID_HANDLE)
{ {
return; return;
} }
StartRespawnTimer(index, true); StartRespawnTimer(index, true);
} }
} }
@ -277,41 +277,41 @@ public Action:CheckTeam(Handle:timer, any:index)
public Action:PlayerSpawn(Handle:event, const String:name[], bool:dontBroadcast) public Action:PlayerSpawn(Handle:event, const String:name[], bool:dontBroadcast)
{ {
new index = GetClientOfUserId(GetEventInt(event, "userid")); new index = GetClientOfUserId(GetEventInt(event, "userid"));
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)
{ {
return; return;
} }
gZombieID[index] = -1; gZombieID[index] = -1;
if (IsPlayerZombie(index)) if (IsPlayerZombie(index))
{ {
RemoveTargeters(index); RemoveTargeters(index);
InitClientDeathCount(index); InitClientDeathCount(index);
SetPlayerMoney(index, 0); SetPlayerMoney(index, 0);
new bool:noblock = GetConVarBool(gCvars[CVAR_NOBLOCK]); new bool:noblock = GetConVarBool(gCvars[CVAR_NOBLOCK]);
if (noblock) if (noblock)
{ {
NoCollide(index, true); NoCollide(index, true);
} }
decl String:zombieoverride[4]; decl String:zombieoverride[4];
GetDayZombieOverride(gDay, zombieoverride, sizeof(zombieoverride)); GetDayZombieOverride(gDay, zombieoverride, sizeof(zombieoverride));
new zombieid; new zombieid;
if (adtZombies != INVALID_HANDLE && zombieoverride[0]) if (adtZombies != INVALID_HANDLE && zombieoverride[0])
{ {
new size = GetArraySize(adtZombies); new size = GetArraySize(adtZombies);
if (size) if (size)
{ {
zombieid = GetRandomInt(0, size - 1); zombieid = GetRandomInt(0, size - 1);
Zombify(index, GetArrayCell(adtZombies, zombieid)); Zombify(index, GetArrayCell(adtZombies, zombieid));
} }
} }
@ -321,21 +321,21 @@ public Action:PlayerSpawn(Handle:event, const String:name[], bool:dontBroadcast)
{ {
zombieid = GetRandomInt(0, zCount - 1); zombieid = GetRandomInt(0, zCount - 1);
} while(IsOverrideRequired(zombieid)); } while(IsOverrideRequired(zombieid));
Zombify(index, zombieid); Zombify(index, zombieid);
} }
new health = GetClientHealth(index); new health = GetClientHealth(index);
SetEntityHealth(index, health + GetDayHealthBoost(gDay)); SetEntityHealth(index, health + GetDayHealthBoost(gDay));
new Float:fademin = GetDayMinFade(gDay); new Float:fademin = GetDayMinFade(gDay);
new Float:fademax = GetDayMaxFade(gDay); new Float:fademax = GetDayMaxFade(gDay);
SetPlayerMinDist(index, fademin); SetPlayerMinDist(index, fademin);
SetPlayerMaxDist(index, fademax); SetPlayerMaxDist(index, fademax);
new knife = GetPlayerWeaponSlot(index, 2); new knife = GetPlayerWeaponSlot(index, 2);
if (knife != -1) if (knife != -1)
{ {
SetEntityRenderMode(knife, RENDER_TRANSALPHA); SetEntityRenderMode(knife, RENDER_TRANSALPHA);
@ -348,38 +348,38 @@ public Action:PlayerSpawn(Handle:event, const String:name[], bool:dontBroadcast)
{ {
ZRiot_PrintToChat(index, "!market reminder"); ZRiot_PrintToChat(index, "!market reminder");
} }
new bool:noblock = GetConVarBool(gCvars[CVAR_NOBLOCK]); new bool:noblock = GetConVarBool(gCvars[CVAR_NOBLOCK]);
if (noblock) if (noblock)
{ {
NoCollide(index, false); NoCollide(index, false);
} }
SetPlayerMinDist(index, 0.0); SetPlayerMinDist(index, 0.0);
SetPlayerMaxDist(index, 0.0); SetPlayerMaxDist(index, 0.0);
SetPlayerFOV(index, DEFAULT_FOV); SetPlayerFOV(index, DEFAULT_FOV);
SetEntityGravity(index, DEFAULT_GRAVITY); SetEntityGravity(index, DEFAULT_GRAVITY);
new bool:cashfill = GetConVarBool(gCvars[CVAR_CASHFILL]); new bool:cashfill = GetConVarBool(gCvars[CVAR_CASHFILL]);
if (cashfill) if (cashfill)
{ {
new cash = GetConVarInt(gCvars[CVAR_CASHAMOUNT]); new cash = GetConVarInt(gCvars[CVAR_CASHAMOUNT]);
SetPlayerMoney(index, cash); SetPlayerMoney(index, cash);
} }
if (tZVision[index] != INVALID_HANDLE) if (tZVision[index] != INVALID_HANDLE)
{ {
CloseHandle(tZVision[index]); CloseHandle(tZVision[index]);
tZVision[index] = INVALID_HANDLE; tZVision[index] = INVALID_HANDLE;
} }
ClientCommand(index, "r_screenoverlay \"\""); ClientCommand(index, "r_screenoverlay \"\"");
RemoveTargeters(index); RemoveTargeters(index);
UpdateHUDAll(); UpdateHUDAll();
} }
if (tRespawn[index] != INVALID_HANDLE) if (tRespawn[index] != INVALID_HANDLE)
{ {
CloseHandle(tRespawn[index]); CloseHandle(tRespawn[index]);
@ -391,39 +391,39 @@ public Action:PlayerHurt(Handle:event, const String:name[], bool:dontBroadcast)
{ {
new index = GetClientOfUserId(GetEventInt(event, "userid")); new index = GetClientOfUserId(GetEventInt(event, "userid"));
new attacker = GetClientOfUserId(GetEventInt(event, "attacker")); new attacker = GetClientOfUserId(GetEventInt(event, "attacker"));
decl String:weapon[32]; decl String:weapon[32];
GetEventString(event, "weapon", weapon, sizeof(weapon)); GetEventString(event, "weapon", weapon, sizeof(weapon));
if (!IsPlayerZombie(index)) if (!IsPlayerZombie(index))
{ {
return; return;
} }
if (attacker) if (attacker)
{ {
TargetPlayer(attacker, index); TargetPlayer(attacker, index);
} }
new maxplayers = GetMaxClients(); new maxplayers = GetMaxClients();
new clients[maxplayers]; new clients[maxplayers];
new numClients = GetClientTargeters(index, clients, maxplayers); new numClients = GetClientTargeters(index, clients, maxplayers);
UpdateHUD(clients, numClients); UpdateHUD(clients, numClients);
if (GetRandomInt(1, 5) == 1) if (GetRandomInt(1, 5) == 1)
{ {
decl String:sound[64]; decl String:sound[64];
new randsound = GetRandomInt(1, 6); new randsound = GetRandomInt(1, 6);
Format(sound, sizeof(sound), "npc/zombie/zombie_pain%d.wav", randsound); Format(sound, sizeof(sound), "npc/zombie/zombie_pain%d.wav", randsound);
PrecacheSound(sound); PrecacheSound(sound);
EmitSoundToAll(sound, index); EmitSoundToAll(sound, index);
} }
new bool:napalm = GetConVarBool(gCvars[CVAR_NAPALM]); new bool:napalm = GetConVarBool(gCvars[CVAR_NAPALM]);
if (napalm && StrEqual(weapon, "hegrenade", false)) if (napalm && StrEqual(weapon, "hegrenade", false))
{ {
new Float:burntime = GetConVarFloat(gCvars[CVAR_NAPALM_TIME]); new Float:burntime = GetConVarFloat(gCvars[CVAR_NAPALM_TIME]);
@ -434,42 +434,42 @@ public Action:PlayerHurt(Handle:event, const String:name[], bool:dontBroadcast)
public Action:PlayerDeath(Handle:event, const String:name[], bool:dontBroadcast) public Action:PlayerDeath(Handle:event, const String:name[], bool:dontBroadcast)
{ {
new index = GetClientOfUserId(GetEventInt(event, "userid")); new index = GetClientOfUserId(GetEventInt(event, "userid"));
if (tHUD == INVALID_HANDLE) if (tHUD == INVALID_HANDLE)
{ {
return; return;
} }
new bool:respawn = GetDayRespawn(gDay); new bool:respawn = GetDayRespawn(gDay);
if (IsPlayerZombie(index)) if (IsPlayerZombie(index))
{ {
ExtinguishEntity(index); ExtinguishEntity(index);
SetEntProp(index, Prop_Data, "m_takedamage", 2, 1); SetEntProp(index, Prop_Data, "m_takedamage", 2, 1);
SetEntProp(index, Prop_Data, "m_fFlags", FL_ONGROUND); SetEntProp(index, Prop_Data, "m_fFlags", FL_ONGROUND);
decl String:sound[64]; decl String:sound[64];
new randsound = GetRandomInt(1, 3); new randsound = GetRandomInt(1, 3);
Format(sound, sizeof(sound), "npc/zombie/zombie_die%d.wav", randsound); Format(sound, sizeof(sound), "npc/zombie/zombie_die%d.wav", randsound);
PrecacheSound(sound); PrecacheSound(sound);
EmitSoundToAll(sound, index); EmitSoundToAll(sound, index);
new zombiecount = GetLiveZombieCount(); new zombiecount = GetLiveZombieCount();
new zombiemax = GetConVarInt(gCvars[CVAR_ZOMBIEMAX]); new zombiemax = GetConVarInt(gCvars[CVAR_ZOMBIEMAX]);
if (respawn || zombiecount > zombiemax) if (respawn || zombiecount > zombiemax)
{ {
CreateTimer(0.5, ZombieRespawn, index, TIMER_FLAG_NO_MAPCHANGE); CreateTimer(0.5, ZombieRespawn, index, TIMER_FLAG_NO_MAPCHANGE);
} }
gZombiesKilled++; gZombiesKilled++;
RemoveTargeters(index); RemoveTargeters(index);
UpdateHUDAll(); UpdateHUDAll();
if (gZombiesKilled >= GetDayCount(gDay) && respawn) if (gZombiesKilled >= GetDayCount(gDay) && respawn)
{ {
TerminateRound(5.0, CTs_Win); TerminateRound(5.0, CTs_Win);
@ -479,35 +479,35 @@ public Action:PlayerDeath(Handle:event, const String:name[], bool:dontBroadcast)
{ {
ChangeClientDeathCount(index, 1); ChangeClientDeathCount(index, 1);
new deaths_before_zombie = GetDayDeathsBeforeZombie(gDay); new deaths_before_zombie = GetDayDeathsBeforeZombie(gDay);
if (deaths_before_zombie > 0 && GetClientDeathCount(index) >= deaths_before_zombie && GetLiveHumanCount() > 0) if (deaths_before_zombie > 0 && GetClientDeathCount(index) >= deaths_before_zombie && GetLiveHumanCount() > 0)
{ {
ZRiot_PrintToChat(index, "You are now a zombie"); ZRiot_PrintToChat(index, "You are now a zombie");
CreateTimer(0.5, JoinZombie, index); CreateTimer(0.5, JoinZombie, index);
} }
else else
{ {
StartRespawnTimer(index, false); StartRespawnTimer(index, false);
} }
RemoveTargeters(index); RemoveTargeters(index);
UpdateHUDAll(); UpdateHUDAll();
if (GetLiveHumanCount() <= 0 && respawn) if (GetLiveHumanCount() <= 0 && respawn)
{ {
TerminateRound(5.0, Terrorists_Win); TerminateRound(5.0, Terrorists_Win);
} }
} }
new Float:delay = GetConVarFloat(gCvars[CVAR_RAGDOLL_REMOVE]); new Float:delay = GetConVarFloat(gCvars[CVAR_RAGDOLL_REMOVE]);
if (delay > 0.0) if (delay > 0.0)
{ {
new ragdoll = GetEntPropEnt(index, Prop_Send, "m_hRagdoll"); new ragdoll = GetEntPropEnt(index, Prop_Send, "m_hRagdoll");
CreateTimer(delay, RemoveRagdoll, ragdoll); CreateTimer(delay, RemoveRagdoll, ragdoll);
} }
if (tZVision[index] != INVALID_HANDLE) if (tZVision[index] != INVALID_HANDLE)
{ {
CloseHandle(tZVision[index]); CloseHandle(tZVision[index]);
@ -518,14 +518,14 @@ public Action:PlayerDeath(Handle:event, const String:name[], bool:dontBroadcast)
public Action:PlayerJump(Handle:event, const String:name[], bool:dontBroadcast) public Action:PlayerJump(Handle:event, const String:name[], bool:dontBroadcast)
{ {
new index = GetClientOfUserId(GetEventInt(event, "userid")); new index = GetClientOfUserId(GetEventInt(event, "userid"));
if (!IsPlayerZombie(index)) if (!IsPlayerZombie(index))
{ {
return; return;
} }
new Float:vel[3] = {0.0, 0.0, 0.0}; new Float:vel[3] = {0.0, 0.0, 0.0};
vel[2] = GetZombieJump(gZombieID[index]); vel[2] = GetZombieJump(gZombieID[index]);
SetPlayerVelocity(index, vel); SetPlayerVelocity(index, vel);
} }

View File

@ -17,7 +17,7 @@ CreateGlobals()
CreateNative("ZRiot_Human", Native_Human); CreateNative("ZRiot_Human", Native_Human);
CreateNative("ZRiot_GetZombieTeam", Native_GetZombieTeam); CreateNative("ZRiot_GetZombieTeam", Native_GetZombieTeam);
CreateNative("ZRiot_GetHumanTeam", Native_GetHumanTeam); CreateNative("ZRiot_GetHumanTeam", Native_GetHumanTeam);
hOnClientZombie = CreateGlobalForward("ZRiot_OnClientZombie", ET_Ignore, Param_Cell); hOnClientZombie = CreateGlobalForward("ZRiot_OnClientZombie", ET_Ignore, Param_Cell);
hOnClientHuman = CreateGlobalForward("ZRiot_OnClientHuman", ET_Ignore, Param_Cell); hOnClientHuman = CreateGlobalForward("ZRiot_OnClientHuman", ET_Ignore, Param_Cell);
hOnClientHUDUpdate = CreateGlobalForward("ZRiot_OnClientHUDUpdate", ET_Ignore, Param_Cell, Param_String); hOnClientHUDUpdate = CreateGlobalForward("ZRiot_OnClientHUDUpdate", ET_Ignore, Param_Cell, Param_String);
@ -28,7 +28,7 @@ public Native_IsClientZombie(Handle:plugin, argc)
new client = GetNativeCell(1); new client = GetNativeCell(1);
if (!client) if (!client)
ThrowNativeError(SP_ERROR_INDEX, "Client index %d is not in the game", client); ThrowNativeError(SP_ERROR_INDEX, "Client index %d is not in the game", client);
return bZombie[GetNativeCell(1)]; return bZombie[GetNativeCell(1)];
} }
@ -47,7 +47,7 @@ public Native_Zombie(Handle:plugin, argc)
new client = GetNativeCell(1); new client = GetNativeCell(1);
if (!client) if (!client)
ThrowNativeError(SP_ERROR_INDEX, "Client index %d is not in the game", client); ThrowNativeError(SP_ERROR_INDEX, "Client index %d is not in the game", client);
ZRiot_Zombie(client); ZRiot_Zombie(client);
} }
@ -56,9 +56,9 @@ public Native_Human(Handle:plugin, argc)
new client = GetNativeCell(1); new client = GetNativeCell(1);
if (!client) if (!client)
ThrowNativeError(SP_ERROR_INDEX, "Client index %d is not in the game", client); ThrowNativeError(SP_ERROR_INDEX, "Client index %d is not in the game", client);
if (IsFakeClient(client)) if (IsFakeClient(client))
ThrowNativeError(SP_ERROR_INDEX, "Bots cannot be moved to the human team"); ThrowNativeError(SP_ERROR_INDEX, "Bots cannot be moved to the human team");
ZRiot_Human(client); ZRiot_Human(client);
} }

View File

@ -14,37 +14,37 @@ public Action:HUD(Handle:timer)
UpdateHUD(clients[], numClients) UpdateHUD(clients[], numClients)
{ {
new bool:hud = GetConVarBool(gCvars[CVAR_HUD]); new bool:hud = GetConVarBool(gCvars[CVAR_HUD]);
if (tHUD == INVALID_HANDLE || !hud) if (tHUD == INVALID_HANDLE || !hud)
{ {
return; return;
} }
new bool:targeting = GetConVarBool(gCvars[CVAR_TARGETING]); new bool:targeting = GetConVarBool(gCvars[CVAR_TARGETING]);
new livezombies = GetLiveZombieCount(); new livezombies = GetLiveZombieCount();
new livehumans = GetLiveHumanCount(); new livehumans = GetLiveHumanCount();
decl String:display[32]; decl String:display[32];
decl String:targetname[64]; decl String:targetname[64];
GetDayDisplay(gDay, display, sizeof(display)); GetDayDisplay(gDay, display, sizeof(display));
for (new x = 0; x < numClients; x++) for (new x = 0; x < numClients; x++)
{ {
if (!IsClientInGame(clients[x]) || IsFakeClient(clients[x]) || GetClientTeam(clients[x]) == CS_TEAM_NONE) if (!IsClientInGame(clients[x]) || IsFakeClient(clients[x]) || GetClientTeam(clients[x]) == CS_TEAM_NONE)
{ {
continue; continue;
} }
new target = GetClientTarget(clients[x]); new target = GetClientTarget(clients[x]);
if (targeting && target != -1 && IsPlayerZombie(target) && GetClientTeam(clients[x]) != CS_TEAM_SPECTATOR) if (targeting && target != -1 && IsPlayerZombie(target) && GetClientTeam(clients[x]) != CS_TEAM_SPECTATOR)
{ {
GetClientName(target, targetname, sizeof(targetname)); GetClientName(target, targetname, sizeof(targetname));
new health = GetClientHealth(target); new health = GetClientHealth(target);
health = (health >= 0) ? health : 0; health = (health >= 0) ? health : 0;
ZRiot_HudHint(clients[x], "HUD target", gDay + 1, dCount, display, livezombies, livehumans, target, health); ZRiot_HudHint(clients[x], "HUD target", gDay + 1, dCount, display, livezombies, livehumans, target, health);
} }
else else
@ -60,33 +60,33 @@ stock UpdateHUDClient(client)
{ {
return; return;
} }
new clients[1]; new clients[1];
clients[0] = client; clients[0] = client;
UpdateHUD(clients, 1); UpdateHUD(clients, 1);
} }
stock UpdateHUDAll() stock UpdateHUDAll()
{ {
new maxplayers = GetMaxClients(); new maxplayers = GetMaxClients();
new clients[maxplayers]; new clients[maxplayers];
new count = 0; new count = 0;
for (new x = 1; x <= maxplayers; x++) for (new x = 1; x <= maxplayers; x++)
{ {
if (!IsClientInGame(x) || GetClientTeam(x) == CS_TEAM_NONE) if (!IsClientInGame(x) || GetClientTeam(x) == CS_TEAM_NONE)
{ {
continue; continue;
} }
clients[count++] = x; clients[count++] = x;
} }
UpdateHUD(clients, count); UpdateHUD(clients, count);
} }
GetLiveHumanCount() GetLiveHumanCount()
{ {
new humansleft = 0; new humansleft = 0;
@ -97,10 +97,10 @@ GetLiveHumanCount()
{ {
continue; continue;
} }
humansleft++; humansleft++;
} }
return humansleft; return humansleft;
} }

View File

@ -26,49 +26,49 @@ FindOffsets()
{ {
SetFailState("Couldn't find \"m_vecBaseVelocity\"!"); SetFailState("Couldn't find \"m_vecBaseVelocity\"!");
} }
offsGetVelocity2 = FindSendPropInfo("CBasePlayer", "m_vecVelocity[2]"); offsGetVelocity2 = FindSendPropInfo("CBasePlayer", "m_vecVelocity[2]");
if (offsGetVelocity2 == -1) if (offsGetVelocity2 == -1)
{ {
SetFailState("Couldn't find \"m_vecVelocity[2]\"!"); SetFailState("Couldn't find \"m_vecVelocity[2]\"!");
} }
offsSpeed = FindSendPropInfo("CCSPlayer", "m_flLaggedMovementValue"); offsSpeed = FindSendPropInfo("CCSPlayer", "m_flLaggedMovementValue");
if (offsSpeed == -1) if (offsSpeed == -1)
{ {
SetFailState("Couldn't find \"m_flLaggedMovementValue\"!"); SetFailState("Couldn't find \"m_flLaggedMovementValue\"!");
} }
offsCollision = FindSendPropInfo("CBaseEntity", "m_CollisionGroup"); offsCollision = FindSendPropInfo("CBaseEntity", "m_CollisionGroup");
if (offsCollision == -1) if (offsCollision == -1)
{ {
SetFailState("Couldn't find \"m_CollisionGroup\"!"); SetFailState("Couldn't find \"m_CollisionGroup\"!");
} }
offsMoney = FindSendPropInfo("CCSPlayer", "m_iAccount"); offsMoney = FindSendPropInfo("CCSPlayer", "m_iAccount");
if (offsMoney == -1) if (offsMoney == -1)
{ {
SetFailState("Couldn't find \"m_iAccount\"!"); SetFailState("Couldn't find \"m_iAccount\"!");
} }
offsFOV = FindSendPropInfo("CBasePlayer", "m_iDefaultFOV"); offsFOV = FindSendPropInfo("CBasePlayer", "m_iDefaultFOV");
if (offsFOV == -1) if (offsFOV == -1)
{ {
SetFailState("Couldn't find \"m_iDefaultFOV\"!"); SetFailState("Couldn't find \"m_iDefaultFOV\"!");
} }
offsBuyZone = FindSendPropInfo("CCSPlayer", "m_bInBuyZone"); offsBuyZone = FindSendPropInfo("CCSPlayer", "m_bInBuyZone");
if (offsBuyZone == -1) if (offsBuyZone == -1)
{ {
SetFailState("Couldn't find \"m_bInBuyZone\"!"); SetFailState("Couldn't find \"m_bInBuyZone\"!");
} }
offsFadeMin = FindSendPropInfo("CCSPlayer", "m_fadeMinDist"); offsFadeMin = FindSendPropInfo("CCSPlayer", "m_fadeMinDist");
if (offsFadeMin == -1) if (offsFadeMin == -1)
{ {
SetFailState("Couldn't find \"m_fadeMinDist\"!"); SetFailState("Couldn't find \"m_fadeMinDist\"!");
} }
offsFadeMax = FindSendPropInfo("CCSPlayer", "m_fadeMaxDist"); offsFadeMax = FindSendPropInfo("CCSPlayer", "m_fadeMaxDist");
if (offsFadeMax == -1) if (offsFadeMax == -1)
{ {
@ -79,7 +79,7 @@ FindOffsets()
SetupGameData() SetupGameData()
{ {
hGameConf = LoadGameConfigFile("plugin.zombieriot"); hGameConf = LoadGameConfigFile("plugin.zombieriot");
StartPrepSDKCall(SDKCall_GameRules); StartPrepSDKCall(SDKCall_GameRules);
PrepSDKCall_SetFromConf(hGameConf, SDKConf_Signature, "TerminateRound"); PrepSDKCall_SetFromConf(hGameConf, SDKConf_Signature, "TerminateRound");
PrepSDKCall_AddParameter(SDKType_Float, SDKPass_Plain); PrepSDKCall_AddParameter(SDKType_Float, SDKPass_Plain);
@ -137,7 +137,7 @@ SetPlayerMaxDist(client, Float:maxdist)
/** /**
* Remove all weapons. * Remove all weapons.
* *
* @param client The client index. * @param client The client index.
* @param weapons An array of boolean values for each weapon slot. True means remove, false means ignore. * @param weapons An array of boolean values for each weapon slot. True means remove, false means ignore.
*/ */
@ -152,14 +152,14 @@ stock RemoveAllPlayersWeapons(client)
Util_RemovePlayerItem(client, weaponindex); Util_RemovePlayerItem(client, weaponindex);
} }
} }
// Remove left-over projectiles. // Remove left-over projectiles.
WepLib_GrenadeStripAll(client); WepLib_GrenadeStripAll(client);
} }
/** /**
* Used to explicitly remove projectiles from a client. * Used to explicitly remove projectiles from a client.
* *
* @param client The client index. * @param client The client index.
*/ */
stock WepLib_GrenadeStripAll(client) stock WepLib_GrenadeStripAll(client)
@ -175,7 +175,7 @@ stock WepLib_GrenadeStripAll(client)
/** /**
* Fully remove a weapon from a client's inventory and the world. * Fully remove a weapon from a client's inventory and the world.
* *
* @param client The client whose weapon to remove. * @param client The client whose weapon to remove.
* @param weaponindex The weapon index. * @param weaponindex The weapon index.
*/ */
@ -189,6 +189,6 @@ TerminateRound(Float:delay, reason)
{ {
if (tHUD == INVALID_HANDLE) if (tHUD == INVALID_HANDLE)
return; return;
SDKCall(hTerminateRound, delay, reason); SDKCall(hTerminateRound, delay, reason);
} }

View File

@ -3,7 +3,7 @@
* Zombie Riot * Zombie Riot
* File: overlays.inc * File: overlays.inc
* Author: Greyscale * Author: Greyscale
* ==================== * ====================
*/ */
ShowOverlays(Float:time, winner) ShowOverlays(Float:time, winner)
@ -17,16 +17,16 @@ ShowOverlays(Float:time, winner)
{ {
GetConVarString(gCvars[CVAR_OVERLAYS_HUMAN], overlay, sizeof(overlay)); GetConVarString(gCvars[CVAR_OVERLAYS_HUMAN], overlay, sizeof(overlay));
} }
new maxplayers = GetMaxClients(); new maxplayers = GetMaxClients();
for (new x = 1; x <= maxplayers; x++) for (new x = 1; x <= maxplayers; x++)
{ {
if (!IsClientInGame(x)) if (!IsClientInGame(x))
continue; continue;
DisplayClientOverlay(x, overlay); DisplayClientOverlay(x, overlay);
} }
CreateTimer(time, KillOverlays); CreateTimer(time, KillOverlays);
} }
@ -37,7 +37,7 @@ public Action:KillOverlays(Handle:timer)
{ {
if (!IsClientInGame(x)) if (!IsClientInGame(x))
continue; continue;
ClientCommand(x, "r_screenoverlay \"\""); ClientCommand(x, "r_screenoverlay \"\"");
} }
} }

View File

@ -19,18 +19,18 @@ public Action:SayCommand(client, argc)
{ {
return Plugin_Continue; return Plugin_Continue;
} }
decl String:args[192]; decl String:args[192];
GetCmdArgString(args, sizeof(args)); GetCmdArgString(args, sizeof(args));
ReplaceString(args, sizeof(args), "\"", ""); ReplaceString(args, sizeof(args), "\"", "");
if (StrEqual(args, "!market", false)) if (StrEqual(args, "!market", false))
{ {
Market(client); Market(client);
return Plugin_Handled; return Plugin_Handled;
} }
return Plugin_Continue; return Plugin_Continue;
} }
@ -39,26 +39,26 @@ Market(client)
if (!market) if (!market)
{ {
ZRiot_PrintToChat(client, "Feature is disabled"); ZRiot_PrintToChat(client, "Feature is disabled");
return; return;
} }
new bool:buyzone = GetConVarBool(gCvars[CVAR_ZMARKET_BUYZONE]); new bool:buyzone = GetConVarBool(gCvars[CVAR_ZMARKET_BUYZONE]);
if (!IsClientInBuyZone(client) && buyzone) if (!IsClientInBuyZone(client) && buyzone)
{ {
ZRiot_PrintCenterText(client, "Market out of buyzone"); ZRiot_PrintCenterText(client, "Market out of buyzone");
return; return;
} }
SetGlobalTransTarget(client); SetGlobalTransTarget(client);
decl String:title[64]; decl String:title[64];
decl String:rebuy[64]; decl String:rebuy[64];
Format(title, sizeof(title), "%t\n ", "Market title"); Format(title, sizeof(title), "%t\n ", "Market title");
Format(rebuy, sizeof(rebuy), "%t\n ", "Market rebuy"); Format(rebuy, sizeof(rebuy), "%t\n ", "Market rebuy");
Market_Send(client, title, rebuy); Market_Send(client, title, rebuy);
} }
@ -68,37 +68,37 @@ public bool:Market_OnWeaponSelected(client, String:weaponid[])
{ {
return false; return false;
} }
if (IsPlayerZombie(client)) if (IsPlayerZombie(client))
{ {
ZRiot_PrintToChat(client, "Zombie cant use weapon"); ZRiot_PrintToChat(client, "Zombie cant use weapon");
return false; return false;
} }
if (StrEqual(weaponid, "rebuy")) if (StrEqual(weaponid, "rebuy"))
{ {
return true; return true;
} }
decl String:display[64]; decl String:display[64];
decl String:weapon[32]; decl String:weapon[32];
new price; new price;
if (!Market_GetWeaponIDInfo(weaponid, display, weapon, price)) if (!Market_GetWeaponIDInfo(weaponid, display, weapon, price))
{ {
return false; return false;
} }
ReplaceString(weapon, sizeof(weapon), "weapon_", ""); ReplaceString(weapon, sizeof(weapon), "weapon_", "");
if (IsWeaponRestricted(weapon)) if (IsWeaponRestricted(weapon))
{ {
ZRiot_PrintToChat(client, "Weapon is restricted", weapon); ZRiot_PrintToChat(client, "Weapon is restricted", weapon);
return false; return false;
} }
return true; return true;
} }
@ -108,6 +108,6 @@ public Market_PostOnWeaponSelected(client, &bool:allowed)
{ {
return; return;
} }
Market(client); Market(client);
} }

View File

@ -16,9 +16,9 @@ TargetPlayer(attacker, client)
{ {
return; return;
} }
gTarget[attacker] = client; gTarget[attacker] = client;
bTargeted[client][attacker] = true; bTargeted[client][attacker] = true;
} }
@ -28,7 +28,7 @@ GetClientTarget(client)
{ {
return -1; return -1;
} }
return gTarget[client]; return gTarget[client];
} }
@ -41,10 +41,10 @@ GetClientTargeters(client, clients[], maxClients)
{ {
continue; continue;
} }
clients[count++] = x; clients[count++] = x;
} }
return count; return count;
} }
@ -57,13 +57,13 @@ FindClientNextTarget(client)
{ {
continue; continue;
} }
if (bTargeted[x][client]) if (bTargeted[x][client])
{ {
return x; return x;
} }
} }
return -1; return -1;
} }
@ -73,7 +73,7 @@ RemoveTargeters(client)
for (new x = 1; x <= maxplayers; x++) for (new x = 1; x <= maxplayers; x++)
{ {
bTargeted[client][x] = false; bTargeted[client][x] = false;
if (gTarget[x] == client) if (gTarget[x] == client)
{ {
gTarget[x] = FindClientNextTarget(x); gTarget[x] = FindClientNextTarget(x);

View File

@ -24,18 +24,18 @@ public Action:Command_JoinTeam(client, argc)
{ {
return Plugin_Continue; return Plugin_Continue;
} }
new bool:enabled = GetConVarBool(gCvars[CVAR_ENABLE]); new bool:enabled = GetConVarBool(gCvars[CVAR_ENABLE]);
if (!enabled) if (!enabled)
{ {
return Plugin_Continue; return Plugin_Continue;
} }
decl String:args[8]; decl String:args[8];
GetCmdArgString(args, sizeof(args)); GetCmdArgString(args, sizeof(args));
new jointeam = StringToInt(args); new jointeam = StringToInt(args);
new team = GetClientTeam(client); new team = GetClientTeam(client);
if (team == CS_TEAM_T || team == CS_TEAM_CT) if (team == CS_TEAM_T || team == CS_TEAM_CT)
{ {
@ -48,7 +48,7 @@ public Action:Command_JoinTeam(client, argc)
ChangeClientDeathCount(client, -1); ChangeClientDeathCount(client, -1);
} }
} }
return Plugin_Continue; return Plugin_Continue;
} }
@ -58,15 +58,15 @@ public Action:Command_Kill(client, argc)
{ {
return Plugin_Continue; return Plugin_Continue;
} }
new bool:enabled = GetConVarBool(gCvars[CVAR_ENABLE]); new bool:enabled = GetConVarBool(gCvars[CVAR_ENABLE]);
if (!enabled) if (!enabled)
{ {
return Plugin_Continue; return Plugin_Continue;
} }
ZRiot_ReplyToCommand(client, "Suicide text"); ZRiot_ReplyToCommand(client, "Suicide text");
return Plugin_Handled; return Plugin_Handled;
} }
@ -76,15 +76,15 @@ public Action:Command_Spectate(client, argc)
{ {
return Plugin_Continue; return Plugin_Continue;
} }
new bool:enabled = GetConVarBool(gCvars[CVAR_ENABLE]); new bool:enabled = GetConVarBool(gCvars[CVAR_ENABLE]);
if (!enabled) if (!enabled)
{ {
return Plugin_Continue; return Plugin_Continue;
} }
ChangeClientDeathCount(client, -1); ChangeClientDeathCount(client, -1);
return Plugin_Continue; return Plugin_Continue;
} }
@ -92,7 +92,7 @@ UpdateTeams()
{ {
decl String:zombieteam[8]; decl String:zombieteam[8];
GetConVarString(gCvars[CVAR_ZOMBIETEAM], zombieteam, sizeof(zombieteam)); GetConVarString(gCvars[CVAR_ZOMBIETEAM], zombieteam, sizeof(zombieteam));
if (StrEqual(zombieteam, "t", false)) if (StrEqual(zombieteam, "t", false))
{ {
gZombieTeam = CS_TEAM_T; gZombieTeam = CS_TEAM_T;
@ -108,7 +108,7 @@ UpdateTeams()
SetFailState("Invalid value for cvar zriot_zombieteam, see config file"); SetFailState("Invalid value for cvar zriot_zombieteam, see config file");
return; return;
} }
AssignTeamAll(true); AssignTeamAll(true);
} }
@ -121,10 +121,10 @@ ResetZombies(bool:switchteam)
{ {
continue; continue;
} }
bZombie[x] = IsFakeClient(x); bZombie[x] = IsFakeClient(x);
} }
if (switchteam) if (switchteam)
{ {
AssignTeamAll(false); AssignTeamAll(false);
@ -144,13 +144,13 @@ AssignTeam(clients[], numClients, bool:spawn)
{ {
continue; continue;
} }
new team = GetClientTeam(clients[x]); new team = GetClientTeam(clients[x]);
if (IsPlayerZombie(clients[x])) if (IsPlayerZombie(clients[x]))
{ {
CS_SwitchTeam(clients[x], gZombieTeam); CS_SwitchTeam(clients[x], gZombieTeam);
if (spawn && team != gZombieTeam) if (spawn && team != gZombieTeam)
{ {
CS_RespawnPlayer(clients[x]); CS_RespawnPlayer(clients[x]);
@ -159,7 +159,7 @@ AssignTeam(clients[], numClients, bool:spawn)
else else
{ {
CS_SwitchTeam(clients[x], gHumanTeam); CS_SwitchTeam(clients[x], gHumanTeam);
if (spawn && team != gHumanTeam) if (spawn && team != gHumanTeam)
{ {
CS_RespawnPlayer(clients[x]); CS_RespawnPlayer(clients[x]);
@ -174,29 +174,29 @@ stock AssignTeamClient(client, bool:spawn)
{ {
return; return;
} }
new clients[1]; new clients[1];
clients[0] = client; clients[0] = client;
AssignTeam(clients, 1, spawn); AssignTeam(clients, 1, spawn);
} }
stock AssignTeamAll(bool:spawn) stock AssignTeamAll(bool:spawn)
{ {
new maxplayers = GetMaxClients(); new maxplayers = GetMaxClients();
new clients[maxplayers]; new clients[maxplayers];
new count = 0; new count = 0;
for (new x = 1; x <= maxplayers; x++) for (new x = 1; x <= maxplayers; x++)
{ {
if (!IsClientInGame(x) || GetClientTeam(x) < CS_TEAM_T) if (!IsClientInGame(x) || GetClientTeam(x) < CS_TEAM_T)
{ {
continue; continue;
} }
clients[count++] = x; clients[count++] = x;
} }
AssignTeam(clients, count, spawn); AssignTeam(clients, count, spawn);
} }

View File

@ -9,7 +9,7 @@
FormatTextString(String:text[], maxlen) FormatTextString(String:text[], maxlen)
{ {
Format(text, maxlen, "@green[%t] @default%s", "ZRiot", text); Format(text, maxlen, "@green[%t] @default%s", "ZRiot", text);
ReplaceString(text, maxlen, "@default","\x01"); ReplaceString(text, maxlen, "@default","\x01");
ReplaceString(text, maxlen, "@lgreen","\x03"); ReplaceString(text, maxlen, "@lgreen","\x03");
ReplaceString(text, maxlen, "@green","\x04"); ReplaceString(text, maxlen, "@green","\x04");
@ -18,35 +18,35 @@ FormatTextString(String:text[], maxlen)
stock ZRiot_PrintToChat(client, any:...) stock ZRiot_PrintToChat(client, any:...)
{ {
decl String:phrase[192]; decl String:phrase[192];
if (client) if (client)
{ {
SetGlobalTransTarget(client); SetGlobalTransTarget(client);
VFormat(phrase, sizeof(phrase), "%t", 2); VFormat(phrase, sizeof(phrase), "%t", 2);
FormatTextString(phrase, sizeof(phrase)); FormatTextString(phrase, sizeof(phrase));
PrintToChat(client, phrase); PrintToChat(client, phrase);
} }
else else
{ {
SetGlobalTransTarget(client); SetGlobalTransTarget(client);
VFormat(phrase, sizeof(phrase), "%t", 2); VFormat(phrase, sizeof(phrase), "%t", 2);
FormatTextString(phrase, sizeof(phrase)); FormatTextString(phrase, sizeof(phrase));
PrintToServer(phrase); PrintToServer(phrase);
new maxplayers = GetMaxClients(); new maxplayers = GetMaxClients();
for (new x = 1; x <= maxplayers; x++) for (new x = 1; x <= maxplayers; x++)
{ {
if (IsClientInGame(x)) if (IsClientInGame(x))
{ {
SetGlobalTransTarget(x); SetGlobalTransTarget(x);
VFormat(phrase, sizeof(phrase), "%t", 2); VFormat(phrase, sizeof(phrase), "%t", 2);
FormatTextString(phrase, sizeof(phrase)); FormatTextString(phrase, sizeof(phrase));
PrintToChat(x, phrase); PrintToChat(x, phrase);
} }
} }
@ -56,32 +56,32 @@ stock ZRiot_PrintToChat(client, any:...)
stock ZRiot_PrintCenterText(client, any:...) stock ZRiot_PrintCenterText(client, any:...)
{ {
SetGlobalTransTarget(client); SetGlobalTransTarget(client);
decl String:phrase[192]; decl String:phrase[192];
VFormat(phrase, sizeof(phrase), "%t", 2); VFormat(phrase, sizeof(phrase), "%t", 2);
PrintCenterText(client, phrase); PrintCenterText(client, phrase);
} }
stock ZRiot_HudHint(client, any:...) stock ZRiot_HudHint(client, any:...)
{ {
SetGlobalTransTarget(client); SetGlobalTransTarget(client);
decl String:phrase[192]; decl String:phrase[192];
VFormat(phrase, sizeof(phrase), "%t", 2); VFormat(phrase, sizeof(phrase), "%t", 2);
new Handle:hHintText = StartMessageOne("HintText", client); new Handle:hHintText = StartMessageOne("HintText", client);
if (hHintText != INVALID_HANDLE) if (hHintText != INVALID_HANDLE)
{ {
BfWriteByte(hHintText, -1); BfWriteByte(hHintText, -1);
Call_StartForward(hOnClientHUDUpdate); Call_StartForward(hOnClientHUDUpdate);
Call_PushCell(client); Call_PushCell(client);
Call_PushStringEx(phrase, sizeof(phrase), SM_PARAM_STRING_COPY, SM_PARAM_COPYBACK); Call_PushStringEx(phrase, sizeof(phrase), SM_PARAM_STRING_COPY, SM_PARAM_COPYBACK);
Call_Finish(); Call_Finish();
BfWriteString(hHintText, phrase); BfWriteString(hHintText, phrase);
EndMessage(); EndMessage();
} }
@ -90,35 +90,35 @@ stock ZRiot_HudHint(client, any:...)
stock ZRiot_PrintToServer(any:...) stock ZRiot_PrintToServer(any:...)
{ {
SetGlobalTransTarget(LANG_SERVER); SetGlobalTransTarget(LANG_SERVER);
decl String:phrase[192]; decl String:phrase[192];
decl String:buffer[192]; decl String:buffer[192];
VFormat(phrase, sizeof(phrase), "%t", 1); VFormat(phrase, sizeof(phrase), "%t", 1);
Format(buffer, sizeof(buffer), "[%t] %s", "ZRiot", phrase); Format(buffer, sizeof(buffer), "[%t] %s", "ZRiot", phrase);
PrintToServer(buffer); PrintToServer(buffer);
} }
stock ZRiot_LogMessage(any:...) stock ZRiot_LogMessage(any:...)
{ {
SetGlobalTransTarget(LANG_SERVER); SetGlobalTransTarget(LANG_SERVER);
decl String:phrase[192]; decl String:phrase[192];
VFormat(phrase, sizeof(phrase), "%t", 1); VFormat(phrase, sizeof(phrase), "%t", 1);
LogMessage(phrase); LogMessage(phrase);
} }
stock ZRiot_ReplyToCommand(client, any:...) stock ZRiot_ReplyToCommand(client, any:...)
{ {
decl String:phrase[192]; decl String:phrase[192];
SetGlobalTransTarget(client); SetGlobalTransTarget(client);
VFormat(phrase, sizeof(phrase), "%t", 2); VFormat(phrase, sizeof(phrase), "%t", 2);
FormatTextString(phrase, sizeof(phrase)); FormatTextString(phrase, sizeof(phrase));
ReplyToCommand(client, phrase); ReplyToCommand(client, phrase);
} }

View File

@ -14,17 +14,17 @@ enum WepRestrictQuery
Invalid, /** Weapon invalid */ Invalid, /** Weapon invalid */
Existing, /** Already restricted */ Existing, /** Already restricted */
} }
InitWeaponRestrict() InitWeaponRestrict()
{ {
RegConsoleCmd("buy", BuyHook); RegConsoleCmd("buy", BuyHook);
restrictedWeapons = CreateArray(32, 0); restrictedWeapons = CreateArray(32, 0);
} }
ClientHookUse(client) ClientHookUse(client)
{ {
SDKHook(client, SDKHook_WeaponCanUse, Weapon_CanUse); SDKHook(client, SDKHook_WeaponCanUse, Weapon_CanUse);
} }
public Action:BuyHook(client, argc) public Action:BuyHook(client, argc)
@ -34,25 +34,25 @@ public Action:BuyHook(client, argc)
{ {
return Plugin_Continue; return Plugin_Continue;
} }
if (IsPlayerZombie(client)) if (IsPlayerZombie(client))
{ {
ZRiot_PrintToChat(client, "Zombie cant use weapon"); ZRiot_PrintToChat(client, "Zombie cant use weapon");
return Plugin_Handled; return Plugin_Handled;
} }
decl String:weapon[64]; decl String:weapon[64];
GetCmdArg(1, weapon, sizeof(weapon)); GetCmdArg(1, weapon, sizeof(weapon));
ReplaceString(weapon, sizeof(weapon), "weapon_", ""); ReplaceString(weapon, sizeof(weapon), "weapon_", "");
if (IsWeaponRestricted(weapon)) if (IsWeaponRestricted(weapon))
{ {
ZRiot_PrintToChat(client, "Weapon is restricted", weapon); ZRiot_PrintToChat(client, "Weapon is restricted", weapon);
return Plugin_Handled; return Plugin_Handled;
} }
return Plugin_Continue; return Plugin_Continue;
} }
@ -61,21 +61,21 @@ WepRestrictQuery:RestrictWeapon(const String:weapon[])
if (IsWeaponGroup(weapon)) if (IsWeaponGroup(weapon))
{ {
RestrictWeaponGroup(weapon); RestrictWeaponGroup(weapon);
ZRiot_PrintToChat(0, "Weapon group has been restricted", weapon); ZRiot_PrintToChat(0, "Weapon group has been restricted", weapon);
return Successful; return Successful;
} }
if (!IsWeaponRestricted(weapon)) if (!IsWeaponRestricted(weapon))
{ {
PushArrayString(restrictedWeapons, weapon); PushArrayString(restrictedWeapons, weapon);
ZRiot_PrintToChat(0, "Weapon has been restricted", weapon); ZRiot_PrintToChat(0, "Weapon has been restricted", weapon);
return Successful; return Successful;
} }
return Existing; return Existing;
} }
@ -120,26 +120,26 @@ RestrictWeaponGroup(const String:group[])
PushArrayString(restrictedWeapons, "awp"); PushArrayString(restrictedWeapons, "awp");
} }
} }
WepRestrictQuery:UnRestrictWeapon(const String:weapon[]) WepRestrictQuery:UnRestrictWeapon(const String:weapon[])
{ {
if (IsWeaponGroup(weapon)) if (IsWeaponGroup(weapon))
{ {
UnRestrictWeaponGroup(weapon); UnRestrictWeaponGroup(weapon);
ZRiot_PrintToChat(0, "Weapon group has been unrestricted", weapon); ZRiot_PrintToChat(0, "Weapon group has been unrestricted", weapon);
return Successful; return Successful;
} }
new index = GetRestrictedWeaponIndex(weapon); new index = GetRestrictedWeaponIndex(weapon);
if (index > -1) if (index > -1)
{ {
RemoveFromArray(restrictedWeapons, index); RemoveFromArray(restrictedWeapons, index);
ZRiot_PrintToChat(0, "Weapon has been unrestricted", weapon); ZRiot_PrintToChat(0, "Weapon has been unrestricted", weapon);
return Successful; return Successful;
} }
@ -194,13 +194,13 @@ bool:IsWeaponRestricted(const String:weapon[])
{ {
decl String:restrictedweapon[32]; decl String:restrictedweapon[32];
GetArrayString(restrictedWeapons, x, restrictedweapon, sizeof(restrictedweapon)); GetArrayString(restrictedWeapons, x, restrictedweapon, sizeof(restrictedweapon));
if (StrEqual(weapon, restrictedweapon, false)) if (StrEqual(weapon, restrictedweapon, false))
{ {
return true; return true;
} }
} }
return false; return false;
} }
@ -211,13 +211,13 @@ GetRestrictedWeaponIndex(const String:weapon[])
decl String:restrictedweapon[32]; decl String:restrictedweapon[32];
GetArrayString(restrictedWeapons, x, restrictedweapon, sizeof(restrictedweapon)); GetArrayString(restrictedWeapons, x, restrictedweapon, sizeof(restrictedweapon));
ReplaceString(restrictedweapon, sizeof(restrictedweapon), "weapon_", ""); ReplaceString(restrictedweapon, sizeof(restrictedweapon), "weapon_", "");
if (StrEqual(weapon, restrictedweapon, false)) if (StrEqual(weapon, restrictedweapon, false))
{ {
return x; return x;
} }
} }
return -1; return -1;
} }
@ -233,40 +233,40 @@ public Action:Weapon_CanUse(client, weapon)
{ {
return Plugin_Continue; return Plugin_Continue;
} }
new String:weaponname[32]; new String:weaponname[32];
if (!weapon || !GetEdictClassname(weapon, weaponname, sizeof(weaponname))) if (!weapon || !GetEdictClassname(weapon, weaponname, sizeof(weaponname)))
{ {
return Plugin_Continue; return Plugin_Continue;
} }
ReplaceString(weaponname, sizeof(weaponname), "weapon_", ""); ReplaceString(weaponname, sizeof(weaponname), "weapon_", "");
decl String:model[256]; decl String:model[256];
GetClientModel(client, model, sizeof(model)); GetClientModel(client, model, sizeof(model));
ReplaceString(model, sizeof(model), ".mdl", ""); ReplaceString(model, sizeof(model), ".mdl", "");
if (FindStringInArray(adtModels, model) > -1 && !StrEqual(weaponname, "knife")) if (FindStringInArray(adtModels, model) > -1 && !StrEqual(weaponname, "knife"))
{ {
return Plugin_Handled; return Plugin_Handled;
} }
if (IsWeaponRestricted(weaponname)) if (IsWeaponRestricted(weaponname))
{ {
return Plugin_Handled; return Plugin_Handled;
} }
if (IsPlayerZombie(client) && !StrEqual(weaponname, "knife")) if (IsPlayerZombie(client) && !StrEqual(weaponname, "knife"))
{ {
if (StrEqual(weaponname, "glock") || StrEqual(weaponname, "usp")) if (StrEqual(weaponname, "glock") || StrEqual(weaponname, "usp"))
{ {
CreateTimer(0.0, RemoveSpawnWeapon, weapon); CreateTimer(0.0, RemoveSpawnWeapon, weapon);
} }
return Plugin_Handled; return Plugin_Handled;
} }
return Plugin_Continue; return Plugin_Continue;
} }
@ -275,5 +275,5 @@ public Action:RemoveSpawnWeapon(Handle:timer, any:weapon)
if (IsValidEdict(weapon)) if (IsValidEdict(weapon))
{ {
RemoveEdict(weapon); RemoveEdict(weapon);
} }
} }

View File

@ -258,21 +258,22 @@ ApplyZombieHealth(client, zombieid)
{ {
if (IsValidZombieID(zombieid)) if (IsValidZombieID(zombieid))
{ {
new iCount = 0; new iClientCount = 0;
for (new i = 1; i <= MaxClients; i++) for (new i = 1; i <= MaxClients; i++)
{ {
if (IsValidClient(i) && (GetClientTeam(i) == 3) && IsPlayerAlive(i)) if (IsClientInGame(i) && IsPlayerAlive(i) && GetClientTeam(i) == CS_TEAM_CT)
{ {
iCount++; iClientCount++;
} }
} }
if (iCount == 0)
{
iCount++;
}
SetEntityHealth(client, arrayZombies[zombieid][data_health]*iCount); if (iClientCount == 0)
{
iClientCount++;
}
SetEntityHealth(client, arrayZombies[zombieid][data_health] * iClientCount);
} }
} }
@ -308,17 +309,4 @@ ApplyZombieFOV(client, zombieid)
{ {
SetPlayerFOV(client, arrayZombies[zombieid][data_fov]); SetPlayerFOV(client, arrayZombies[zombieid][data_fov]);
} }
}
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
int:IsValidClient(client, nobots = true)
{
if (client <= 0 || client > MaxClients || !IsClientConnected(client) || (nobots && IsFakeClient(client)))
{
return false;
}
return IsClientInGame(client);
} }

View File

@ -3,25 +3,25 @@
* Zombie Riot * Zombie Riot
* File: zombieriot.inc * File: zombieriot.inc
* Author: Greyscale * Author: Greyscale
* ==================== * ====================
*/ */
#define Target_Bombed 0 // Target Successfully Bombed! #define Target_Bombed 0 // Target Successfully Bombed!
#define VIP_Escaped 1 // The VIP has escaped! #define VIP_Escaped 1 // The VIP has escaped!
#define VIP_Assassinated 2 // VIP has been assassinated! #define VIP_Assassinated 2 // VIP has been assassinated!
#define Terrorists_Escaped 3 // The terrorists have escaped! #define Terrorists_Escaped 3 // The terrorists have escaped!
#define CTs_PreventEscape 4 // The CT's have prevented most of the terrorists from escaping! #define CTs_PreventEscape 4 // The CT's have prevented most of the terrorists from escaping!
#define Escaping_Terrorists_Neutralized 5 // Escaping terrorists have all been neutralized! #define Escaping_Terrorists_Neutralized 5 // Escaping terrorists have all been neutralized!
#define Bomb_Defused 6 // The bomb has been defused! #define Bomb_Defused 6 // The bomb has been defused!
#define CTs_Win 7 // Counter-Terrorists Win! #define CTs_Win 7 // Counter-Terrorists Win!
#define Terrorists_Win 8 // Terrorists Win! #define Terrorists_Win 8 // Terrorists Win!
#define Round_Draw 9 // Round Draw! #define Round_Draw 9 // Round Draw!
#define All_Hostages_Rescued 10 // All Hostages have been rescued! #define All_Hostages_Rescued 10 // All Hostages have been rescued!
#define Target_Saved 11 // Target has been saved! #define Target_Saved 11 // Target has been saved!
#define Hostages_Not_Rescued 12 // Hostages have not been rescued! #define Hostages_Not_Rescued 12 // Hostages have not been rescued!
#define Terrorists_Not_Escaped 13 // Terrorists have not escaped! #define Terrorists_Not_Escaped 13 // Terrorists have not escaped!
#define VIP_Not_Escaped 14 // VIP has not escaped! #define VIP_Not_Escaped 14 // VIP has not escaped!
#define Game_Commencing 15 // Game Commencing! #define Game_Commencing 15 // Game Commencing!
#define DXLEVEL_MIN 90 #define DXLEVEL_MIN 90
@ -61,7 +61,7 @@ FindClientDXLevel(client)
{ {
return; return;
} }
mat_dxlevel = QueryClientConVar(client, "mat_dxlevel", DXLevelClientQuery); mat_dxlevel = QueryClientConVar(client, "mat_dxlevel", DXLevelClientQuery);
} }
@ -71,14 +71,14 @@ public DXLevelClientQuery(QueryCookie:cookie, client, ConVarQueryResult:result,
{ {
return; return;
} }
dxLevel[client] = 0; dxLevel[client] = 0;
if (result != ConVarQuery_Okay) if (result != ConVarQuery_Okay)
{ {
return; return;
} }
dxLevel[client] = StringToInt(cvarValue); dxLevel[client] = StringToInt(cvarValue);
} }
@ -87,10 +87,10 @@ DisplayClientOverlay(client, const String:overlay[])
if (!dxLevel[client]) if (!dxLevel[client])
{ {
FindClientDXLevel(client); FindClientDXLevel(client);
return; return;
} }
if (dxLevel[client] >= DXLEVEL_MIN) if (dxLevel[client] >= DXLEVEL_MIN)
{ {
ClientCommand(client, "r_screenoverlay \"%s\"", overlay); ClientCommand(client, "r_screenoverlay \"%s\"", overlay);
@ -104,14 +104,14 @@ DisplayClientOverlay(client, const String:overlay[])
stock GotoNextMap() stock GotoNextMap()
{ {
new Handle:timelimit = FindConVar("mp_timelimit"); new Handle:timelimit = FindConVar("mp_timelimit");
if (timelimit == INVALID_HANDLE) if (timelimit == INVALID_HANDLE)
{ {
return; return;
} }
new flags = GetConVarFlags(timelimit) & FCVAR_NOTIFY; new flags = GetConVarFlags(timelimit) & FCVAR_NOTIFY;
SetConVarFlags(timelimit, flags); SetConVarFlags(timelimit, flags);
SetConVarInt(timelimit, 1); SetConVarInt(timelimit, 1);
} }