Leeuwis Posted December 2, 2013 Share Posted December 2, 2013 Hey guys, I'm kinda new to scripting in LUA and I need some help with a simple script I made and I get an annoying "bad argument" or something. Maybe I've done something wrong or something I don't know the MTA Script Editor is not giving any errors for me, only when I run my server it says http://puu.sh/5AeTH.png if some one would be kind and help me with my problem would be nice local argument = nil local x,y,z = 0, 0 ,0 function createFire (thePlayer, command, argument) if thePlayer == ("admin") then local x,y,z = getElementPosition (thePlayer) local argument = nil createFire ( 0, 0, 0, 1.-- s8) --> else outputChatBox ("Fuck off please, don't try again.") end end addCommandHandler (createfire, createFire) 1. is supposed to be 1.8 only it displays something else on this forum. It displays normally in my MTA script Editor Link to comment
Woovie Posted December 3, 2013 Share Posted December 3, 2013 1. You can't name your function the same as an existing MTA function, otherwise you override it. Rename your function to something else. 2. You need to put your command in quotations, as it's a string. The way you have it now as just createFire, it's looking for a variable called createFire, no variable of that name exists so it's returning nil. 3. Use proper indentation! Else should be in line with if, outputChatBox should be on a seperate line. 4. You realize that on line 5, it's going to check if the player element is == "admin" (Hint: it won't be) 5. You're using local incorrectly... In fact, line 1, 2, and 7 as far as I can see are useless. 6. You're creating a fire at 0,0,0? Uh, why are you getting player position then? Here's I guess what you meant to do. function fireAtPlayer(player) if (true) then --replace with an admin check, use getElementData/setElementData after they login to verify they are admin? Or use ACL to check their permissions local x,y,z = getElementPosition(playeR) createFire(x,y,z,1. else outputChatBox("You're not an admin",player) end end Link to comment
TAPL Posted December 3, 2013 Share Posted December 3, 2013 createFire is client side only, so you will have to use addCommandHandler client side while it also doesn't have player parameter and you should use localPlayer Instead. Link to comment
Leeuwis Posted December 3, 2013 Author Share Posted December 3, 2013 1. You can't name your function the same as an existing MTA function, otherwise you override it. Rename your function to something else.2. You need to put your command in quotations, as it's a string. The way you have it now as just createFire, it's looking for a variable called createFire, no variable of that name exists so it's returning nil. 3. Use proper indentation! Else should be in line with if, outputChatBox should be on a seperate line. 4. You realize that on line 5, it's going to check if the player element is == "admin" (Hint: it won't be) 5. You're using local incorrectly... In fact, line 1, 2, and 7 as far as I can see are useless. 6. You're creating a fire at 0,0,0? Uh, why are you getting player position then? Here's I guess what you meant to do. function fireAtPlayer(player) if (true) then --replace with an admin check, use getElementData/setElementData after they login to verify they are admin? Or use ACL to check their permissions local x,y,z = getElementPosition(playeR) createFire(x,y,z,1. else outputChatBox("You're not an admin",player) end end Thanks man, you're helpfull. 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