Jump to content

Problem with setElementVisibleTo


justn

Recommended Posts

Posted

Hi

I'm working on a little script, and I have a problem with setElementVisibleTo

No errors in debugscript :/

addEvent("CreateCaptainMarker",true) 
addEventHandler("CreateCaptainMarker",getRootElement(), 
function(x,y,z) 
local playerName = getPlayerName(source) 
local playerFromName = getPlayerFromName(playerName) 
if playerName and playerFromName then 
CaptainMarker[source] = createMarker ( x, y, z, "cylinder", 5, 255, 51, 102, 85) 
CaptainAttachedBlip[source] = createBlipAttachedTo(CaptainMarker[source],9) 
setElementVisibleTo(CaptainMarker[source],playerFromName,true) 
setElementVisibleTo(CaptainMarker[source],root,false) 
setElementVisibleTo(CaptainAttachedBlip[source],playerFromName,true) 
setElementVisibleTo(CaptainAttachedBlip[source],root,false) 
end 
end 
) 

Posted

playerFromName is a part of root, this means that you first make the element visible to playerFromName and straight after that making the element invisible to all, including playerFromName. Also make sure that you run this script server side only. Try this:

 addEvent("CreateCaptainMarker",true) 
addEventHandler("CreateCaptainMarker",getRootElement(), 
function(x,y,z) 
    local playerName = getPlayerName(source) 
    local playerFromName = getPlayerFromName(playerName) 
    if playerName and playerFromName then 
        CaptainMarker[source] = createMarker ( x, y, z, "cylinder", 5, 255, 51, 102, 85) 
        CaptainAttachedBlip[source] = createBlipAttachedTo(CaptainMarker[source],9) 
        setElementVisibleTo(CaptainMarker[source],root,false) 
        setElementVisibleTo(CaptainMarker[source],playerFromName,true) 
        setElementVisibleTo(CaptainAttachedBlip[source],root,false) 
        setElementVisibleTo(CaptainAttachedBlip[source],playerFromName,true)  
    end 
end) 

  • Moderators
Posted

Also blips will be visible to new players. Because root only included the players that are inside the server at that moment.

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