Lalalu Posted December 3, 2022 Share Posted December 3, 2022 Hello, this is a following topic to an old one... It works a little better with the lines you helped me last time, but the image keeps disappearing when another player uses it at the same time as me, or after me, and it disappears on me too. It is as if it communicates with the rest of players when creating or removing the image... @Shady1 local sX, sY = guiGetScreenSize ( ) local onEmoji5 = {}; local plyEmoji5 = getElementsByType ( "player" ) local showEmoji5 = false local alphaEmoji5 = 0; tickEmoji5 = 0; local isEventEmoji5Added = false function onEmoji5Render ( ) local cx, cy, cz = getCameraMatrix () for i = 1, #plyEmoji5 do local pEmoji5 = plyEmoji5[i] if ( onEmoji5[pEmoji5] ) then if (getElementData (pEmoji5, "Emoji5") == true) then local x, y, z = getPedBonePosition ( pEmoji5, 6 ); local dEmoji5 = getDistanceBetweenPoints3D ( cx, cy, cz, x, y, z ); if ( dEmoji5 < 100 ) then if ( isLineOfSightClear ( cx, cy, cz, x, y, z, true, true, false, false, true, false, false, localPlayer ) ) then local sx, sy = getScreenFromWorldPosition ( x, y, z+0.4 ); if ( sx ) and ( sy ) then local sEmoji5 = 400 / dEmoji5; if showEmoji5 then alphaEmoji5 = interpolateBetween(alphaEmoji5,0,0,0,0,255,(getTickCount()-tickEmoji5)/1000, "InBounce") end dxDrawImage ( sx - ( sEmoji5 / 2 ), sy - ( sEmoji5 / 2 ), sEmoji5, sEmoji5, "Images/Effects/T_UI_Message_Icon_Shousan_BC.webp", 0, 0, 0, tocolor ( 255, 255, 255, alphaEmoji5 ) ) end end end end end end end function attachEmoji5 ( Emoji5 ) if not ( Emoji5 and isElement ( Emoji5 ) ) then return end if(isEventEmoji5Added) then return end -- if event added don't go onEmoji5[Emoji5] = true addEventHandler ( "onClientRender", root, onEmoji5Render ) alphaEmoji5 = 255 showEmoji5 = false setTimer(function() tickEmoji5 = getTickCount() showEmoji5 = not showEmoji5 end, 1000, 1) isEventEmoji5Added = true -- mark as added setTimer(function() removeEventHandler ( "onClientRender", root, onEmoji5Render ) isEventEmoji5Added = false -- mark as deleted end, 2000, 1) end addEvent( "Emoji5:activarEfecto", true ) addEventHandler( "Emoji5:activarEfecto", root, attachEmoji5 ) I'm using this for the server side trigger: triggerClientEvent("Emoji5:activarEfecto", root, source ) setElementData(source, "Emoji5", true) Link to comment
Shady1 Posted December 3, 2022 Share Posted December 3, 2022 (edited) first of all @Lalalu , welcome to the forum, it would be great if you could tag me and show a screenshot of your problem to get your opinions on this. 27 minutes ago, Lalalu said: Hello, this is a following topic to an old one... It works a little better with the lines you helped me last time, but the image keeps disappearing when another player uses it at the same time as me, or after me, and it disappears on me too. It is as if it communicates with the rest of players when creating or removing the image... @Shady1 local sX, sY = guiGetScreenSize ( ) local onEmoji5 = {}; local plyEmoji5 = getElementsByType ( "player" ) local showEmoji5 = false local alphaEmoji5 = 0; tickEmoji5 = 0; local isEventEmoji5Added = false function onEmoji5Render ( ) local cx, cy, cz = getCameraMatrix () for i = 1, #plyEmoji5 do local pEmoji5 = plyEmoji5[i] if ( onEmoji5[pEmoji5] ) then if (getElementData (pEmoji5, "Emoji5") == true) then local x, y, z = getPedBonePosition ( pEmoji5, 6 ); local dEmoji5 = getDistanceBetweenPoints3D ( cx, cy, cz, x, y, z ); if ( dEmoji5 < 100 ) then if ( isLineOfSightClear ( cx, cy, cz, x, y, z, true, true, false, false, true, false, false, localPlayer ) ) then local sx, sy = getScreenFromWorldPosition ( x, y, z+0.4 ); if ( sx ) and ( sy ) then local sEmoji5 = 400 / dEmoji5; if showEmoji5 then alphaEmoji5 = interpolateBetween(alphaEmoji5,0,0,0,0,255,(getTickCount()-tickEmoji5)/1000, "InBounce") end dxDrawImage ( sx - ( sEmoji5 / 2 ), sy - ( sEmoji5 / 2 ), sEmoji5, sEmoji5, "Images/Effects/T_UI_Message_Icon_Shousan_BC.webp", 0, 0, 0, tocolor ( 255, 255, 255, alphaEmoji5 ) ) end end end end end end end function attachEmoji5 ( Emoji5 ) if not ( Emoji5 and isElement ( Emoji5 ) ) then return end if(isEventEmoji5Added) then return end -- if event added don't go onEmoji5[Emoji5] = true addEventHandler ( "onClientRender", root, onEmoji5Render ) alphaEmoji5 = 255 showEmoji5 = false setTimer(function() tickEmoji5 = getTickCount() showEmoji5 = not showEmoji5 end, 1000, 1) isEventEmoji5Added = true -- mark as added setTimer(function() removeEventHandler ( "onClientRender", root, onEmoji5Render ) isEventEmoji5Added = false -- mark as deleted end, 2000, 1) end addEvent( "Emoji5:activarEfecto", true ) addEventHandler( "Emoji5:activarEfecto", root, attachEmoji5 ) I'm using this for the server side trigger: triggerClientEvent("Emoji5:activarEfecto", root, source ) setElementData(source, "Emoji5", true) Edited December 3, 2022 by Shady1 1 Link to comment
Moderators IIYAMA Posted December 3, 2022 Moderators Share Posted December 3, 2022 1 hour ago, Lalalu said: It is as if it communicates with the rest of players when creating or removing the image... That is indeed the case. Syntax: bool triggerClientEvent ( [ table/element sendTo = getRootElement(), ] string name, element sourceElement [, arguments... ] ) Optional argument sendTo is not filled in, therefore it will send to all. To fix that: triggerClientEvent(source, "Emoji5:activarEfecto", root, source ) triggerClientEvent(source, "Emoji5:activarEfecto", root ) triggerClientEvent(source, "Emoji5:activarEfecto", source ) -- or for better performance 1 1 Link to comment
Shady1 Posted December 3, 2022 Share Posted December 3, 2022 3 minutes ago, IIYAMA said: That is indeed the case. Syntax: bool triggerClientEvent ( [ table/element sendTo = getRootElement(), ] string name, element sourceElement [, arguments... ] ) Optional argument sendTo is not filled in, therefore it will send to all. To fix that: triggerClientEvent(source, "Emoji5:activarEfecto", root, source ) triggerClientEvent(source, "Emoji5:activarEfecto", root ) triggerClientEvent(source, "Emoji5:activarEfecto", source ) -- or for better performance thanks, he talked to me on discord and I gave him the necessary answer but forgot to comment on the topic in the forum... Thanks for your help. 1 Link to comment
Moderators IIYAMA Posted December 3, 2022 Moderators Share Posted December 3, 2022 2 minutes ago, Shady1 said: thanks, he talked to me on discord and I gave him the necessary answer but forgot to comment on the topic in the forum... Thanks for your help. Nice, good to know! 1 Link to comment
Lalalu Posted December 14, 2022 Author Share Posted December 14, 2022 Hello again, @Shady1 help me a lot! (thank you☆). It works with that. triggerClientEvent(source, "Emoji5:activarEfecto", source, OnEnmojiRender) ---i've tried with this and same, it works. triggerClientEvent(source, "Emoji5:activarEfecto", root, OnEnmojiRender) But no one can see the image that i have created, @Shady1 i've tried with setElementVisibleTo but It's not working, still no one can see the image :(. Any other recommendation or something to use that allow other players see the image i have created? and also that i can se their images.. Link to comment
βurak Posted December 14, 2022 Share Posted December 14, 2022 can you try this please triggerClientEvent(root, "Emoji5:activarEfecto", source, OnEnmojiRender) or try this triggerClientEvent(root, "Emoji5:activarEfecto", root, OnEnmojiRender) 1 Link to comment
Lalalu Posted December 14, 2022 Author Share Posted December 14, 2022 1 minute ago, Burak5312 said: can you try this please triggerClientEvent(root, "Emoji5:activarEfecto", source, OnEnmojiRender) or try this triggerClientEvent(root, "Emoji5:activarEfecto", root, OnEnmojiRender) Hello, If I use It that way the image communicates with other players. For example If I active this by a command, and someone else uses this command at the same time that I'm using It then the image communicates with other player, dissapears, appears on both, and things like that. Link to comment
βurak Posted December 14, 2022 Share Posted December 14, 2022 (edited) can you try this on server side addCommandHandler("emoji", function(player) local x,y,z = getElementPosition(player) -- get x,y,z position who used player emoji command local nearbyPlayers = getElementsWithinRange(x, y, z, 100, "player") -- get players 100 range for _,player in ipairs(nearbyPlayers) do triggerClientEvent(player, "Emoji5:activarEfecto", root, OnEnmojiRender) -- send them so they can see this effect end end ) Edited December 14, 2022 by Burak5312 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