Lalalu Posted September 29, 2018 Share Posted September 29, 2018 (edited) Hello... i need some help. This is a client-side script but... why can everyone see the markers when they take the mission at the same time? It works like this: when someone takes the marker it is deleted and immediately another marker is created in another position. function DestinationA () markerA = createMarker( -499.85806274414, 218.47076416016, 723.70001220703, "corona", 1, 0, 255, 255, 200, localPlayer ) blipA = createBlip( -499.85806274414, 218.47076416016, 723.70001220703, 0, 2.5, 0, 255, 255, 255, 0, 99999, localPlayer) addEventHandler("onClientMarkerHit", markerA, DestinationB) end function onMissionEMarkerHitA(hitA) if source == markerA and localPlayer == hitA then destroyElement( markerA ) destroyElement( blipA ) end end addEventHandler("onClientMarkerHit", root, onMissionEMarkerHitA) ----------------------------------- function DestinationB () markerB = createMarker( -498.54946899414, 191.89947509766, 723.70001220703, "corona", 1, 0, 255, 255, 200, localPlayer ) blipB = createBlip( -498.54946899414, 191.89947509766, 723.70001220703, 0, 2.5, 0, 255, 255, 255, 0, 99999, localPlayer) addEventHandler("onClientMarkerHit", markerB, DestinationC) end function onMissionEMarkerHitB(hitB) if source == markerB and localPlayer == hitB then destroyElement( markerB ) destroyElement( blipB ) end end addEventHandler("onClientMarkerHit", root, onMissionEMarkerHitB) Edited September 29, 2018 by Lalalu error Link to comment
NeXuS™ Posted September 29, 2018 Share Posted September 29, 2018 How is "DestinationA" and "DestinationB" called? 1 Link to comment
Lalalu Posted September 29, 2018 Author Share Posted September 29, 2018 (edited) 18 minutes ago, NeXuS™ said: How is "DestinationA" and "DestinationB" called? This in that way will it work? function DestinationA (A1) markerA = createMarker( -499.85806274414, 218.47076416016, 723.70001220703, "corona", 1, 0, 255, 255, 200, localPlayer ) blipA = createBlip( -499.85806274414, 218.47076416016, 723.70001220703, 0, 2.5, 0, 255, 255, 255, 0, 99999, localPlayer) addEventHandler("onClientMarkerHit", markerA, DestinationB) end function onMissionEMarkerHitA(hitA) if source == markerA and localPlayer == hitA then destroyElement( markerA ) destroyElement( blipA ) end end addEventHandler("onClientMarkerHit", root, onMissionEMarkerHitA) ----------------------------------- function DestinationB (B2) markerB = createMarker( -498.54946899414, 191.89947509766, 723.70001220703, "corona", 1, 0, 255, 255, 200, localPlayer ) blipB = createBlip( -498.54946899414, 191.89947509766, 723.70001220703, 0, 2.5, 0, 255, 255, 255, 0, 99999, localPlayer) addEventHandler("onClientMarkerHit", markerB, DestinationC) end function onMissionEMarkerHitB(hitB) if source == markerB and localPlayer == hitB then destroyElement( markerB ) destroyElement( blipB ) end end addEventHandler("onClientMarkerHit", root, onMissionEMarkerHitB) Edited September 29, 2018 by Lalalu Link to comment
JeViCo Posted September 29, 2018 Share Posted September 29, 2018 Markers are not synced so you should do it manually. You can use triggerClient/Server events for this action. when player hits the marker, use triggerServerEvent -- server for _, pl in ipairs(getElementsByType("player")) do if pl ~= source -- if player is not that one who hit the marker if getElementData(pl,"mission") == getElementData(source,"mission") then -- if mission is the same (i attached it to ElementData) -- triggerClientEvent stuff (remove marker and create a new one) end end end @Lalalu 1 Link to comment
NeXuS™ Posted September 29, 2018 Share Posted September 29, 2018 function DestinationB(hitPlayer) if hitPlayer == localPlayer then markerB = createMarker( -498.54946899414, 191.89947509766, 723.70001220703, "corona", 1, 0, 255, 255, 200, localPlayer ) blipB = createBlip( -498.54946899414, 191.89947509766, 723.70001220703, 0, 2.5, 0, 255, 255, 255, 0, 99999, localPlayer) addEventHandler("onClientMarkerHit", markerB, DestinationC) end end And you'll have to add this to all of your marker creations. Link to comment
Lalalu Posted September 29, 2018 Author Share Posted September 29, 2018 That will make only the player taking the mission can see the markers? I have this issue... when two players take the mission at the same time they get bug and the other can see the other player markers. 5 minutes ago, JeViCo said: Markers are not synced so you should do it manually. You can use triggerClient/Server events for this action. when player hits the marker, use triggerServerEvent -- server for _, pl in ipairs(getElementsByType("player")) do if pl ~= source -- if player is not that one who hit the marker if getElementData(pl,"mission") == getElementData(source,"mission") then -- if mission is the same (i attached it to ElementData) -- triggerClientEvent stuff (remove marker and create a new one) end end end @Lalalu Link to comment
JeViCo Posted September 29, 2018 Share Posted September 29, 2018 28 minutes ago, Lalalu said: That will make only the player taking the mission can see the markers? oops. Marker didn't appear for player who hit it (fixed). I recommend you to create those markers server-side (and make your code shorter of course). You'll able to set marker's element data to prevent bugs -- server for _, pl in ipairs(getElementsByType("player")) do --if pl ~= source -- if player is not that one who hit the marker if getElementData(pl,"mission") == getElementData(source,"mission") then -- if mission is the same (i attached it to ElementData) -- triggerClientEvent stuff (remove marker and create a new one) end --end end 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