OrbTanT Posted July 26, 2017 Share Posted July 26, 2017 Hello, I am transforming the game mode Race, in an event script, I made the script map and also made checkpoints work, I would like to know how I can recreate the placement of the players in the race, 1st, 2nd, 3rd .... And also how can I create the marker checkpoint just for the player, I tried this, that I will show in the code, but I would like to know if there is a better way to do it. Thank you. mapRace = nil currentId = 0 markerpoint = {} addEvent("startRaceEvent", true) addEventHandler("startRaceEvent", getRootElement(), function(mapName) local hud = raceHud.getInstance() local v = getPedOccupiedVehicle(localPlayer) for index, vehicle in ipairs(getElementsByType("vehicle")) do setElementCollidableWith(vehicle, v, false) end stopRace = Timer(stopRace, 60000*10, 1) hud:setVisible(true) mapRace = mapName for index, checkpoint in pairs (map[mapName..".checkpoint"]) do if (checkpoint[4] == "checkpoint0") then markerpoint[localPlayer] = {} markerpoint[localPlayer].marker = createMarker(checkpoint[1], checkpoint[2], checkpoint[3], "checkpoint", 3.0, 255, 0, 0, 200) markerpoint[localPlayer].marker:setData("checkpoint", checkpoint[4]) markerpoint[localPlayer].marker:setData("mapname", mapName) markerpoint[localPlayer].marker:setData("nextcheckpoint", checkpoint[5]) markerpoint[localPlayer].marker:setDimension(200) myBlip = createBlipAttachedTo(markerpoint[localPlayer].marker, 0) addEventHandler("onClientMarkerHit", markerpoint[localPlayer].marker, checkpointHit) end end end) function checkpointHit(hitPlayer, matchingDimension ) local nextId = source:getData("nextcheckpoint") local mapaName = source:getData("mapname") if (nextId) then for index, checkpoint in pairs (map[mapaName..".checkpoint"]) do if (checkpoint[4] == nextId) then playSoundFrontEnd(13) markerpoint[hitPlayer].marker:destroy() myBlip:destroy() currentId = currentId + 1 markerpoint[hitPlayer].marker = createMarker(checkpoint[1], checkpoint[2], checkpoint[3], "checkpoint", 3.0, 255, 0, 0, 200) markerpoint[hitPlayer].marker:setData("checkpoint", checkpoint[4]) markerpoint[hitPlayer].marker:setData("mapname", mapaName) markerpoint[hitPlayer].marker:setData("nextcheckpoint", checkpoint[5]) markerpoint[hitPlayer].marker:setDimension(200) myBlip = createBlipAttachedTo(markerpoint[hitPlayer].marker, 0) addEventHandler("onClientMarkerHit", markerpoint[hitPlayer].marker, checkpointHit) end end end end function stopRace() outputChatBox("Acabou o tempo do evento.") end Spoiler Link to comment
MisterQuestions Posted July 30, 2017 Share Posted July 30, 2017 Once someone finishes you add him to ranking board, then on race end/stop podium should get first 3 places of rankingboard and done. 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