Raised This Month: $ Target: $400
 0% 

Hello World plugin


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
LeOp4rD
New Member
Join Date: Jul 2022
Location: Algeria
Old 04-04-2024 , 01:17   Hello World plugin
Reply With Quote #1

Hello, I'm totally new to this, i wanted to start by creating a simple plugin that displays 'Hello World' to the player who prints 'Hello' in the message chat, but nothing happened :

#include "amxmodx"

public plugin_init(){
register_plugin("Greetings", "1.0.0", "LeOpArD")
register_concmd("Say Hello", "sayHello")
}
public sayHello(client){
client_print(client, print_chat, "HelloWorld")
}

//btw the plugin is registered in plugins.ini file and has been properly loaded into the server,
would apperciate some guides here
LeOp4rD is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 04-04-2024 , 03:29   Re: Hello World plugin
Reply With Quote #2

You can verify that your plugin is running by using the "amxx list" command in the server's console. It will list all the plugins and tell you if any of them have failed to load.

Secondly, any "say" commands should be registered as client commands with register_clcmd(). Also, always assume that everything is case sensitive if you're not 100% sure or have not verified otherwise. In this case, the "say" command is "say" not "Say". Based on my testing, the "Hello" in "say Hello" is case insensitive, probably because it's not part of the "say" command.

Finally, it is traditional in AMX Mod X plugins to include libraries, the library name is surrounded by angle brackets e.g. #include <amxmodx>. I think in other languages, the way you do this has significant meaning but I don't think that is the case here. When in Rome, . . .

One very important thing you'll want to do when learning how to write plugins is to find a plugin that already does something similar to what you want and see how they do it. There are many plugins that register various "say" commands.
__________________

Last edited by fysiks; 04-04-2024 at 03:30.
fysiks is offline
Old 04-04-2024, 11:32
Bugsy
This message has been deleted by Bugsy.
Tote
Senior Member
Join Date: Jul 2023
Old 04-04-2024 , 14:40   Re: Hello World plugin
Reply With Quote #3

Code:
#include <amxmodx>

public plugin_init() {
	register_plugin("Greetings", "1.0", "Author")
	register_clcmd("say hello", "func_hello")
}

public func_hello(id) {
	client_print(id, print_chat, "Hello World!")
}
1. "amxmodx" -> <amxmodx>
2. Say -> say
3. It's fine to use concmd but put small "say" and it's better to use clcmd
4. As fysiks said

Last edited by Tote; 04-04-2024 at 14:42.
Tote is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 04-04-2024 , 17:20   Re: Hello World plugin
Reply With Quote #4

Quote:
Originally Posted by Tote View Post
3. It's fine to use concmd but put small "say" and it's better to use clcmd
"say" is a client command and should and should be registered as such. Console commands are commands that can be executed and function correctly from either the server or client console. Technically, in the case of the "say" command, you can execute it from the server console but, based on my testing, it does not appear to be work even when registering the command as a console command.
__________________
fysiks 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 02:49.


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