FSXTim Posted May 19, 2012 Share Posted May 19, 2012 Hello, I have a small problem with my script. The firework starts and I can hear/see the first explosion, but the second explosion doesn't start. Errors: Line 13: Bad argument @ 'getElementPosition' Line 14: attempt to perform arithmetic on local 'z' (a nil value) function Feuerwerk () fire1 ( player ) end addEvent ( "Feuerwerk", true ) addEventHandler ( "Feuerwerk", getRootElement(), Feuerwerk ) function fire1 ( player ) local x,y,z = getElementPosition ( player ) createExplosion ( x, y, z + 15, 0 ) setTimer(fire2, 500, 1, 0) end function fire2 ( player ) local x,y,z = getElementPosition ( player ) createExplosion ( x, y, z + 13, 0 ) setTimer(fire3, 500, 1, 0) end Can anybody help me? Greets Link to comment
Genius Posted May 19, 2012 Share Posted May 19, 2012 Try this function Feuerwerk ( thePlayer) fire1 ( thePlayer ) end addEvent ( "Feuerwerk", true ) addEventHandler ( "Feuerwerk", getRootElement(), Feuerwerk ) function fire1 ( thePlayer ) local position = getElementPosition ( thePlayer ) createExplosion ( x, y, z + 15, 0 ) setTimer(fire2, 500, 1, 0) end function fire2 ( thePlayer ) local position1 = getElementPosition ( thePlayer ) createExplosion ( x, y, z + 13, 0 ) setTimer(fire3, 500, 1, 0) end Link to comment
FSXTim Posted May 19, 2012 Author Share Posted May 19, 2012 (edited) That doesn't work, now the first explosion doesn't start, too! Errors: Line 8: Bad argument @ 'getElementPosition' Line 9: attempt to perform arithmetic on local 'z' (a nil value) Greets Edited May 19, 2012 by Guest Link to comment
Castillo Posted May 19, 2012 Share Posted May 19, 2012 This is a client or a server side script? P.S: Can you post the rest of the script? Link to comment
FSXTim Posted May 19, 2012 Author Share Posted May 19, 2012 Partly serverside and partly clientside. clientside: function bombe10_Button (state) if state == "left" then if source == GUIEditor_Button[12] then local vehicle = getPedOccupiedVehicle (getLocalPlayer()) local x,y,z = getElementPosition (getLocalPlayer()) triggerServerEvent ( "Feuerwerk", root ) end end end addEventHandler("onClientGUIClick", getRootElement(), bombe10_Button) serverside: function Feuerwerk ( thePlayer) fire1 ( thePlayer ) end addEvent ( "Feuerwerk", true ) addEventHandler ( "Feuerwerk", getRootElement(), Feuerwerk ) function fire1 ( thePlayer ) local position1 = getElementPosition ( thePlayer ) createExplosion ( x, y, z + 15, 0 ) setTimer(fire2, 500, 1, 0) end function fire2 ( thePlayer ) local position2 = getElementPosition ( thePlayer ) createExplosion ( x, y, z + 13, 0 ) setTimer(fire3, 500, 1, 0) end Greets Link to comment
X-SHADOW Posted May 19, 2012 Share Posted May 19, 2012 --ClientSide function bombe10_Button (state) if state == "left" then if (source == GUIEditor_Button[12]) then local vehicle = getPedOccupiedVehicle (localPlayer) local x,y,z = getElementPosition (localPlayer) triggerServerEvent ( "Feuerwerk", source ) end end end addEventHandler("onClientGUIClick", getRootElement(), bombe10_Button) --ServerSide function Feuerwerk () end addEvent ( 'Feuerwerk', true ) addEventHandler ( "Feuerwerk", root , Feuerwerk ) function fire1 ( thePlayer ) local x, y, z = getElementPosition ( thePlayer ) createExplosion ( x, y, z + 15, 0 ) setTimer(fire2, 500, 1, 0) end function fire2 ( thePlayer ) local x,y,z = getElementPosition ( thePlayer ) createExplosion ( x, y, z + 13, 0 ) setTimer(fire3, 500, 1, 0) end Link to comment
Castillo Posted May 19, 2012 Share Posted May 19, 2012 -- client side: function bombe10_Button ( state ) if ( state == "left" ) then if ( source == GUIEditor_Button[12] ) then triggerServerEvent ( "Feuerwerk", localPlayer ) end end end addEventHandler ( "onClientGUIClick", getRootElement(), bombe10_Button ) -- server side: function Feuerwerk ( ) fire1 ( source ) end addEvent ( "Feuerwerk", true ) addEventHandler ( "Feuerwerk", getRootElement(), Feuerwerk ) function fire1 ( thePlayer ) local x, y, z = getElementPosition ( thePlayer ) createExplosion ( x, y, z + 15, 0 ) setTimer ( fire2, 500, 1, thePlayer ) end function fire2 ( thePlayer ) local x, y, z = getElementPosition ( thePlayer ) createExplosion ( x, y, z + 13, 0 ) setTimer ( fire3, 500, 1, thePlayer ) end @X-SHADOW: Please don't post useless stuff. Link to comment
FSXTim Posted May 19, 2012 Author Share Posted May 19, 2012 Thanks, I will test it. Greets Link to comment
X-SHADOW Posted May 19, 2012 Share Posted May 19, 2012 -- client side: function bombe10_Button ( state ) if ( state == "left" ) then if ( source == GUIEditor_Button[12] ) then triggerServerEvent ( "Feuerwerk", localPlayer ) end end end addEventHandler ( "onClientGUIClick", getRootElement(), bombe10_Button ) -- server side: function Feuerwerk ( ) fire1 ( source ) end addEvent ( "Feuerwerk", true ) addEventHandler ( "Feuerwerk", getRootElement(), Feuerwerk ) function fire1 ( thePlayer ) local position1 = getElementPosition ( thePlayer ) createExplosion ( x, y, z + 15, 0 ) setTimer ( fire2, 500, 1, 0 ) end function fire2 ( thePlayer ) local position2 = getElementPosition ( thePlayer ) createExplosion ( x, y, z + 13, 0 ) setTimer ( fire3, 500, 1, 0 ) end @X-SHADOW: Please don't post useless stuff. SoldSnake iam trying to help just like you its free to help others if it wrong or right |~ ~| You write CreateExploison ( x,y,z ) ?? where is x,y,z defined ? Link to comment
Castillo Posted May 19, 2012 Share Posted May 19, 2012 Thanks, I will test it.Greets Copy the server side code again, I fixed some bugs. Link to comment
FSXTim Posted May 19, 2012 Author Share Posted May 19, 2012 function Feuerwerk ( ) fire1 ( source ) end addEvent ( "Feuerwerk", true ) addEventHandler ( "Feuerwerk", getRootElement(), Feuerwerk ) function fire1 ( thePlayer ) local x, y, z = getElementPosition ( thePlayer ) createExplosion ( x, y, z + 7, 1 ) setTimer ( fire2, 500, 1, 0, thePlayer ) end function fire2 ( thePlayer ) local x, y, z = getElementPosition ( thePlayer ) createExplosion ( x, y, z + 7, 1 ) setTimer ( fire3, 1000, 1, 0, thePlayer ) end There is still one explosions and not two! Errors: Line 14: Bad argument @ 'getElementPosition' Line 15: attempt to perform arithmetic on local 'z' (a nil value) Greets Link to comment
Castillo Posted May 19, 2012 Share Posted May 19, 2012 Found the problem, you we're passing another argument "0" in setTimer, so at the other functions it wasn't sending the first argument as a player element, but a number. Copy server side again. Link to comment
FSXTim Posted May 19, 2012 Author Share Posted May 19, 2012 Thanks, you're the number 1 ... Greets 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