GamerDeMTA Posted September 14, 2013 Share Posted September 14, 2013 So, I want to do X function when there is a satchel explosion near you. How? Link to comment
Dealman Posted September 14, 2013 Share 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. Link to comment
GamerDeMTA Posted September 14, 2013 Author Share 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 Link to comment
kevenvz Posted September 14, 2013 Share 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 Link to comment
Moderators IIYAMA Posted September 14, 2013 Moderators Share 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. 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