Raised This Month: $51 Target: $400
 12% 

Creating events.


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Halt
Senior Member
Join Date: Jan 2015
Location: Black Mesa
Old 10-25-2017 , 23:20   Creating events.
Reply With Quote #1

I'm having an issue reseting the game when "zombies" (red team) wins the round. They do this by killing all humans (blue team). Blue team wins when the time runs out. When the maps time runs out the game fires teamplay_round_win. And I have it hooked so the following happens, and it works when the map runs out of time.

Code:
public Action RoundWin(Event event, const char[] name, bool dontBroadcast)
{
	HasRoundStarted = false;
	TFTeam WinningTeam = view_as< TFTeam >( event.GetInt("team"));
	
	if	(WinningTeam == TFTeam_Red)
	{
		PrintToChatAll("\x07ff2929[\x0730FF31ZomXR\x07ff2929] - \x07e3f010Humanity has failed. Zombies Win!");
		EmitSoundToAll("ui/halloween_boss_summoned_monoculus.wav");
	}
	else if	(WinningTeam == TFTeam_Blue)
		PrintToChatAll("\x07ff2929[\x0730FF31ZomXR\x07ff2929] - \x07e3f010Humans have prevailed!");
	
	for	(int IGC; IGC <= MaxClients; IGC++)
	{
		if	(IsClientInGame(IGC) && bIsPlayerZombie[IGC])
		{
			CreateTimer(0.5, RespawnPlayer, GetClientUserId(IGC), TIMER_FLAG_NO_MAPCHANGE);
			PrintToChat(IGC, "You've been respawned cuz u were a zambie");
		}
	}
}
The issue is when all humans are dead the mod has to manually fire "teamplay_round_win" like so

Code:
public Action At_Player_Death(Event event, const char[] name, bool dontBroadcast) 
{
	int Client = GetClientOfUserId(GetEventInt(event, "userid"));
	int RedTeamCount = GetTeamClientCount(2)
	int BlueTeamCount = GetTeamClientCount(3)
	
	if (RedTeamCount >= 1 && BlueTeamCount <= 0)
	{
		Event RoundForceWin = CreateEvent("teamplay_round_win", false);
		RoundForceWin.SetInt("team", 2);
		RoundForceWin.Fire();
		PrintToChatAll("mp_forcewin fired zombies win");
	}
	
	CreateTimer(0.5, RespawnPlayer, GetClientUserId(Client), TIMER_FLAG_NO_MAPCHANGE);
}
The problem is that when I manually fire teamplay_round_win in the block of code above the round does not reset as if it would when called when the map runs out of time. Any ideas?

Last edited by Halt; 10-25-2017 at 23:21.
Halt is offline
8guawong
AlliedModders Donor
Join Date: Dec 2013
Location: BlackMarke7
Old 10-25-2017 , 23:50   Re: Creating events.
Reply With Quote #2

donno much about TF2
but maybe this plugin will help?

https://forums.alliedmods.net/showthread.php?p=1756067
__________________
8guawong is offline
Halt
Senior Member
Join Date: Jan 2015
Location: Black Mesa
Old 10-26-2017 , 10:26   Re: Creating events.
Reply With Quote #3

See Darth just creates the game_round_win entity which is already in my map. Perhaps I'll just have the mod create one too.
Halt is offline
Halt
Senior Member
Join Date: Jan 2015
Location: Black Mesa
Old 10-26-2017 , 10:32   Re: Creating events.
Reply With Quote #4

Basically stole Darths method but here it is for anyone who might be trying to accomplish something similar.

Code:
		if (RedTeamCount >= 1 && BlueTeamCount <= 0)
		{
			RoundWinEnt = CreateEntityByName("game_round_win");
			
			if (IsValidEntity(RoundWinEnt))
			{
				DispatchSpawn(RoundWinEnt);
				AcceptEntityInput(RoundWinEnt, "SetTeam", 2);
				AcceptEntityInput(RoundWinEnt, "RoundWin");
				PrintToChatAll("mp_forcewin fired zombies win");
			}
			AcceptEntityInput(RoundWinEnt, "Kill");
		}
Halt is offline
xerox8521
Senior Member
Join Date: Sep 2011
Old 10-26-2017 , 13:41   Re: Creating events.
Reply With Quote #5

Events are usually for either bot stuff (used in cs for example to tell the AI bots that a hostage has been rescued) or simply tell the client to do something based on the event.
xerox8521 is offline
Reply



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 14:30.


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