Clipper_ Posted August 7, 2018 Share Posted August 7, 2018 (edited) I got a problem with created effects. In normal dimension I created an effect that is attached to the player's vehicle. The problem is that players from other dimensions can see it too moving around. Any idea how I can restrict the effects only for dimension 0? local attachedEffects = {} function getPositionFromElementOffset(element,offX,offY,offZ) local m = getElementMatrix ( element ) -- Get the matrix local x = offX * m[1][1] + offY * m[2][1] + offZ * m[3][1] + m[4][1] -- Apply transform local y = offX * m[1][2] + offY * m[2][2] + offZ * m[3][2] + m[4][2] local z = offX * m[1][3] + offY * m[2][3] + offZ * m[3][3] + m[4][3] return x, y, z -- Return the transformed point end function attachEffect(effect, element, pos) attachedEffects[effect] = { effect = effect, element = element, pos = pos } addEventHandler("onClientElementDestroy", effect, function() attachedEffects[effect] = nil end) addEventHandler("onClientElementDestroy", element, function() attachedEffects[effect] = nil end) return true end addEventHandler("onClientPreRender", root, function() for fx, info in pairs(attachedEffects) do local x, y, z = getPositionFromElementOffset(info.element, info.pos.x, info.pos.y, info.pos.z) setElementPosition(fx, x, y, z) end end ) local fire = {} function createCustomEffect(player, vehicle, value) if value then local x, y, z = getElementPosition(vehicle) if not fire[player] then fire[player] = createEffect("fire_bike", x, y, z, 0, 0, 0, 0, true) attachEffect(fire[player], vehicle, Vector3(0, 0, 0)) setElementDimension(fire[player], 0) end else if fire[player] then attachedEffects[fire[player]] = nil destroyElement(fire[player]) fire[player] = nil end end end addEvent("triggerCustomEffect", true) addEventHandler("triggerCustomEffect", root, createCustomEffect) The event is triggered in server when a player enters a vehicle, motorcycle in this case. Attaching functions are taken from 'MTA Wiki > Suggested functions function onPlayerVehicleEnter(vehicle, seat, jacked) if getElementModel(vehicle) == 463 then if seat == 0 then triggerClientEvent("triggerCustomEffect", source, source, vehicle, false) end end end addEventHandler("onPlayerVehicleExit", root, onPlayerVehicleEnter) Edited August 7, 2018 by Clipper_ Link to comment
Gaborboy95 Posted August 7, 2018 Share Posted August 7, 2018 Try setElementDimension(fire[player], 0) After creating it Link to comment
JustinMTA Posted August 8, 2018 Share Posted August 8, 2018 (edited) Use the .DFF, if you can rig it..https://dev.prineside.com/en/gtasa_samp_model_id/tag/404-sa-mp-particle-effects/https://community.multitheftauto.com/index.php?p=resources&s=details&id=1292 Edited August 8, 2018 by JustinMTA Link to comment
Clipper_ Posted August 8, 2018 Author Share Posted August 8, 2018 13 hours ago, Gaborboy95 said: Try setElementDimension(fire[player], 0) After creating it Doesn't work. I just want to see the effect in dimension 0, not all dimensions Link to comment
Clipper_ Posted August 8, 2018 Author Share Posted August 8, 2018 3 hours ago, JustinMTA said: Use the .DFF, if you can rig it..https://dev.prineside.com/en/gtasa_samp_model_id/tag/404-sa-mp-particle-effects/https://community.multitheftauto.com/index.php?p=resources&s=details&id=1292 used your method, thanks 1 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