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

Solved Executing an include file on server start - Does not work?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Afonso
New Member
Join Date: Jul 2020
Old 07-11-2020 , 11:22   Executing an include file on server start - Does not work?
Reply With Quote #1

Hi everyone!
I'm looking for a solution, I think that might be easy...
So, I have one plugin (smx) and an include, I want that when server start, automatically execute de Include file too!
Here is the example:

Main Plugin File:
PHP Code:
#include <sourcemod>
#include "include_file.sp"
public void OnPluginStart()
{
SetPluginWork();

Include File:
PHP Code:
#include <SteamWorks>
public void SetPluginWork()
{
PrintToServer("The Include file started!");

Basically, when I start my server, the "PrintToServer("The Include file started!");" is not printed and anything that I run on that function "SetPluginWork()" not works. If I unload and load the Main Plugin the function SetPluginWork() start working with any problem...
So, is there any possibility to run that function at server start without needing unload and load the main plugin?

Thank you!

Last edited by Afonso; 07-11-2020 at 17:30.
Afonso is offline
MAGNAT2645
Senior Member
Join Date: Nov 2015
Location: AlliedMods.net
Old 07-11-2020 , 12:53   Re: Executing an include file on server start - Does not work?
Reply With Quote #2

1) You shouldn't use public keyword for functions that are not callbacks.
2) Your code prints message on plugin start (actually not on server start) so if you reload plugin, late plugin load happens and you see your message but if plugin loads normally (not by reloading etc.) then you could have just missed your message (many plugins load very early, after server start), you can try to log same message.
Like:
Code:
public void SetPluginWork()
{
PrintToServer("The Include file started!");
LogMessage("The Include file started!");
}
then restart your server (if it's working now) and check logs in /addons/sourcemod/logs.
__________________

Last edited by MAGNAT2645; 07-11-2020 at 12:55.
MAGNAT2645 is offline
Afonso
New Member
Join Date: Jul 2020
Old 07-11-2020 , 17:29   Re: Executing an include file on server start - Does not work?
Reply With Quote #3

That's it!
Thank you
Quote:
Originally Posted by MAGNAT2645 View Post
1) You shouldn't use public keyword for functions that are not callbacks.
2) Your code prints message on plugin start (actually not on server start) so if you reload plugin, late plugin load happens and you see your message but if plugin loads normally (not by reloading etc.) then you could have just missed your message (many plugins load very early, after server start), you can try to log same message.
Like:
Code:
public void SetPluginWork()
{
PrintToServer("The Include file started!");
LogMessage("The Include file started!");
}
then restart your server (if it's working now) and check logs in /addons/sourcemod/logs.
Afonso 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 21:07.


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