gghvcffcv Posted March 6, 2014 Posted March 6, 2014 Hello i got another Problem the Problem is When a player attacks the trailer with the truck all Player can see the blip and the marker, i want that only the player that attachs the trailer with the truck can see them server: myMarker = createMarker(-1722.37073, 99.83501, 2.2, 'cylinder', 2.0, 255, 0, 0, 150) function MarkerHit( hitElement, matchingDimension ) local elementType = getElementType( hitElement ) end addEventHandler( "onMarkerHit", myMarker, MarkerHit ) function Trailer() Trailer = createVehicle ( 435, -1745.12244, 150.12001, 3.54956, 0, 0, 180 ) Trailer2 = createVehicle ( 435, -1737.79968, 147.05283, 3.55469, 0, 0, 180 ) Trailer3 = createVehicle (435, -1732.06018, 142.87035, 3.55469, 0, 0, 180 ) end addEventHandler ( "onResourceStart", getRootElement(), Trailer ) function Darvehiculo ( hitElement ) if ( getElementType ( hitElement ) == "player" ) and not isPedInVehicle ( hitElement ) then -- If the element that hit the marker is a player and he/she is not in a vehicle. createVehicle ( 514, -1726.37073, 99.83501, 4.0 ) end end addEventHandler ( "onMarkerHit", myMarker, Darvehiculo ) function detachTrailer( hitElement ) createBlip ( -51.26127, -1143.13037, 0.70681, 51 ) end addEventHandler("onTrailerAttach", getRootElement(), detachTrailer) function Marker2 (theTruck) Marker2 = createMarker(-51.26127, -1143.13037, 0.70681, 'cylinder', 2.0, 255, 0, 0, 150) end addEventHandler( "onTrailerAttach", getRootElement(), Marker2 )
DNL291 Posted March 6, 2014 Posted March 6, 2014 Use: setElementVisibleTo( element, root, false ) setElementVisibleTo( element, player, true )
Moderators Citizen Posted March 6, 2014 Moderators Posted March 6, 2014 Use: setElementVisibleTo( element, root, false ) setElementVisibleTo( element, player, true ) And check if the player who triggers the onMarkerHit is the player who can see it (use element datas) Also your code will work for only one player at a time. Why Because you are using a global variable on the server-side. Only use tables/element datas to be able to store multiple markers (so multiple players can do it and have their own markers).
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