1LoL1 Posted July 12, 2016 Share Posted July 12, 2016 Hello, i have problem in my script when any player joined in my marker and leave then marker + tent is destroyed and this i don't want.. i need only me when i leave so then will marker + tent destroyed. Can anyone help me please? addEventHandler("onPlayerMarkerLeave", getRootElement(), function(mark) if isElement(mark) and getElementData(mark, "tentMark") then local tent = getElementData(mark, "tent") local tentCol = getElementData(mark, "tentCol") if isElement(tent) then destroyElement(tentCol) destroyElement(tent) end destroyElement(mark) setElementData(source, "Tent", getElementData(source, "Tent") + 1) unbindKey(source, "enter", "down", setTent) end end) Link to comment
G-Stefan Posted July 12, 2016 Share Posted July 12, 2016 Dont use destroyElement(mark) because the marker will be deleted It is like when you delete a folder The folder will not exist until you recreate it (The mark will be deleted until you declare it again ) U can make the marker invisible setting its alpha to 0 EDIT:Try to use this event https://wiki.multitheftauto.com/wiki/OnClientMarkerLeave Sorry but i can't post the correct code because i am on my phone Hope my post helped you Link to comment
1LoL1 Posted July 12, 2016 Author Share Posted July 12, 2016 Dont use destroyElement(mark) because the marker will be deletedIt is like when you delete a folder The folder will not exist until you recreate it (The mark will be deleted until you declare it again ) U can make the marker invisible setting its alpha to 0 Sorry but i can't post the correct code because i am on my phone Hope my post helped you But i need destroyElement(mark) i need only cancel if other players leave my marker.. Me = i leave marker so marker will be deleted Others players = others players leave marker so nothing only leave. if this is possible. Link to comment
Bean666 Posted July 12, 2016 Share Posted July 12, 2016 destroyElement works in both sides. Link to comment
1LoL1 Posted July 12, 2016 Author Share Posted July 12, 2016 destroyElement works in both sides. I know omg.. i need know if this is possible what i said. Link to comment
G-Stefan Posted July 12, 2016 Share Posted July 12, 2016 Yes! Trigger a client function with "onClientMarkerLeave event Link to comment
1LoL1 Posted July 12, 2016 Author Share Posted July 12, 2016 Please post full script Don't need full script.. i tested with onClientMarkerLeave and not work.. Link to comment
Captain Cody Posted July 12, 2016 Share Posted July 12, 2016 CLIENT --- addEventHandler("OnClientMarkerLeave", getRootElement(), function() if isElement(source) and getElementData(source, "tentMark") then local tent = getElementData(source, "tent") local tentCol = getElementData(source, "tentCol") if isElement(tent) then destroyElement(tentCol) destroyElement(tent) end destroyElement(source) setElementData(localPlayer, "Tent", getElementData(localPlayer, "Tent") + 1,true) triggerServerEvent ( "UnBindSetTent", resourceRoot ) end end) SERVER ---- function UnBindSetTent() unbindKey(client,"enter", "down", setTent) end addEvent( "unBindSetTent", true ) addEventHandler( "unBindSetTent", resourceRoot, UnBindSetTent) Untested. Link to comment
1LoL1 Posted July 12, 2016 Author Share Posted July 12, 2016 CLIENT --- addEventHandler("OnClientMarkerLeave", getRootElement(), function() if isElement(source) and getElementData(source, "tentMark") then local tent = getElementData(source, "tent") local tentCol = getElementData(source, "tentCol") if isElement(tent) then destroyElement(tentCol) destroyElement(tent) end destroyElement(source) setElementData(localPlayer, "Tent", getElementData(localPlayer, "Tent") + 1,true) triggerServerEvent ( "UnBindSetTent", resourceRoot ) end end) SERVER ---- function UnBindSetTent() unbindKey(client,"enter", "down", setTent) end addEvent( "unBindSetTent", true ) addEventHandler( "unBindSetTent", resourceRoot, UnBindSetTent) Untested. But i have marker created in server-side.. MaRkeR = createMarker(...) Me = i leave marker(MaRkeR) so marker will be deleted Others players = others players leave marker(MaRkeR) so nothing only leave. Now it's i'am in marker my friend join too but when he leave the marker my marker is deleted.. i need this: i'am in marker my friend join too then my friend leave the marker and marker will not deleted.. only when i leave.. Link to comment
Captain Cody Posted July 12, 2016 Share Posted July 12, 2016 Using my code marker will only be deleted for you 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