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

Solved Sourcemod "My first ever plugin" not printing to console.


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
lowheartrate
Member
Join Date: Apr 2015
Location: United States, New York
Old 04-18-2017 , 01:47   Sourcemod "My first ever plugin" not printing to console.
Reply With Quote #1

I am following this Introduction to SourceMod Plugins tutorial trying to learn how to code Sourcemod plugins and on the getting code to run portion of the article. After I compiled the following code using the compiler recommended, and adding the .smx file into my server /addons/sourcemod/plugins/ folder it doesn't seem to print anything in the console as it should. Not sure what it is I am doing wrong as my code looks exactly as they say it should.

Code:
#include <sourcemod>
 
public Plugin myinfo =
{
	name = "my first plugin",
	author = "lowheartrate",
	description = "my first plugin ever",
	version = "1.0",
	url = "http://www.sourcemod.net/"
};
 
public void OnPluginStart()
{
	PrintToServer("Hello world!");
}
__________________

Last edited by lowheartrate; 04-18-2017 at 04:07.
lowheartrate is offline
Sillium
AlliedModders Donor
Join Date: Sep 2008
Location: Germany
Old 04-18-2017 , 02:08   Re: Sourcemod "My first ever plugin" not printing to console.
Reply With Quote #2

Did you drop the plugin in the folder while the server was running? Did you load the plugin?
__________________
brb, dishes have developed their own language and are talking to the garbage about overthrowing me... i must correct this

www.unterwasserpyromanen.de
Sillium is offline
lowheartrate
Member
Join Date: Apr 2015
Location: United States, New York
Old 04-18-2017 , 02:14   Re: Sourcemod "My first ever plugin" not printing to console.
Reply With Quote #3

Quote:
Originally Posted by Sillium View Post
Did you drop the plugin in the folder while the server was running? Did you load the plugin?
I put the plugin in /addons/sourcemod/plugins while server was offline and rebooted it afterwards. I did not do anything other then dropping the plugin in /plugins/ folder and not sure what command to use in console to load a plugin...

EDIT: I got it to work but had to unload the plugin first and load it back up for it to display "Hello World!". Not sure if I am supposed to see it as I join the server or what.
Code:
sm_rcon sm plugins unload plugin
sm_rcon sm plugins load plugin
__________________

Last edited by lowheartrate; 04-18-2017 at 02:23.
lowheartrate is offline
ddhoward
Veteran Member
Join Date: May 2012
Location: California
Old 04-18-2017 , 03:00   Re: Sourcemod "My first ever plugin" not printing to console.
Reply With Quote #4

You've placed the code in OnPluginStart(), which means it happens when the plugin starts. Further, you've used PrintToServer(), which prints to the server, and not to players.

If you want to display the message to players as they join, you will need to use OnClientPutInServer() or something similar, and PrintToChat().
__________________

Last edited by ddhoward; 04-18-2017 at 03:02.
ddhoward is offline
lowheartrate
Member
Join Date: Apr 2015
Location: United States, New York
Old 04-18-2017 , 03:02   Re: Sourcemod "My first ever plugin" not printing to console.
Reply With Quote #5

Quote:
Originally Posted by ddhoward View Post
You've placed the code in OnPluginStart(), which means it happens when the plugin starts. Further, you've used PrintToServer(), which prints to the server, and not to players.
Okay, so really "Hello World!" is being displayed as soon as server goes live and the plugin(s) are loaded. That's why I only seen it when I manually reloaded the plugin?!
__________________
lowheartrate is offline
ddhoward
Veteran Member
Join Date: May 2012
Location: California
Old 04-18-2017 , 03:04   Re: Sourcemod "My first ever plugin" not printing to console.
Reply With Quote #6

Quote:
Originally Posted by lowheartrate View Post
Okay, so really "Hello World!" is being displayed as soon as server goes live and the plugin(s) are loaded. That's why I only seen it when I manually reloaded the plugin?!
Correct. I've edited my previous post with alternative forwards and functions to result in the behavior that you expected.
__________________
ddhoward 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 19:31.


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