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

Why map_transition (or round_end) event is not happen on map end?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Dragokas
Veteran Member
Join Date: Nov 2017
Location: Ukraine on fire
Old 10-23-2018 , 12:03   Why map_transition (or round_end) event is not happen on map end?
Reply With Quote #1

Hi,
I'm interested in correct clearing variables when map end.

Previously, I used coupe of hooks, like:
Code:
			HookEvent("round_end", 				Event_RoundEnd,		EventHookMode_PostNoCopy);
			HookEvent("finale_win", 			Event_RoundEnd,		EventHookMode_PostNoCopy);
			HookEvent("mission_lost", 			Event_RoundEnd,		EventHookMode_PostNoCopy);
			HookEvent("map_transition", 		Event_RoundEnd,		EventHookMode_PostNoCopy);
However I noticed, when I e.g. loaded 2-nd map and I finished voting for transition to 1-st map ("start new campaign" menu item), I'm receving no round_end and no map_transition events:

Quote:
L 10/23/2018 - 18:45:49: [say_event.smx] 2018-10-23, 18:45:49 - EVENT_HAPPENED ---> "vote_started"
L 10/23/2018 - 18:45:49: "Dragokas<2><STEAM_1:1:22512941><Survivor><Bi ker><ALIVE><100+0><setpos_exact 2927.41 2905.29 78.03; setang 9.86 87.96 0.00><Area 40391>" called vote "ChangeMission Hospital"
Server event "vote_cast_yes", Tick 1608:
- "team" = "-1"
- "entityid" = "1"
L 10/23/2018 - 18:45:49: [say_event.smx] 2018-10-23, 18:45:49 - EVENT_HAPPENED ---> "vote_cast_yes"
L 10/23/2018 - 18:45:49: Vote succeeded "ChangeMission #L4D360UI_Campaign_Hospital"
Server event "vote_passed", Tick 1611:
- "details" = "#L4D_vote_passed_mission_change"
- "param1" = "#L4D360UI_Campaign_Hospital"
- "team" = "-1"
L 10/23/2018 - 18:45:49: [say_event.smx] 2018-10-23, 18:45:49 - EVENT_HAPPENED ---> "vote_passed"
L 10/23/2018 - 18:45:51: change mission now vote - changing to Hospital (l4d_hospital01_apartment)
L 10/23/2018 - 18:45:51: Preparing player entities for changelevel
L 10/23/2018 - 18:45:51: Saving Dragokas for transition at 2927.414795 2905.294189 16.031250
L 10/23/2018 - 18:45:51: (SKIN) Dragokas saved model [models/survivors/survivor_biker.mdl] via PlayerSaveData
L 10/23/2018 - 18:45:51: Saving NORMAL for map transition at 2892,3148,16
L 10/23/2018 - 18:45:51: (SKIN) Zoey saved model [models/survivors/survivor_teenangst.mdl] via PlayerSaveData
L 10/23/2018 - 18:45:51: Saving NORMAL for map transition at 2975,2922,16
L 10/23/2018 - 18:45:51: (SKIN) Bill saved model [models/survivors/survivor_namvet.mdl] via PlayerSaveData
L 10/23/2018 - 18:45:51: Saving NORMAL for map transition at 2864,3193,16
L 10/23/2018 - 18:45:51: (SKIN) Louis saved model [models/survivors/survivor_manager.mdl] via PlayerSaveData
L 10/23/2018 - 18:45:51: [say_event.smx] +-------------------------------------------+
L 10/23/2018 - 18:45:51: [say_event.smx] | MAP END |
L 10/23/2018 - 18:45:51: [say_event.smx] +-------------------------------------------+
Server event "player_left_checkpoint", Tick 1678:
- "userid" = "0"
- "entityid" = "1"
- "area" = "40391"
So, what is a reliable way to reset resources in my plugins before they are initialized on round_start?

I think:
Code:
public void OnPluginStart()
{
	HookEvent("round_end", 				Event_RoundEnd,		EventHookMode_PostNoCopy);
	HookEvent("finale_win", 			Event_RoundEnd,		EventHookMode_PostNoCopy);
	HookEvent("mission_lost", 			Event_RoundEnd,		EventHookMode_PostNoCopy);
	HookEvent("map_transition", 		Event_RoundEnd,		EventHookMode_PostNoCopy);
}

public void OnMapEnd()
{
	ResetSettings();
}
public Action Event_RoundEnd(Event event, char[] name, bool dontBroadcast)
{
	ResetSettings();
	return Plugin_Continue;
}
should be enough. + Maybe, add some bool flag to prevent calling ResetSettings() twice.

Thank you.
__________________
Expert of CMD/VBS/VB6. Malware analyst. L4D fun (Bloody Witch & FreeZone)
[My plugins] [My tools] [GitHub] [Articles] [HiJackThis+] [Donate]
Dragokas is offline
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 10-24-2018 , 03:39   Re: Why map_transition (or round_end) event is not happen on map end?
Reply With Quote #2

I would use
https://sm.alliedmods.net/new-api/sourcemod/OnMapStart

or
https://sm.alliedmods.net/new-api/so...onfigsExecuted

These forward works also when you load plugin on server in the middle of game play.
Bacardi is offline
Dragokas
Veteran Member
Join Date: Nov 2017
Location: Ukraine on fire
Old 10-24-2018 , 08:31   Re: Why map_transition (or round_end) event is not happen on map end?
Reply With Quote #3

Use OnMapStart to reset all settings before round_start?

I think it's bed idea. See:

Quote:
L 10/24/2018 - 13:51:23: [say_event.smx] 2018-10-24, 13:51:23 - EVENT_HAPPENED ---> "pounce_end"
L 10/24/2018 - 13:51:23: [say_event.smx] 2018-10-24, 13:51:23 - EVENT_HAPPENED ---> "round_start_pre_entity"
L 10/24/2018 - 13:51:23: [say_event.smx] 2018-10-24, 13:51:23 - EVENT_HAPPENED ---> "round_start_post_nav"
L 10/24/2018 - 13:51:24: [say_event.smx] 2018-10-24, 13:51:24 - EVENT_HAPPENED :::: "round_start"
L 10/24/2018 - 13:51:24: [say_event.smx] +-------------------------------------------+
L 10/24/2018 - 13:51:24: [say_event.smx] | MAP START |
L 10/24/2018 - 13:51:24: [say_event.smx] +-------------------------------------------+
L 10/24/2018 - 13:51:24: [say_event.smx] | "l4d_hospital01_apartment" |
L 10/24/2018 - 13:51:24: [say_event.smx] 2018-10-24, 13:51:24 - EVENT_HAPPENED ---> "hostname_changed"
L 10/24/2018 - 13:51:24: [say_event.smx] 2018-10-24, 13:51:24 - EVENT_HAPPENED :::: "server_cvar"
...
...
L 10/24/2018 - 13:58:25: [say_event.smx] 2018-10-24, 13:58:25 - EVENT_HAPPENED :::: "server_cvar"
L 10/24/2018 - 13:58:25: [say_event.smx] {Forward} OnAutoConfigsBuffered
L 10/24/2018 - 13:58:25: [say_event.smx] 2018-10-24, 13:58:25 - EVENT_HAPPENED ---> "round_freeze_end"
L 10/24/2018 - 13:58:25: [say_event.smx] {Forward} OnConfigsExecuted
L 10/24/2018 - 13:58:25: [say_event.smx] {Forward} OnClientConnect. Client: 1. rejectmsg: Connection rejected by game
. Maxlen: 128
L 10/24/2018 - 13:58:25: [say_event.smx] {Forward} OnClientConnected. Client: 1
L 10/24/2018 - 13:58:25: [say_event.smx] {Forward} OnClientSettingsChanged. Client: 1
L 10/24/2018 - 13:58:25: [say_event.smx] {Forward} OnClientAuthorized. Client: 1, STEAM_1:1xxxxxx
L 10/24/2018 - 13:58:28: [say_event.smx] 2018-10-24, 13:58:28 - EVENT_HAPPENED ---> "pounce_end"
L 10/24/2018 - 13:58:28: [say_event.smx] {Forward} OnClientPutInServer. Client: 1 (Dragokas), team: 0
L 10/24/2018 - 13:58:28: [say_event.smx] {Forward} OnClientPreAdminCheck. Client: 1
L 10/24/2018 - 13:58:28: [say_event.smx] {Forward} OnClientPostAdminFilter. Client: 1
L 10/24/2018 - 13:58:28: [say_event.smx] {Forward} OnClientPostAdminCheck. Client: 1
L 10/24/2018 - 13:58:28: [say_event.smx] 2018-10-24, 13:58:28 - EVENT_HAPPENED ---> "round_start_pre_entity"
L 10/24/2018 - 13:58:28: [say_event.smx] 2018-10-24, 13:58:28 - EVENT_HAPPENED ---> "round_start_post_nav"
L 10/24/2018 - 13:58:28: [say_event.smx] 2018-10-24, 13:58:28 - EVENT_HAPPENED :::: "round_start"
L 10/24/2018 - 13:58:28: [say_event.smx] 2018-10-24, 13:58:28 - EVENT_HAPPENED ---> "player_team"
In above scenario, we have 2 round_start events. First of them is happened right before OnMapStart.
If I place my reset settings code in "OnMapStart()" and init. settings code in "round_start", it broke my code logic.
__________________
Expert of CMD/VBS/VB6. Malware analyst. L4D fun (Bloody Witch & FreeZone)
[My plugins] [My tools] [GitHub] [Articles] [HiJackThis+] [Donate]

Last edited by Dragokas; 10-24-2018 at 08:32.
Dragokas is offline
MasterMind420
BANNED
Join Date: Nov 2010
Old 10-24-2018 , 08:37   Re: Why map_transition (or round_end) event is not happen on map end?
Reply With Quote #4

I think because your changing the map and its not naturally happening at the end of a map, round_end nor map_transition are being called...this is what i do to clear variables in such cases
where i need to cache a forcible map change...

Code:
public void OnPluginStart()
{
	AddCommandListener(MapChange, "sm_map");
	AddCommandListener(MapChange, "changelevel");
}

public Action MapChange(int client, const char[] cmd, int argc)
{
	if(IsValidClient(client))
	{
              //RESET VARIABLES HERE
	}
}
I'm not 100% sure but changelevel may be called also when a map ends and moves on to the next...so u may wanna leave that out, to prevent resetting your variables when u don't actually want to.

I noticed your doing this for a vote to restart the campaign or changelevel...in such a case im not sure what i gave u will work...I honestly wish valve had actually finished vote_pass event...would have made checking this easier. However you can check to see how many clients there are on the server and check to see who voted yes and no...if the tally is greater then it passes, hence you could reset the variables there as well...I had to hack something together awhile ago for something similar that your trying to do...

You can use callvote commandlistener to tell when the vote has started...its beyond me as to why valve didn't implement a simple way of telling if a vote has passed or failed...

Last edited by MasterMind420; 10-24-2018 at 08:47.
MasterMind420 is offline
Dragokas
Veteran Member
Join Date: Nov 2017
Location: Ukraine on fire
Old 10-25-2018 , 01:26   Re: Why map_transition (or round_end) event is not happen on map end?
Reply With Quote #5

Thank you.
No, my question is not directly related to vote plugin.
It was just a way to show the case when map_transition and round_end events are not happen even if map changed.
Though, thanks for tips and sample.

OnMapEnd() Forward handle such situation. So, I bet it'll be enough together with coupe of hooks in 1-st post to catch every posible round ends.
I just wanted everybody know this fact.
And also, want to know is it possible to have more compact but the same reliable code.
But, without real tests it seems nobody can answer me surely about all possible behaviours when round_end is not called (or OnMapEnd() is not called).
__________________
Expert of CMD/VBS/VB6. Malware analyst. L4D fun (Bloody Witch & FreeZone)
[My plugins] [My tools] [GitHub] [Articles] [HiJackThis+] [Donate]

Last edited by Dragokas; 10-25-2018 at 01:36.
Dragokas 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 08:16.


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