waterplaygames Posted January 28, 2019 Share Posted January 28, 2019 Hola, tengo una script que me facilita la modificación de rutas y eso, pero quiero añadir mas rutas y que a la hora de coger un bus salga una ruta y si coge otro que salga otra ruta, son 10 rutas las que tengo pero lo he intentado de muchas maneras y no consigo poner mas de 1 ruta. local rootElement = getRootElement() local busses = {[431] = true, [437] = true} local busTable = { [1]={2341.08008, 254.46613, 26.77982},[2]={1384.49072, 446.74542, 20.31025},[3]={785.14990, 337.11038, 20.47677},[4]={218.50070, 54.91001, 2.59345},[5]={-37.93279, 186.94962, 2.51513}, [6]={-780.84589, 176.88986, 4.20245},[7]={-801.76013, -105.41871, 64.15147},[8]={-125.47652, -401.58975, 1.53782},[9]={1202.70044, -159.35268, 40.76083},[10]={1513.83557, 89.98413, 30.25498}, [11]={2346.74780, 238.26855, 26.77025},[12]={2370.31104, 272.22159, 26.65545},[13]={2178.53760, 44.51852, 26.77347},[14]={1494.40198, 92.72229, 30.46353},[15]={1187.22803, -152.97209, 41.05466}, [16]={-154.23553, -359.67560, 1.86264},[17]={-813.50641, -120.67672, 63.69178},[18]={-686.76483, 242.10464, 2.52678},[19]={2.42428, 152.58315, 2.53380},[20]={280.75461, 54.00553, 2.60478}, [21]={730.80847, 312.94794, 20.45628},[22]={1453.51099, 386.39627, 19.67584},[23]={2341.18091, 262.41519, 26.77247},[24]={2370.27295, 272.17935, 26.66003} } createBlip(2370.31104, 272.22159, 26.65545, 55, 3, 0, 0, 255, 255, 0, 250) function getBusLocation (thePlayer, ID) local x, y, z = busTable[ID][1], busTable[ID][2], busTable[ID][3] triggerClientEvent(thePlayer,"bus_set_location",thePlayer,x,y,z) end function busJob(thePlayer) local theVehicle = getPedOccupiedVehicle (thePlayer) local id = getElementModel(theVehicle) if id == 431 or id == 437 then local x, y, z = getNewBusLocation(thePlayer, 1) setElementData(thePlayer,"buszp",0) setElementData(thePlayer,"busData",1) else end end addEventHandler("onVehicleEnter",rootElement,busJob) function busStart(thePlayer) local theVehicle = getPedOccupiedVehicle (thePlayer) local id = getElementModel(theVehicle) if id == 431 or id == 437 then outputChatBox("Línea 01", thePlayer, 255, 255, 0) end end addEventHandler("onVehicleEnter",rootElement,busStart) addEvent("bus_finish",true) addEventHandler("bus_finish",rootElement, function (client) if not isPedInVehicle(client) then return end if not busses[getElementModel(getPedOccupiedVehicle(client))] then return end local zarp = getElementData(client, "buszp") local money = math.random(10,20) setElementData(client, "buszp", zarp + money) if #busTable == tonumber(getElementData(client,"busData")) then setElementData(client,"busData",1) else setElementData(client,"busData",tonumber(getElementData(client,"busData"))+1) end getNewBusLocation(client, tonumber(getElementData(client,"busData"))) end) function giveMoney(thePlayer) local theVehicle = getPedOccupiedVehicle (thePlayer) local id = getElementModel(theVehicle) if id == 431 or 437 then local gpm = getElementData(thePlayer, "buszp") if ((gpm) > 0 ) then givePlayerMoney(thePlayer, tonumber(gpm)) outputChatBox("Tu sueldo es..." .. gpm .. "$", thePlayer, 0, 140, 240) setElementData(thePlayer, "buszp", 0) end end end addEventHandler("onVehicleExit", rootElement, giveMoney) addEventHandler("onPlayerQuit", rootElement, giveMoney) Link to comment
Peti Posted January 30, 2019 Share Posted January 30, 2019 local x, y, z = busTable[ID][1], busTable[ID][2], busTable[ID][3] Aquí le estás definiendo valores fijos, entonces siempre tomará esa ruta. Trata de usar la función table.random: https://wiki.multitheftauto.com/wiki/Table.random 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