AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   [small]Help with 1st plugin (https://forums.alliedmods.net/showthread.php?t=87242)

DotPT 03-08-2009 16:27

[small]Help with 1st plugin
 
I feel like crap for posting such a simple error.

I started learning Pawn language a few hours ago and i have tried to do my best in a first plugin:
-0.1 version i sucessfully made it to print a chat message 4.0 seconds after a client when he connects to the server.
-Now for the next version i want to make a HUD Message. I got an error.


Here is the code:

PHP Code:

#include <amxmodx>
#include <amxmisc>
#define PLUGIN_NAME "Welcome Message"
#define PLUGIN_VERSION "0.5"
#define PLUGIN_AUTHOR "Dotcom"


public plugin_init()   // function to register the plugin
{
    
register_plugin (PLUGIN_NAMEPLUGIN_VERSIONPLUGIN_AUTHOR)        
}

public 
client_putinserver(id)  // fuction to register that the user has entered the server
{
    
set_task(5.0"print_msg"id
    
set_task(15.0"hud_msg"id)
}

public 
print_msg(id)  // function to print a message
{
    
client_print(idprint_chat"Welcome, this is my first plugin")

public 
hud_msg(id)
    
set_hudmessage(02550, -1.0, -1.0)
    
show_hudmessage(id"hey world!")


And the error:

Code:

Error: Symbol already defined: "show_hudmessage" on line 25
As this is more like a spam thread, i'll use it for any more help i need. Thanks! :mrgreen:

Exolent[jNr] 03-08-2009 16:33

Re: [small]Help with 1st plugin
 
Code:
#include <amxmodx> #include <amxmisc> #define PLUGIN_NAME "Welcome Message" #define PLUGIN_VERSION "0.5" #define PLUGIN_AUTHOR "Dotcom" public plugin_init()   // function to register the plugin {     register_plugin (PLUGIN_NAME, PLUGIN_VERSION, PLUGIN_AUTHOR)         } public client_putinserver(id)  // fuction to register that the user has entered the server {     set_task(5.0, "print_msg", id)     set_task(15.0, "hud_msg", id) } public print_msg(id)  // function to print a message {     client_print(id, print_chat, "Welcome, this is my first plugin") } public hud_msg(id) {     set_hudmessage(0, 255, 0, -1.0, -1.0)     show_hudmessage(id, "hey world!") }

tuty 03-08-2009 16:36

Re: [small]Help with 1st plugin
 
i think this is not correct

set_hudmessage(0, 255, 0, -1.0, -1.0)

Exolent[jNr] 03-08-2009 16:39

Re: [small]Help with 1st plugin
 
Actually, that is valid.

http://www.amxmodx.org/funcwiki.php?...sage&go=search

All the arguments are default to a value, which means you don't have to pass them.
Therefore, even this is valid:
Code:
set_hudmessage();

DotPT 03-08-2009 16:57

Re: [small]Help with 1st plugin
 
Oh, well it was just for a test. Thanks for the advice Exolent, worked perfect!


All times are GMT -4. The time now is 08:54.

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