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

Solved List of events sequence


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Dragokas
Veteran Member
Join Date: Nov 2017
Location: Ukraine on fire
Old 05-24-2018 , 13:56   List of events sequence
Reply With Quote #1

Hi,

where can I find it.

Actually, I need an event that happens right before OnMapStart.

Thanks,
Alex.
__________________
Expert of CMD/VBS/VB6. Malware analyst. L4D fun (Bloody Witch & FreeZone)
[My plugins] [My tools] [GitHub] [Articles] [HiJackThis+] [Donate]

Last edited by Dragokas; 05-29-2018 at 09:16.
Dragokas is offline
ambn
Veteran Member
Join Date: Feb 2015
Location: Fun servers
Old 05-25-2018 , 01:32   Re: List of events sequence
Reply With Quote #2

Maybe try https://wiki.alliedmods.net/Generic_...ts#game_newmap
And set EventHookMode to EventHookMode_Pre?
__________________
ambn is offline
Dragokas
Veteran Member
Join Date: Nov 2017
Location: Ukraine on fire
Old 05-25-2018 , 09:11   Re: List of events sequence
Reply With Quote #3

Include every possible hook in script and write result in log-file? Maybe.
__________________
Expert of CMD/VBS/VB6. Malware analyst. L4D fun (Bloody Witch & FreeZone)
[My plugins] [My tools] [GitHub] [Articles] [HiJackThis+] [Donate]
Dragokas is offline
Dragokas
Veteran Member
Join Date: Nov 2017
Location: Ukraine on fire
Old 05-25-2018 , 09:35   Re: List of events sequence
Reply With Quote #4

---------
__________________
Expert of CMD/VBS/VB6. Malware analyst. L4D fun (Bloody Witch & FreeZone)
[My plugins] [My tools] [GitHub] [Articles] [HiJackThis+] [Donate]

Last edited by Dragokas; 05-25-2018 at 09:38.
Dragokas is offline
8guawong
AlliedModders Donor
Join Date: Dec 2013
Location: BlackMarke7
Old 05-25-2018 , 10:23   Re: List of events sequence
Reply With Quote #5

Quote:
Originally Posted by Dragokas View Post
Include every possible hook in script and write result in log-file? Maybe.
i guess
__________________
8guawong is offline
Mitchell
~lick~
Join Date: Mar 2010
Old 05-25-2018 , 10:38   Re: List of events sequence
Reply With Quote #6

I've never came came across this issue but from a guess OnMapEnd() is send right before OnMapStart()
Mitchell is offline
Dragokas
Veteran Member
Join Date: Nov 2017
Location: Ukraine on fire
Old 05-25-2018 , 11:16   Re: List of events sequence
Reply With Quote #8

I've always been lazy to make such a long plugin.
sm_cvar net_showevents 2 command is not always convinient.

Anyway, here it is, just someone need the same:
- List Basic Source Events (not game specific).
- List all Forwards
- "sm_seq_finish" command to stop logging and save file to "addons/sourcemod/logs/Events_seq.log".

Code:
#define PLUGIN_VERSION		"1.0"

#pragma semicolon 1
#pragma newdecls required

#include <sourcemod>

public Plugin myinfo =
{
	name = "[ANY] Events sequence catcher",
	author = "Dragokas",
	description = "List the sequence of basic events and forwards raised in-game.",
	version = PLUGIN_VERSION,
	url = "https://forums.alliedmods.net/showthread.php?p=2593805"
}

File g_hLog;
bool g_bLockFile;

public void OnPluginStart()
{
	char sLog[PLATFORM_MAX_PATH] = "addons/sourcemod/logs/Events_seq.log";

	g_hLog = OpenFile(sLog, "a+");
	if( g_hLog == null )
	{
		PrintToServer("[EVENTS_SEQ] Failed to create temporary file: %s", sLog);
		return;
	}

	RegAdminCmd("sm_seq_finish",		CmdLogFinish,		ADMFLAG_ROOT);

	// Generic Source Events

	HookEvent("team_info",						Events_Handler,	EventHookMode_Pre);
	HookEvent("team_score",						Events_Handler,	EventHookMode_Pre);
	HookEvent("teamplay_broadcast_audio",		Events_Handler,	EventHookMode_Pre);
	HookEvent("player_team",					Events_Handler,	EventHookMode_Pre);
	HookEvent("player_class",					Events_Handler,	EventHookMode_Pre);
	HookEvent("player_death",					Events_Handler,	EventHookMode_Pre);
	HookEvent("player_hurt",					Events_Handler,	EventHookMode_Pre);
	HookEvent("player_chat",					Events_Handler,	EventHookMode_Pre);
	HookEvent("player_score",					Events_Handler,	EventHookMode_Pre);
	HookEvent("player_spawn",					Events_Handler,	EventHookMode_Pre);
	HookEvent("player_shoot",					Events_Handler,	EventHookMode_Pre);
	HookEvent("player_use",						Events_Handler,	EventHookMode_Pre);
	HookEvent("player_changename",				Events_Handler,	EventHookMode_Pre);
	HookEvent("player_hintmessage",				Events_Handler,	EventHookMode_Pre);
	HookEvent("game_init",						Events_Handler,	EventHookMode_Pre);
	HookEvent("game_newmap",					Events_Handler,	EventHookMode_Pre);
	HookEvent("game_start",						Events_Handler,	EventHookMode_Pre);
	HookEvent("game_end",						Events_Handler,	EventHookMode_Pre);
	HookEvent("round_start",					Events_Handler,	EventHookMode_Pre);
	HookEvent("round_end",						Events_Handler,	EventHookMode_Pre);
	HookEvent("game_message",					Events_Handler,	EventHookMode_Pre);
	HookEvent("break_breakable",				Events_Handler,	EventHookMode_Pre);
	HookEvent("break_prop",						Events_Handler,	EventHookMode_Pre);
	HookEvent("entity_killed",					Events_Handler,	EventHookMode_Pre);
	HookEvent("bonus_updated",					Events_Handler,	EventHookMode_Pre);
	HookEvent("achievement_event",				Events_Handler,	EventHookMode_Pre);
	HookEvent("physgun_pickup",					Events_Handler,	EventHookMode_Pre);
	HookEvent("flare_ignite_npc",				Events_Handler,	EventHookMode_Pre);	
	HookEvent("helicopter_grenade_punt_miss",	Events_Handler,	EventHookMode_Pre);	
	HookEvent("user_data_downloaded",			Events_Handler,	EventHookMode_Pre);	
	HookEvent("ragdoll_dissolved",				Events_Handler,	EventHookMode_Pre);	
	HookEvent("vote_ended",						Events_Handler,	EventHookMode_Pre);	
	HookEvent("vote_started",					Events_Handler,	EventHookMode_Pre);	
	HookEvent("vote_changed",					Events_Handler,	EventHookMode_Pre);	
	HookEvent("vote_passed",					Events_Handler,	EventHookMode_Pre);	
	HookEvent("vote_failed",					Events_Handler,	EventHookMode_Pre);	

//	Commented, because raise error "event doesn't exist", at least in L4D server

//	HookEvent("base_player_teleported",			Events_Handler,	EventHookMode_Pre);
//	HookEvent("achievement_increment",			Events_Handler,	EventHookMode_Pre);
//	HookEvent("hltv_changed_mode",				Events_Handler,	EventHookMode_Pre);	
//	HookEvent("hltv_changed_target",			Events_Handler,	EventHookMode_Pre);	
//	HookEvent("vote_cast",						Events_Handler,	EventHookMode_Pre);	
//	HookEvent("vote_options",					Events_Handler,	EventHookMode_Pre);	
//	HookEvent("replay_saved",					Events_Handler,	EventHookMode_Pre);	
//	HookEvent("entered_performance_mode",		Events_Handler,	EventHookMode_Pre);	
//	HookEvent("browse_replays",					Events_Handler,	EventHookMode_Pre);	
//	HookEvent("replay_youtube_stats",			Events_Handler,	EventHookMode_Pre);	
//	HookEvent("inventory_updated",				Events_Handler,	EventHookMode_Pre);	
//	HookEvent("cart_updated",					Events_Handler,	EventHookMode_Pre);	
//	HookEvent("store_pricesheet_updated",		Events_Handler,	EventHookMode_Pre);	
//	HookEvent("gc_connected",					Events_Handler,	EventHookMode_Pre);	
//	HookEvent("item_schema_initialized",		Events_Handler,	EventHookMode_Pre);	

	// Another games' events
	// TODO
}

// ===================== Helpers =========================

public Action CmdLogFinish(int client, int args)
{
	g_bLockFile = true;
	FlushFile(g_hLog);
	g_hLog.Close();
	g_hLog = null;
	if (client != 0)
		PrintToChat(client, "Log file is flushed.");
	return Plugin_Handled;
}

void LogString(const char[] format, any ...)
{
	char buffer[200];
	if (!g_bLockFile && g_hLog != null) {
		VFormat(buffer, sizeof(buffer), format, 2);
		Format(buffer, sizeof(buffer), "[EVENTS_SEQ] %i: %s", GetTime(), buffer);
		g_hLog.WriteLine(buffer);
	}
}

// ====================== Events =========================

public void Events_Handler(Event event, const char[] name, bool dontBroadcast)
{
	LogString("{Event} %s", name);
}

// ====================== Forwards =======================

/*
public bool AskPluginLoad(Handle myself, bool late, char[] error, int err_max) // replaced by => AskPluginLoad2
{
	LogString("{Forward} AskPluginLoad");
}*/

public APLRes AskPluginLoad2(Handle myself, bool late, char[] error, int err_max)
{
	LogString("{Forward} AskPluginLoad2");
}

public void OnAllPluginsLoaded()
{
	LogString("{Forward} OnAllPluginsLoaded");
}

public void OnAutoConfigsBuffered()
{
	LogString("{Forward} OnAutoConfigsBuffered");
}

public bool OnClientFloodCheck(int client)
{
	LogString("{Forward} OnClientFloodCheck");
}

public void OnClientFloodResult(int client, bool blocked)
{
	LogString("{Forward} OnClientFloodResult");
}

public void OnConfigsExecuted()
{
	LogString("{Forward} OnConfigsExecuted");
}

/*
public void OnGameFrame()
{
}*/

public void OnLibraryAdded(const char[] name)
{
	LogString("{Forward} OnLibraryAdded");
}

public void OnLibraryRemoved(const char[] name)
{
	LogString("{Forward} OnLibraryRemoved");
}

public void OnMapEnd()
{
	LogString("{Forward} OnMapEnd");
}

public void OnMapStart()
{
	LogString("{Forward} OnMapStart");
}

public void OnPluginEnd()
{
	LogString("{Forward} OnPluginEnd");
	CmdLogFinish(0, 0);
}

public void OnPluginPauseChange(bool pause)
{
	LogString("{Forward} OnPluginPauseChange");
}

/*
public void OnPluginStart()
{
}*/

/*
public void OnServerCfg() // replaced by => OnConfigsExecuted()
{
	LogString("{Forward} OnServerCfg");
}*/
Result is something like this:
Quote:
[EVENTS_SEQ] 1527260054: {Forward} OnLibraryAdded
[EVENTS_SEQ] 1527260054: {Forward} OnLibraryAdded
[EVENTS_SEQ] 1527260054: {Forward} OnAllPluginsLoaded
[EVENTS_SEQ] 1527260056: {Event} round_start
[EVENTS_SEQ] 1527260056: {Forward} OnMapStart
[EVENTS_SEQ] 1527260056: {Forward} OnAutoConfigsBuffered
[EVENTS_SEQ] 1527260056: {Forward} OnConfigsExecuted
[EVENTS_SEQ] 1527260086: {Event} player_team
[EVENTS_SEQ] 1527260086: {Event} player_spawn
[EVENTS_SEQ] 1527260086: {Event} player_team
[EVENTS_SEQ] 1527260086: {Event} player_spawn
[EVENTS_SEQ] 1527260086: {Event} player_team
[EVENTS_SEQ] 1527260086: {Event} player_spawn
[EVENTS_SEQ] 1527260086: {Event} player_team
[EVENTS_SEQ] 1527260086: {Event} player_spawn
[EVENTS_SEQ] 1527260103: {Forward} OnClientFloodCheck
[EVENTS_SEQ] 1527260103: {Forward} OnClientFloodResult
[EVENTS_SEQ] 1527260105: {Event} player_use
[EVENTS_SEQ] 1527260106: {Event} player_use
[EVENTS_SEQ] 1527260106: {Event} player_use
[EVENTS_SEQ] 1527260106: {Event} player_use
[EVENTS_SEQ] 1527260107: {Event} player_use
[EVENTS_SEQ] 1527260107: {Forward} OnMapEnd
[EVENTS_SEQ] 1527260108: {Event} round_start
[EVENTS_SEQ] 1527260108: {Forward} OnMapStart
So, the most usefull event for my task is a forward "OnAutoConfigsBuffered".
Quote:
This is called once, right after OnMapStart() but any time before OnConfigsExecuted(). It is called after the "exec sourcemod.cfg" command and all AutoExecConfig() exec commands have been added to the ServerCommand() buffer.

If you need to load per-map settings that override default values, adding commands to the ServerCommand() buffer here will guarantee that they're set before OnConfigsExecuted().

Unlike OnMapStart() and OnConfigsExecuted(), this is not called on late loads that occur after OnMapStart().
Anybody know what is mean "bolded" part?
__________________
Expert of CMD/VBS/VB6. Malware analyst. L4D fun (Bloody Witch & FreeZone)
[My plugins] [My tools] [GitHub] [Articles] [HiJackThis+] [Donate]
Dragokas is offline
Dragokas
Veteran Member
Join Date: Nov 2017
Location: Ukraine on fire
Old 05-25-2018 , 11:18   Re: List of events sequence
Reply With Quote #9

hehe, nice one, breeeezy!
Thanks. My bearish labor is now useless.
__________________
Expert of CMD/VBS/VB6. Malware analyst. L4D fun (Bloody Witch & FreeZone)
[My plugins] [My tools] [GitHub] [Articles] [HiJackThis+] [Donate]
Dragokas is offline
Silvers
SourceMod Plugin Approver
Join Date: Aug 2010
Location: SpaceX
Old 05-25-2018 , 12:14   Re: List of events sequence
Reply With Quote #10

Events are not guaranteed to fire in any order. round_start can fire before or after OnMapStart() forward.
__________________
Silvers 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 04:48.


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