GamerDeMTA Posted September 14, 2013 Posted September 14, 2013 So, I want to do X function when there is a satchel explosion near you. How?
Dealman Posted September 14, 2013 Posted September 14, 2013 You'll have to use the event onClientExplosion and then isolate the source to make sure it was a Satchel Charge. I don't know what type it is, but I would assume mine. If I help you in a thread and you need further assistance, please don't PM me - use the thread you created instead. This way everyone on the forum can take advantage of it.
GamerDeMTA Posted September 14, 2013 Author Posted September 14, 2013 thanks but are u sure that it is mine? isn't there any type for grenades and satchel together or i need to make it 2 functions
kevenvz Posted September 14, 2013 Posted September 14, 2013 Just do something like this: function onExplosion (x, y, z, type) If (type == -- s8) --> or (type == 0) then -- WHAT HAPPENS ? end end
Moderators IIYAMA Posted September 14, 2013 Moderators Posted September 14, 2013 Well no, satchel's are sharing same explosion the grenade. But you can try something like this: (this have to be done per player because satchel positions aren't synced) -- client -- addCommandHandler("getallSatchels", function () local projectileTable = getElementsByType ("projectile") local projectileDataTable = {} for i=1, #projectileTable do local projectile = projectileTable[i] if getProjectileType(projectile) == 39 and getProjectileCreator (projectile) == localPlayer then local x,y,z = getElementPosition(projectile) projectileDataTable[#projectileDataTable+1] = {x=x,y=y,z=z} end end if #projectileDataTable >0 then triggerLatentServerEvent(localPlayer,"allSatchel",localPlayer,projectileDataTable) end end) -- server -- addEvent("allSatchel",true) addEventHandler("allSatchel",root, function (projectileDataTable) if isElement(source) then detonateSatchels (source) -- blow the satchels -- local players = getElementsbyType("player") -- get all the players for p=1,#players do -- loop through all the players local pX,pY,Pz = getElementPosition(players[p] for X=1,#projectileDataTable do -- loop through all the satchels per player local satchelPosition = projectileDataTable[X] if getDistanceBetweenPoints3D ( pX,pY,Pz, satchelPosition.x, satchelPosition.y, satchelPosition.z ) < 5 then -- compare the distance end end end end end) @kevenvz, first read, then answer. Do you want to improve your Lua programming skills and make less mistakes? Start with Lua Language Server! Useful functions 3x Spoiler checkPassiveTimer getScreenStartPositionFromBox getPedGender Tutorials 4x Spoiler Scaling DX Events Attach an addEventHandler on a group of elements Debugging
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