Jump to content

[HELP] onPlayerMarkerLeave


1LoL1

Recommended Posts

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

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
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

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

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
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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...