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

Plugin does not call OnPluginStart when changing map


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
marco811
New Member
Join Date: Jul 2019
Old 07-13-2019 , 19:39   Plugin does not call OnPluginStart when changing map
Reply With Quote #1

Hello. I am creating my first plugin but I have some serious problems. I was testing on my CSGO server in linux and when I changed the map the plugin does not call OnPluginStart. I thought it was a server problem, I installed a clean server on my computer (windows) and I have exactly the same problem.

My plugin:

Code:
#include <sourcemod>

public Plugin myinfo = {
	name = "Test plugin",
	author = "",
	description = "",
	version = "1.0",
	url = ""
};

public void OnPluginStart() {
	LogMessage("======================HELLO WORLD=========================");
}
My log file:
Code:
L 07/14/2019 - 01:36:47: SourceMod log file session started (file "L20190714.log") (Version "1.9.0.6281")
L 07/14/2019 - 01:36:47: -------- Mapchange to de_dust2 --------
L 07/14/2019 - 01:36:47: [test_plugin.smx] ======================HELLO WORLD=========================
L 07/14/2019 - 01:37:03: -------- Mapchange to de_dust2 --------
L 07/14/2019 - 01:37:11: -------- Mapchange to de_dust2 --------
L 07/14/2019 - 01:37:32: -------- Mapchange to de_dust2 --------
What am I doing wrong?
marco811 is offline
xines
Veteran Member
Join Date: Aug 2013
Location: Denmark
Old 07-13-2019 , 20:00   Re: Plugin does not call OnPluginStart when changing map
Reply With Quote #2

https://sm.alliedmods.net/new-api/sourcemod/OnMapStart
__________________
xines is offline
ddhoward
Veteran Member
Join Date: May 2012
Location: California
Old 07-13-2019 , 22:00   Re: Plugin does not call OnPluginStart when changing map
Reply With Quote #3

Plugins don't restart when the map changes...?
__________________
ddhoward is offline
dustinandband
Senior Member
Join Date: May 2015
Old 07-14-2019 , 00:47   Re: Plugin does not call OnPluginStart when changing map
Reply With Quote #4

and in some situations OnMapStart() doesn't get called either. For example, in Left 4 Dead 2 survival, between when a round ends and the map restarts - OnMapStart() doesn't get called but if you hook the event "round_start" that gets called.

Only posting this cause I had to specifically debug that in a recent plugin. I'd imagine that's the equivalent of a round ending and another round starting in CS:GO.
dustinandband is offline
marco811
New Member
Join Date: Jul 2019
Old 07-14-2019 , 04:14   Re: Plugin does not call OnPluginStart when changing map
Reply With Quote #5

Quote:
Originally Posted by xines View Post
Thank you. This was the solution
marco811 is offline
xines
Veteran Member
Join Date: Aug 2013
Location: Denmark
Old 07-14-2019 , 05:10   Re: Plugin does not call OnPluginStart when changing map
Reply With Quote #6

Quote:
Originally Posted by ddhoward View Post
Plugins don't restart when the map changes...?
PHP Code:
/**
 * Called when the plugin is fully initialized and all known external references 
 * are resolved. This is only called once in the lifetime of the plugin, and is 
 * paired with OnPluginEnd().
 *
 * If any run-time error is thrown during this callback, the plugin will be marked 
 * as failed.
 *
 * It is not necessary to close any handles or remove hooks in this function.  
 * SourceMod guarantees that plugin shutdown automatically and correctly releases 
 * all resources.
 *
 * @noreturn
 */
forward void OnPluginStart(); 
Further reference: https://wiki.alliedmods.net/Introduc...ng_code_to_run
__________________
xines is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 07-14-2019 , 13:17   Re: Plugin does not call OnPluginStart when changing map
Reply With Quote #7

Quote:
Originally Posted by dustinandband View Post
and in some situations OnMapStart() doesn't get called either. For example, in Left 4 Dead 2 survival, between when a round ends and the map restarts - OnMapStart() doesn't get called but if you hook the event "round_start" that gets called.

Only posting this cause I had to specifically debug that in a recent plugin. I'd imagine that's the equivalent of a round ending and another round starting in CS:GO.
Well yeah, OnMapStart is called on map load, not for a round change. Players get disconnected/reconnected and the server executes certain config files on map changes... none of which happens on round changes.
__________________
Not currently working on SourceMod plugin development.
Powerlord 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 20:50.


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