John Smith Posted September 13, 2014 Posted September 13, 2014 im trying to make a marker and when player hits marker from one of area 51 rocket objects come projectiles and it should go to the player position but instead it goes to random positions function createMissiles() missileMarker = createMarker(355.373046875,1944.513671875,17.640625,"corona",1.5,255,0,0,255) -- create red corona end addCommandHandler("missile",createMissiles) function triggerMissiles(hitPlayer,matchingDimension) if source == missileMarker then local x,y,z = getElementPosition(hitPlayer) setTimer(function() createProjectile(localPlayer,20,354.0361328125,2027.9912109375,26.000198364258,nil,hitPlayer,0,90,0,1,1,1) end,250,0) end end addEventHandler("onClientMarkerHit",getRootElement(),triggerMissiles) please help
MIKI785 Posted September 13, 2014 Posted September 13, 2014 Try using it without the timer. I'm not sure but i think that if you use a timer like that and a local variable inside it the variable is nil.
John Smith Posted September 13, 2014 Author Posted September 13, 2014 i need to make multiple missiles thats why im using a timer but i dont know how to make createProjectile with all those arguments inside a timer...
MIKI785 Posted September 13, 2014 Posted September 13, 2014 What? You actually shouldn't even create projectiles like this because it will create it multiple times (for each client).. try it this way: function createMissiles() missileMarker = createMarker(355.373046875,1944.513671875,17.640625,"corona",1.5,255,0,0,255) -- create red corona end addCommandHandler("missile",createMissiles) function triggerMissiles(hitPlayer,matchingDimension) if source == missileMarker and hitPlayer == localPlayer then local x,y,z = getElementPosition(hitPlayer) setTimer(function() createProjectile(localPlayer,20,354.0361328125,2027.9912109375,26.000198364258,nil,localPlayer,0,90,0,1,1,1) end,250,0) end end addEventHandler("onClientMarkerHit",getRootElement(),triggerMissiles)
John Smith Posted September 13, 2014 Author Posted September 13, 2014 it works same like it did before and also like before its still like this projectile changes rotation of movement depending on my position but they go in sky far far away and they dont come to ground at all i just want to make it realistic so when player hits marker it creates projectile from a51 rocket launcher object and sends projectile onto my position and i am not sure how to do it... it goes in wrong direction
MIKI785 Posted September 13, 2014 Posted September 13, 2014 Try not using the arguments after the targetPlayer So: createProjectile(localPlayer,20,354.0361328125,2027.9912109375,26.000198364258,nil,localPlayer)
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