Jump to content

[Help] How to create marker only for local player?


Turbesz

Recommended Posts

i tried with table, but does not work, create for all player, when i type the command

local cpk = {}

function teszt(player)
        cpk[player] = createMarker(1954.52979, -1367.25488, 24.27094, "corona", 1.5, 255, 0, 0, 150)
        addEventHandler("onMarkerHit", cpk[player],felvesz)
end

addCommandHandler("t",teszt)

funny, because in another script this method worked... and now what wrong?

Link to comment
  • Moderators

Since it's not client side, you can't create it only for "localPlayer".

The only thing what you can do to make visible only for "player" who used the command.

You have to use createMarker's 10th parameter.

Quote
  • visibleTo: This defines which elements can see the marker. Defaults to visible to everyone. See visibility.

 

Link to comment
1 minute ago, Patrick said:

Since it's not client side, you can't create it only for "localPlayer".

I know, but i've used before this method with table and then the markers or peds appeared only to the player. Now when i change the createMarker to createPed, the ped also appears to everyone... with table.

Link to comment
  • Moderators
3 minutes ago, Turbesz said:

I know, but i've used before this method with table and then the markers or peds appeared only to the player. Now when i change the createMarker to createPed, the ped also appears to everyone... with table.

This is not how it works. Tables are not affect element visibility.

Probably you did it on client-side, where everything created only for "localPlayer".

  • Like 1
Link to comment
11 minutes ago, Patrick said:

This is not how it works. Tables are not affect element visibility.

Probably you did it on client-side, where everything created only for "localPlayer".

Oh, i got it. And how can i solve it the onMarkerHit event for players? Because remove the marker from all players, if a player hit that.

function felvesz(thePlayer, md)
setElementData( thePlayer, 'm', source)
    if getElementType(thePlayer) == "vehicle" then
	destroyElement(getElementData(thePlayer, 'm') ) 
    end
end

 

Link to comment
  • Moderators
46 minutes ago, Turbesz said:

Oh, i got it. And how can i solve it the onMarkerHit event for players? Because remove the marker from all players, if a player hit that.


function felvesz(thePlayer, md)
setElementData( thePlayer, 'm', source)
    if getElementType(thePlayer) == "vehicle" then
	destroyElement(getElementData(thePlayer, 'm') ) 
    end
end

 

 

People who can't see the marker, can hit it?

Try to check is marker visible for "thePlayer" first, with isElementVisibleTo.

  • Thanks 1
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...