justn Posted May 30, 2014 Posted May 30, 2014 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 ) Datastore - Store data to a database quickly. (Useful for saving scripted tables)
Mr_Moose Posted May 30, 2014 Posted May 30, 2014 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) MTA Community | GitHub | 99Stack Forum
justn Posted May 30, 2014 Author Posted May 30, 2014 Thanks. Datastore - Store data to a database quickly. (Useful for saving scripted tables)
Moderators IIYAMA Posted May 30, 2014 Moderators Posted May 30, 2014 Also blips will be visible to new players. Because root only included the players that are inside the server at that moment. Do you want to improve your Lua programming skills and make less mistakes? Start with Lua Language Server! Useful functions 3x Spoiler checkPassiveTimer getScreenStartPositionFromBox getPedGender Tutorials 4x Spoiler Scaling DX Events Attach an addEventHandler on a group of elements Debugging
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