Jump to content

I have a problem w/ my script.


TheDZetko

Recommended Posts

Hello all,

I have a little problem with my script. Here is the code.

function test(source) 
   outputChatBox("Hello World!", source, 255,100,10, true); 
end 
addCommandHandler("test",test) 

And here is my meta.xml file.

<meta> 
<script src="test.lua" type="server"> 
</meta> 

Here is the problem. I have both files in one folder named "test". I placed the folder to my "resources" folder. When I start the server, it says all resources started (0 failed). When I connect to my server with an account with admin rights, start the resource and type /test, it doesn't do anything.

Link to comment

Always read wiki before you use a function in your script. Wiki says

addCommandHandler will attach a scripting function (handler) to a console command, so that whenever a player or administrator uses the command the function is called. Note: You cannot use "list" or "test" as command name.

Also wiki's note:

Note: It is strongly advised that you do not use the same name for your handler function as the command name, as this can lead to confusion if multiple handler functions are used. Use a name that describes your handler's purpose more specifically.

Solution:

  
  
function Hello(source) 
  
   outputChatBox("Hello World!", source, 255,100,10, true); 
  
end 
  
addCommandHandler("yo",Hello) 

So the command is /yo

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...