_DrXenon Posted July 25, 2014 Share Posted July 25, 2014 Hey community! As far as i know, a Marker is an element. And recently i have been trying to store some data in a marker with (setElementData) , and data is being saved. Anyway the problem is that players see different data when they hit the marker, while they should all see the same data .-.! And the data is a math random. Example: marker = createMarker(0,0,3,"cylinder",1.5,255,0,0) local cars = { {445}, {604}, {507}, {585}, {587}, {466}, {492}, {546}, {551}, {516}, } function setData() if not getElementData(marker,"working") then setElementData(marker,"working",true) local firstCol = math.random(#cars) local veh = getVehicleNameFromModel(cars[firstCol][1]) setElementData(marker,"firstCar",veh) setTimer(function() setElementData(marker,"working",false) end,600000,1) end end setTimer(setData,1000,0) Thats how i set the data of the Marker. Anyway, When player hits the marker: addEventHandler("onClientMarkerHit",marker,function(hit) dxDrawText(getElementData(marker,"firstCar"), 353, 241, 668, 304, tocolor(0, 230, 32, 254), 1.00, "bankgothic", "center", "center", false, false, false, false, false) end ) So when players hit the marker, they see different texts than others. Like first player sees : Cheetah, another one sees : Infernus... While they all should see the same thing, As they see the Marker Data. So whats wrong with marker or script ? Even if i reconnected, when i hit the marker, i may see different text.. Link to comment
Bonsai Posted July 25, 2014 Share Posted July 25, 2014 It might be because you switch the data every 1 second. (setTimer(setData,1000,0)) Try setTimer(setData,1000,1) . EDIT: Nevermind. Is that clientside? If so it would be different for every player. Link to comment
_DrXenon Posted July 25, 2014 Author Share Posted July 25, 2014 Timer triggered when marker data is false.. And when its triggered i set the data as true.. then after 10 mins i set marker data to false. That means its not triggered every second And yeah its client. But why it would be different for different players? Link to comment
Bonsai Posted July 25, 2014 Share Posted July 25, 2014 Timer triggered when marker data is false..And when its triggered i set the data as true.. then after 10 mins i set marker data to false. That means its not triggered every second And yeah its client. But why it would be different for different players? Yeah, I didn't see that if the first time. If its clientside every client is doing this function on his own, and since it usee the random function, every player might get a different result. So, just make the marker serverside and attach some ID or something, so on clientside you can check if the marker that was hit is the one here. Link to comment
_DrXenon Posted July 25, 2014 Author Share Posted July 25, 2014 Thnx dude... Now i understood! Link to comment
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