Antoni Posted April 13, 2013 Posted April 13, 2013 function createExplosion(thePlayer, command) local x,y,x = getElementPosition(thePlayer) y = y + 20 local createExplosion(x,y,z, 0) if createdExplosion == false) then outputChatBox("Failed to cause an explosion.",thePlayer) end end addCommandHandler("explosion", createExplosion) I wanted to make a simple command /explosion that will make an explosion near the player, what is wrong with it? BUY/SELL/TRADE ANYTHING RELATED TO MTA SERVER ACCOUNTS SERVER MONEY GAMEMODES SCRIPTING SERVICES
DNL291 Posted April 13, 2013 Posted April 13, 2013 Try this: function createExplosionFunc(thePlayer, command) local x,y,x = getElementPosition(thePlayer) y = y + 20 local createdExplosion = createExplosion(x,y,z, 0) if createdExplosion == false then outputChatBox("Failed to cause an explosion.",thePlayer) end end addCommandHandler("explosion", createExplosionFunc) Please do not PM me with scripting related question nor support, use the forums instead.
Antoni Posted April 13, 2013 Author Posted April 13, 2013 No I don't think that worked either. BUY/SELL/TRADE ANYTHING RELATED TO MTA SERVER ACCOUNTS SERVER MONEY GAMEMODES SCRIPTING SERVICES
DNL291 Posted April 13, 2013 Posted April 13, 2013 The code has no errors. Make sure that the meta.xml is correct and the resource is running. Please do not PM me with scripting related question nor support, use the forums instead.
Antoni Posted April 13, 2013 Author Posted April 13, 2013 Why is it createExplosionFunc and where would the explosion take place? BUY/SELL/TRADE ANYTHING RELATED TO MTA SERVER ACCOUNTS SERVER MONEY GAMEMODES SCRIPTING SERVICES
DNL291 Posted April 13, 2013 Posted April 13, 2013 You can't use a name of a MTA function (not in your case) as a name of a function. Please do not PM me with scripting related question nor support, use the forums instead.
Antoni Posted April 13, 2013 Author Posted April 13, 2013 What? I thought that was the entire point, so for each function I just make it up? BUY/SELL/TRADE ANYTHING RELATED TO MTA SERVER ACCOUNTS SERVER MONEY GAMEMODES SCRIPTING SERVICES
ixjf Posted April 13, 2013 Posted April 13, 2013 (edited) createExplosionFunc is the handler of the command - you want to call createExplosion inside of that function. You were recursively calling itself (since you overwrote createExplosion, you were now calling itself) and it will end up throwing an error. Edited April 13, 2013 by Guest I used to know how to code, but then I took an arrow in the knee. Project Redivivus - Remaking Old School MTA With New Code MTA 0.6 Nightly 1 released
Puma Posted April 13, 2013 Posted April 13, 2013 Nah, not a stack overflow, because the second time he executes createExplosion from within the createExplosion function, his createExplosion function will miss parameters (player) and will throw up an error. He himself made a createExplosion function and that overwrites the default MTA createExplosion function. Just rename your "function createExplosion(thePlayer, command)" to something else like "function createExplosionCommand (thePlayer, command)", don't forget to change "addCommandHandler("explosion", createExplosion)" into "addCommandHandler("explosion", createExplosionCommand)" and you're done. "The total IQ of the world is a constant. The more people, the more idiots." - Anonymous.
ixjf Posted April 13, 2013 Posted April 13, 2013 Nah, not a stack overflow, because the second time he executes createExplosion from within the createExplosion function, his createExplosion function will miss parameters (player) and will throw up an error. Indeed, I'm sorry for the mistake, I haven't seen the code carefully. I used to know how to code, but then I took an arrow in the knee. Project Redivivus - Remaking Old School MTA With New Code MTA 0.6 Nightly 1 released
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