xRGamingx Posted June 4, 2018 Share Posted June 4, 2018 (edited) Hello friends, I need your help! I explain that I have an event panel to create careers for players on my freeroam server Through the panel I must create all racing checkpoint. And what I want to achieve is that when the player passes over the point, that disappears and the next checkpoint comes out I leave my code tell me how I can achieve this Or if they have a similar panel, I would like them to contribute with the ---Server blip = {} marker = {} function event () call(getResourceFromName("guitext"),"outputServerGuiText",root,"An event was placed on your Map",0,255,0) local x, y, z = getElementPosition (source) local maxBlip = #blip -- with this you have the contents of the table. local maxMarker = #marker blip[maxBlip + 1] = createBlip (x, y, z, 49) marker[maxMarker + 1] = createMarker (x, y, z, "checkpoint", 2, 135, 191, 255, 200) end addEvent ("event", true) addEventHandler ("event", root, event) Edited June 4, 2018 by xRGamingx Link to comment
DNL291 Posted June 4, 2018 Share Posted June 4, 2018 (edited) Something like this should work: local markers = { {x, y, z}; {x, y, z}; } local curMarkerBlip local curMarker local ID function event() call(getResourceFromName("guitext"),"outputServerGuiText",root,"An event was placed on your Map",0,255,0) createCheckpoint( 1 ) ID = 1 end addEvent ("event", true) addEventHandler ("event", root, event) function createCheckpoint(ID) if ID then if isElement(curMarker) and isElement(curMarkerBlip) then destroyElement(curMarker) destroyElement(curMarkerBlip) end local x, y, z = unpack(markers[tonumber(ID)]) curMarker = createMarker( x, y, z, "checkpoint", 2, 135, 191, 255, 200 ) curMarkerBlip = createBlipAttachedTo( curMarker, 49 ) return true end return false end addEventHandler( "onClientMarkerHit", resourceRoot, function (hitPlayer, dim) if (curMarker and source == curMarker and hitPlayer == localPlayer and dim) then ID = ID + 1 if ID > #markers then ID = 1 end createCheckpoint( ID ) -- create the next checkpoint end end ) Edited June 4, 2018 by DNL291 Link to comment
xRGamingx Posted June 4, 2018 Author Share Posted June 4, 2018 (edited) 20 minutes ago, DNL291 said: Something like this should work: local markers = { {x, y, z}; {x, y, z}; } local curMarkerBlip local curMarker local ID function event() call(getResourceFromName("guitext"),"outputServerGuiText",root,"An event was placed on your Map",0,255,0) createCheckpoint( 1 ) ID = 1 end addEvent ("event", true) addEventHandler ("event", root, event) function createCheckpoint(ID) if ID then if isElement(curMarker) and isElement(curMarkerBlip) then destroyElement(curMarker) destroyElement(curMarkerBlip) end local x, y, z = unpack(markers[tonumber(ID)]) curMarker = createMarker( x, y, z, "checkpoint", 2, 135, 191, 255, 200 ) curMarkerBlip = createBlipAttachedTo( curMarker, 49 ) return true end return false end addEventHandler( "onClientMarkerHit", resourceRoot, function (hitPlayer, dim) if (curMarker and source == curMarker and hitPlayer == localPlayer and dim) then ID = ID + 1 if ID > #markers then ID = 1 end createCheckpoint( ID ) -- create the next checkpoint end end ) @DNL291 Edited June 4, 2018 by xRGamingx Link to comment
DNL291 Posted June 4, 2018 Share Posted June 4, 2018 Did you put the coordinates on markers table? Link to comment
xRGamingx Posted June 4, 2018 Author Share Posted June 4, 2018 3 minutes ago, DNL291 said: Did you put the coordinates on markers table? I already did it but the checkpoint does not disappear when I touch it Link to comment
DNL291 Posted June 4, 2018 Share Posted June 4, 2018 Show here the code you're using. Post it using the formatting for Lua: Also, type /debugscript 3 when testing your script. Link to comment
xRGamingx Posted June 4, 2018 Author Share Posted June 4, 2018 3 minutes ago, DNL291 said: Show here the code you're using. Post it using the formatting for Lua: Also, type /debugscript 3 when testing your script. friend the debug script 3 is activated and does not throw me error local markers = { {1942.0526123047, -1702.3355712891, 13.3828125}; {1942.302734375, -1715.2150878906, 12.792504310608}; } local curMarkerBlip local curMarker local ID function event() call(getResourceFromName("guitext"),"outputServerGuiText",root,"An event was placed on your Map",0,255,0) createCheckpoint( 1 ) ID = 1 end addEvent ("event", true) addEventHandler ("event", root, event) function createCheckpoint(ID) if ID then if isElement(curMarker) and isElement(curMarkerBlip) then destroyElement(curMarker) destroyElement(curMarkerBlip) end local x, y, z = unpack(markers[tonumber(ID)]) curMarker = createMarker( x, y, z, "checkpoint", 2, 135, 191, 255, 200 ) curMarkerBlip = createBlipAttachedTo( curMarker, 0 ) return true end return false end addEventHandler( "onClientMarkerHit", resourceRoot, function (hitPlayer, dim) if (curMarker and source == curMarker and hitPlayer == localPlayer and dim) then ID = ID + 1 if ID > #markers then ID = 1 end createCheckpoint( ID ) -- create the next checkpoint end end ) Link to comment
DNL291 Posted June 5, 2018 Share Posted June 5, 2018 2 hours ago, xRGamingx said: friend the debug script 3 is activated and does not throw me error local markers = { {1942.0526123047, -1702.3355712891, 13.3828125}; {1942.302734375, -1715.2150878906, 12.792504310608}; } local curMarkerBlip local curMarker local ID function event() call(getResourceFromName("guitext"),"outputServerGuiText",root,"An event was placed on your Map",0,255,0) createCheckpoint( 1 ) ID = 1 end addEvent ("event", true) addEventHandler ("event", root, event) function createCheckpoint(ID) if ID then if isElement(curMarker) and isElement(curMarkerBlip) then destroyElement(curMarker) destroyElement(curMarkerBlip) end local x, y, z = unpack(markers[tonumber(ID)]) curMarker = createMarker( x, y, z, "checkpoint", 2, 135, 191, 255, 200 ) curMarkerBlip = createBlipAttachedTo( curMarker, 0 ) return true end return false end addEventHandler( "onClientMarkerHit", resourceRoot, function (hitPlayer, dim) if (curMarker and source == curMarker and hitPlayer == localPlayer and dim) then ID = ID + 1 if ID > #markers then ID = 1 end createCheckpoint( ID ) -- create the next checkpoint end end ) I've tested this code and it worked for me. Link to comment
xRGamingx Posted June 6, 2018 Author Share Posted June 6, 2018 On 4/6/2018 at 22:46, DNL291 said: I've tested this code and it worked for me. Hello friend, this still does not work.. pass me the code the way you use it in your test for me to put it as is in mine because it still does not work, the first checkpoint appears, but when you touch it it does not disappear to see the next one Link to comment
DNL291 Posted June 7, 2018 Share Posted June 7, 2018 (edited) If nothing happens when you hit the marker, something is wrong, so learn how to debug: Also, make sure the marker really belongs to the script and your player dimension is the same as the marker. Edited June 7, 2018 by DNL291 Link to comment
Dzsozi (h03) Posted June 7, 2018 Share Posted June 7, 2018 (edited) Try it this way, since you are trying to make the marker disappear in a vehicle on the picture, but the hitElement must be the localPlayer based on the previous code. addEventHandler( "onClientMarkerHit", resourceRoot, function (hitElement, dim) if (curMarker and source == curMarker and (hitElement == localPlayer or hitElement == getPedOccupiedVehicle(localPlayer)) and dim) then ID = ID + 1 if ID > #markers then ID = 1 end createCheckpoint( ID ) -- create the next checkpoint end end ) Or just try deleting it and then test if and see if it works. addEventHandler( "onClientMarkerHit", resourceRoot, function (hitElement, dim) if (curMarker and source == curMarker and dim) then ID = ID + 1 if ID > #markers then ID = 1 end createCheckpoint( ID ) -- create the next checkpoint end end ) Edited June 7, 2018 by Dzsozi (h03) Link to comment
xRGamingx Posted June 7, 2018 Author Share Posted June 7, 2018 1 hour ago, Dzsozi (h03) said: Try it this way, since you are trying to make the marker disappear in a vehicle on the picture, but the hitElement must be the localPlayer based on the previous code. addEventHandler( "onClientMarkerHit", resourceRoot, function (hitElement, dim) if (curMarker and source == curMarker and (hitElement == localPlayer or hitElement == getPedOccupiedVehicle(localPlayer)) and dim) then ID = ID + 1 if ID > #markers then ID = 1 end createCheckpoint( ID ) -- create the next checkpoint endend ) Or just try deleting it and then test if and see if it works. addEventHandler( "onClientMarkerHit", resourceRoot, function (hitElement, dim) if (curMarker and source == curMarker and dim) then ID = ID + 1 if ID > #markers then ID = 1 end createCheckpoint( ID ) -- create the next checkpoint endend ) Friend does not work with any What I want to achieve is to create race events within my RPG mode server with checkpoint help plz . Or if you have an equal script to help me Link to comment
xRGamingx Posted June 8, 2018 Author Share Posted June 8, 2018 22 hours ago, xRGamingx said: Friend does not work with any What I want to achieve is to create race events within my RPG mode server with checkpoint help plz . Or if you have an equal script to help me @Dzsozi (h03) 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