Arghreugue Posted January 6, 2008 Share Posted January 6, 2008 Hello, I need help with two simple functions. The first and 'setting up speed in a gmode. I have read the command to MTA Wiki and says: Gamespeedfunction function (sourcePlayer, command, value) SetGameSpeed (tonumber (value)) End AddCommandHandler ( "setgamespeed" gamespeedfunction) I replaced value with 10 but is not working. The command and 'right? Then I wanted to know the exact command to spawn a player. On MTA Wiki I have not found the exact function. If perhaps you please make a small gmode with a single spawn and speed, thanks. Sorry for my English. Link to comment
[email protected] Posted January 6, 2008 Share Posted January 6, 2008 Declaration of a function in LUA, as MTA uses it works as follows: function functionName( arg1, arg2, arg3, ... ) end functionName is the name of the function and arg1, arg2, arg3, etc. are the arguments the function will accept. For instance, suppose we want to create a function called "printText" and arg1 is "Hello world!" and arg2 is empty. We want the function to accept exactly 2 arguments. The function will write arg1 and arg2 to the chatbox of all players on the server, such that arg2 is directly place behind arg1 on a single line. (like: "arg1arg2") We would define the function as follows: function printText( arg1, arg2 ) outputChatBox(arg1..arg2) end arg1..arg2 means the values of both arg1 and arg2 (the actual text) will be linked into 1 whole, in difficult terms this is called concatenation. We can call the function in several ways. printText("Hello World!") or if you wish to use a commandhandler... addCommandHandler( "shout", printText ) This command handler allows us to type this in-game: /shout "Hello World!" in both cases the message "Hello World!" is sent to everyone on the server. in your code that would look like: for the normal function call: function printText( arg1, arg2 ) outputChatBox(arg1..arg2) end printText("Hello World!") for the command handler: function printText( arg1, arg2 ) outputChatBox(arg1..arg2) end addCommandHandler( "shout", printText ) Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now