Raised This Month: $32 Target: $400
 8% 

Bug Report "No one wins..." adds to Terrorist teamscore


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Fawkes37
Senior Member
Join Date: Jul 2008
Old 07-18-2020 , 21:36   "No one wins..." adds to Terrorist teamscore
Reply With Quote #1

It appears that if the round timer runs out and the result is "No one wins...", a point is still added to Terrorists/Zombies (at both de_ and cs_ maps). Not sure if this is an actual bug, because I have played around with the code, and may have introduced this bug myself.
I tried playing around a bit with the zp50_team_scoring.sma, but with no result. I even tried commenting out g_ScoreHumans++ and g_ScoreZombies++, but it didnt have any effect. Guess I dont really understand where the score is calculated. Here is the .sma file:

Code:
/*================================================================================
	
	-------------------------
	-*- [ZP] Team Scoring -*-
	-------------------------
	
	This plugin is part of Zombie Plague Mod and is distributed under the
	terms of the GNU General Public License. Check ZP_ReadMe.txt for details.
	
================================================================================*/

#include <amxmodx>
#include <amx_settings_api>
#include <zp50_gamemodes>

// Settings file
new const ZP_SETTINGS_FILE[] = "zombieplague.ini"

// Default sounds
new const sound_win_zombies[][] = { "ambience/the_horror1.wav" , "ambience/the_horror3.wav" , "ambience/the_horror4.wav" }
new const sound_win_humans[][] = { "radio/ctwin.wav" }
new const sound_win_no_one[][] = { "ambience/3dmstart.wav" }

// HUD messages
#define HUD_EVENT_X -1.0
#define HUD_EVENT_Y 0.12

#define SOUND_MAX_LENGTH 64

// Custom sounds
new Array:g_sound_win_zombies
new Array:g_sound_win_humans
new Array:g_sound_win_no_one

new g_ScoreHumans, g_ScoreZombies
new g_HudSync

new cvar_winner_show_hud, cvar_winner_sounds

public plugin_init()
{
	register_plugin("[ZP] Team Scoring", ZP_VERSION_STRING, "ZP Dev Team")
	
	// Create the HUD Sync Objects
	g_HudSync = CreateHudSyncObj()
	
	register_message(get_user_msgid("TextMsg"), "message_textmsg")
	register_message(get_user_msgid("SendAudio"), "message_sendaudio")
	
	cvar_winner_show_hud = register_cvar("zp_winner_show_hud", "1")
	cvar_winner_sounds = register_cvar("zp_winner_sounds", "1")
}

public plugin_precache()
{
	// Initialize arrays
	g_sound_win_zombies = ArrayCreate(SOUND_MAX_LENGTH, 1)
	g_sound_win_humans = ArrayCreate(SOUND_MAX_LENGTH, 1)
	g_sound_win_no_one = ArrayCreate(SOUND_MAX_LENGTH, 1)
	
	// Load from external file
	amx_load_setting_string_arr(ZP_SETTINGS_FILE, "Sounds", "WIN ZOMBIES", g_sound_win_zombies)
	amx_load_setting_string_arr(ZP_SETTINGS_FILE, "Sounds", "WIN HUMANS", g_sound_win_humans)
	amx_load_setting_string_arr(ZP_SETTINGS_FILE, "Sounds", "WIN NO ONE", g_sound_win_no_one)
	
	// If we couldn't load custom sounds from file, use and save default ones
	new index
	if (ArraySize(g_sound_win_zombies) == 0)
	{
		for (index = 0; index < sizeof sound_win_zombies; index++)
			ArrayPushString(g_sound_win_zombies, sound_win_zombies[index])
		
		// Save to external file
		amx_save_setting_string_arr(ZP_SETTINGS_FILE, "Sounds", "WIN ZOMBIES", g_sound_win_zombies)
	}
	if (ArraySize(g_sound_win_humans) == 0)
	{
		for (index = 0; index < sizeof sound_win_humans; index++)
			ArrayPushString(g_sound_win_humans, sound_win_humans[index])
		
		// Save to external file
		amx_save_setting_string_arr(ZP_SETTINGS_FILE, "Sounds", "WIN HUMANS", g_sound_win_humans)
	}
	if (ArraySize(g_sound_win_no_one) == 0)
	{
		for (index = 0; index < sizeof sound_win_no_one; index++)
			ArrayPushString(g_sound_win_no_one, sound_win_no_one[index])
		
		// Save to external file
		amx_save_setting_string_arr(ZP_SETTINGS_FILE, "Sounds", "WIN NO ONE", g_sound_win_no_one)
	}
	
	// Precache sounds
	new sound[SOUND_MAX_LENGTH]
	for (index = 0; index < ArraySize(g_sound_win_zombies); index++)
	{
		ArrayGetString(g_sound_win_zombies, index, sound, charsmax(sound))
		if (equal(sound[strlen(sound)-4], ".mp3"))
		{
			format(sound, charsmax(sound), "sound/%s", sound)
			precache_generic(sound)
		}
		else
			precache_sound(sound)
	}
	for (index = 0; index < ArraySize(g_sound_win_humans); index++)
	{
		ArrayGetString(g_sound_win_humans, index, sound, charsmax(sound))
		if (equal(sound[strlen(sound)-4], ".mp3"))
		{
			format(sound, charsmax(sound), "sound/%s", sound)
			precache_generic(sound)
		}
		else
			precache_sound(sound)
	}
	for (index = 0; index < ArraySize(g_sound_win_no_one); index++)
	{
		ArrayGetString(g_sound_win_no_one, index, sound, charsmax(sound))
		if (equal(sound[strlen(sound)-4], ".mp3"))
		{
			format(sound, charsmax(sound), "sound/%s", sound)
			precache_generic(sound)
		}
		else
			precache_sound(sound)
	}
}

public zp_fw_gamemodes_end()
{
	// Determine round winner, show HUD notice
	new sound[SOUND_MAX_LENGTH]
	if (!zp_core_get_zombie_count())
	{
		// Human team wins
		if (get_pcvar_num(cvar_winner_show_hud))
		{
			set_hudmessage(0, 0, 200, HUD_EVENT_X, HUD_EVENT_Y, 0, 0.0, 3.0, 2.0, 1.0, -1)
			ShowSyncHudMsg(0, g_HudSync, "%L", LANG_PLAYER, "WIN_HUMAN")
		}
		
		if (get_pcvar_num(cvar_winner_sounds))
		{
			ArrayGetString(g_sound_win_humans, random_num(0, ArraySize(g_sound_win_humans) - 1), sound, charsmax(sound))
			PlaySoundToClients(sound, 0)
		}
		
		g_ScoreHumans++
	}
	else if (!zp_core_get_human_count())
	{
		// Zombie team wins
		if (get_pcvar_num(cvar_winner_show_hud))
		{
			set_hudmessage(200, 0, 0, HUD_EVENT_X, HUD_EVENT_Y, 0, 0.0, 3.0, 2.0, 1.0, -1)
			ShowSyncHudMsg(0, g_HudSync, "%L", LANG_PLAYER, "WIN_ZOMBIE")
		}
		
		if (get_pcvar_num(cvar_winner_sounds))
		{
			ArrayGetString(g_sound_win_zombies, random_num(0, ArraySize(g_sound_win_zombies) - 1), sound, charsmax(sound))
			PlaySoundToClients(sound, 0)
		}
		
		g_ScoreZombies++
	}
	else
	{
		// No one wins
		if (get_pcvar_num(cvar_winner_show_hud))
		{
			set_hudmessage(0, 200, 0, HUD_EVENT_X, HUD_EVENT_Y, 0, 0.0, 3.0, 2.0, 1.0, -1)
			ShowSyncHudMsg(0, g_HudSync, "%L", LANG_PLAYER, "WIN_NO_ONE")
		}
		
		if (get_pcvar_num(cvar_winner_sounds))
		{
			ArrayGetString(g_sound_win_no_one, random_num(0, ArraySize(g_sound_win_no_one) - 1), sound, charsmax(sound))
			PlaySoundToClients(sound, 0)
		}
	}
}

// Block some text messages
public message_textmsg()
{
	new textmsg[22]
	static winmsg[32]
	get_msg_arg_string(2, textmsg, charsmax(textmsg))
	
	// Game restarting/game commencing, reset scores
	if (equal(textmsg, "#Game_will_restart_in") || equal(textmsg, "#Game_Commencing"))
	{
		g_ScoreHumans = 0
		g_ScoreZombies = 0
	}
	// Block round end related messages
	if (!get_pcvar_num(cvar_winner_show_hud))
	{
		if (equal(textmsg, "#Terrorists_Win"))
		{
			formatex(winmsg, 31, "%L", LANG_PLAYER, "WIN_ZOMBIE")
			set_msg_arg_string(2, winmsg)
			//return PLUGIN_HANDLED;
		}
		else if (equal(textmsg, "#CTs_Win") || equal(textmsg, "#Hostages_Not_Rescued") || equal(textmsg, "#Target_Saved"))
		{
			formatex(winmsg, 31, "%L", LANG_PLAYER, "WIN_HUMAN")
			set_msg_arg_string(2, winmsg)
			//return PLUGIN_HANDLED;
		}
		else if (equal(textmsg, "#Round_Draw"))
			return PLUGIN_HANDLED
	}
	else if (equal(textmsg, "#Hostages_Not_Rescued") || equal(textmsg, "#Round_Draw") || equal(textmsg, "#Terrorists_Win") || equal(textmsg, "#CTs_Win"))
		return PLUGIN_HANDLED;
	
	return PLUGIN_CONTINUE;
}

// Block CS round win audio messages, since we're playing our own instead
public message_sendaudio()
{
	new audio[17]
	get_msg_arg_string(2, audio, charsmax(audio))
	
	if(equal(audio[7], "terwin") || equal(audio[7], "ctwin") || equal(audio[7], "rounddraw"))
		return PLUGIN_HANDLED;
	
	return PLUGIN_CONTINUE;
}

// Send actual team scores (T = zombies // CT = humans)
public message_teamscore()
{
	new team[2]
	get_msg_arg_string(1, team, charsmax(team))
	
	switch (team[0])
	{
		// CT
		case 'C': set_msg_arg_int(2, get_msg_argtype(2), g_ScoreHumans)
		// Terrorist
		case 'T': set_msg_arg_int(2, get_msg_argtype(2), g_ScoreZombies)
	}
}

// Plays a sound on clients
PlaySoundToClients(const sound[], stop_sounds_first = 0)
{
	if (stop_sounds_first)
	{
		if (equal(sound[strlen(sound)-4], ".mp3"))
			client_cmd(0, "stopsound; mp3 play ^"sound/%s^"", sound)
		else
			client_cmd(0, "mp3 stop; stopsound; spk ^"%s^"", sound)
	}
	else
	{
		if (equal(sound[strlen(sound)-4], ".mp3"))
			client_cmd(0, "mp3 play ^"sound/%s^"", sound)
		else
			client_cmd(0, "spk ^"%s^"", sound)
	}
}
Attached Files
File Type: sma Get Plugin or Get Source (zp50_team_scoring.sma - 98 views - 7.7 KB)

Last edited by Fawkes37; 08-08-2020 at 18:22.
Fawkes37 is offline
Fawkes37
Senior Member
Join Date: Jul 2008
Old 08-08-2020 , 18:21   Re: "No one wins..." adds to Terrorist teamscore
Reply With Quote #2

Seems this is a bug in ZP, as "message_teamscore" is written but not registered in zp50_team_scoring.sma. To fix, just add the following line to plugin_init():

Code:
register_message(get_user_msgid("TeamScore"), "message_teamscore")

Last edited by Fawkes37; 08-08-2020 at 18:22.
Fawkes37 is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 07:43.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode