damien111 Posted July 2, 2014 Share Posted July 2, 2014 Im working on a riot event script and i cant figure out how to make peds throw tons of molotovs at random times.. Link to comment
Spajk Posted July 2, 2014 Share Posted July 2, 2014 You could try wth setPedControlState. setPedControlState ( ped, "fire", true) setTimer(setPedControlState, 1000, 1, ped, "fire", false) Link to comment
myonlake Posted July 2, 2014 Share Posted July 2, 2014 You can use the math.random function within Lua to make them fire at a random interval. You should also consider switching the third argument on the setTimer to 0 so it will run indefinitely. Link to comment
damien111 Posted July 2, 2014 Author Share Posted July 2, 2014 addEvent("startPedThrowing",true) addEventHandler("startPedThrowing",getRootElement(),function(ped) setPedAnimation(ped, nil, nil) setPedControlState ( ped, "fire", true) setTimer(function() setPedControlState(ped,"fire",false) end, 1000, 1) randomAnimation = math.random(1,5) if(randomAnimation==1)then setPedAnimation(ped,"RIOT","RIOT_ANGRY",-1,true,true,true,true) elseif(randomAnimation==2)then setPedAnimation(ped,"RIOT","RIOT_ANGRY_B",-1,true,true,true,true) elseif(randomAnimation==3)then setPedAnimation(ped,"RIOT","RIOT_shout",-1,true,true,true,true) elseif(randomAnimation==4)then setPedAnimation(ped,"RIOT","RIOT_CHANT",-1,true,true,true,true) elseif(randomAnimation==5)then setPedAnimation(ped,"RIOT","RIOT_challenge",-1,true,true,true,true) end end) The peds already have animations going and this has no effect on it, and i cant figure out why Link to comment
Moderators IIYAMA Posted July 2, 2014 Moderators Share Posted July 2, 2014 Peds can't create (synced) projectiles. Link to comment
damien111 Posted July 2, 2014 Author Share Posted July 2, 2014 Well its just for looks so it doesnt relaly matter to be honest, is there a way to do it with them not being synced Link to comment
Moderators IIYAMA Posted July 2, 2014 Moderators Share Posted July 2, 2014 Well its just for looks so it doesnt relaly matter to be honest, is there a way to do it with them not being synced You see the animation but you don't see the projectile. https://wiki.multitheftauto.com/wiki/CreateProjectile Try something like this or included the ped position. createProjectile (ped,18) 1 Link to comment
damien111 Posted July 2, 2014 Author Share Posted July 2, 2014 Hold on, now i amc reateing projectile client side and triggering a server side event to make a explosion. addEvent("startPedThrowing",true) addEventHandler("startPedThrowing",getRootElement(),function(ped) setTimer(function() x,y,z=getElementPosition(ped) molly = createProjectile ( ped,18,x,y,z+1,1.2) setTimer(function() x,y,z=getElementPosition(molly) triggerServerEvent("syncBoom",getRootElement(),x,y,z) end,3000,1) end,math.random(1000,5000),0) end) I can not get the x,y,z positions of it Link to comment
Moderators IIYAMA Posted July 2, 2014 Moderators Share Posted July 2, 2014 Because the projectile is gone after it exploded, doesn't that make sense? Keep an eye on this event: https://wiki.multitheftauto.com/wiki/OnClientExplosion Also use local's for god sake. 1 Link to comment
damien111 Posted July 3, 2014 Author Share Posted July 3, 2014 I will start using locals i keep forgetting to and it keeps causing more and more problems lmao Thanks though! 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