Destroyer.- Posted February 3, 2015 Share Posted February 3, 2015 Hola a todos encontre un script de bus en la comunidad , y lo use todo pero cuando uno agarra el colectivo , y viene otro y agarra y se baja se cancela la mision aca : Servidor: local rootElement = getRootElement() local busses = {[431] = true, [437] = true} local busTable = { [1]={1823.5513916016,-1803.4302978516,13.392281532288}, [2]={1825.22791, -1635.03711, 13.38281}, [3]={1855.01685, -1430.47449, 13.39063}, [4]={1732.81580, -1296.87122, 13.44294}, [5]={1473.19226, -1295.77124, 13.48315}, [6]={1443.60376, -1498.26660, 13.37650}, [7]={1426.37280, -1716.12439, 13.38281}, [8]={1315.06909, -1656.43799, 13.38281}, [9]={1359.06250, -1432.39734, 13.38281}, [10]={1169.82983, -1392.34473, 13.41728}, [11]={930.76508, -1392.92627, 13.26561}, [12]={815.24756, -1317.91345, 13.44460}, [13]={585.04199, -1320.53748, 13.40609}, [14]={526.99365, -1624.20361, 16.63225} } function getNewBusLocation(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 onVehicleEnter(thePlayer) if not busses[getElementModel(source)] then return end if not getPlayerTeam(thePlayer) then return end if getTeamName(getPlayerTeam(thePlayer)) == "Civiles" then local x, y, z = getNewBusLocation(thePlayer, 1) setElementData(thePlayer,"busData",1) end end addEventHandler("onVehicleEnter",rootElement,onVehicleEnter) addEvent("bus_finish",true) addEventHandler("bus_finish",rootElement, function () if isPedInVehicle(source) then local vehicle = getPedOccupiedVehicle ( source ) if busses[getElementModel(vehicle)] then setElementFrozen ( vehicle, true ) fadeCamera(source, false, 1.-- s8) --> setTimer(fadeCamera, 3000, 1, source, true) setTimer(setElementFrozen, 3000, 1, vehicle, false) dinero = math.random(100,500) givePlayerMoney(source, dinero) outputChatBox("[iNFO]Ganaste $"..dinero, source, 0, 255, 0, true) if #busTable == tonumber(getElementData(source,"busData")) then setElementData(source,"busData",1) else setElementData(source,"busData",tonumber(getElementData(source,"busData"))+1) end test = getElementData(source,"busData") if test == 5 then outputChatBox("[iNFO]BOnus $5.000", source, 0, 255, 0, true) givePlayerMoney(source, 5000) end getNewBusLocation(source, tonumber(getElementData(source,"busData"))) end end end ) Client local client = getLocalPlayer( ) local rootElement = getRootElement() local marker = nil local blip = nil addEvent("bus_set_location",true) addEventHandler("bus_set_location",rootElement, function (x, y, z) marker = createMarker(tostring(x), tostring(y), tostring(z)-1, "checkpoint", 4.0, 0, 0, 255, 255) blip = createBlipAttachedTo( marker, 0, 3, 0, 0, 255, 255 ) addEventHandler("onClientMarkerHit",marker,onBusStopHit) end) function onBusStopHit(hitPlayer) if client == hitPlayer then triggerServerEvent("bus_finish",client) if isElement(blip) then destroyElement(blip) end if isElement(marker) then removeEventHandler("onClientMarkerHit",marker,onBusStopHit) destroyElement(marker) end end end function auto(thePlayer) if (getElementModel(source) == 431 ) and ( getElementModel (thePlayer) == 156 ) then destroyElement(marker) destroyElement(blip) end end addEventHandler("onClientVehicleExit",rootElement, auto) Gracias Link to comment
Tomas Posted February 3, 2015 Share Posted February 3, 2015 El problema es.. cuando alguien se baja se pierden todas las misiones o cuando Pedro se baja la misión de Pedro se cancela? En caso de que el problema sea la última remueve la última función y su respectivo evento que se encuentra en el client. Link to comment
Destroyer.- Posted February 3, 2015 Author Share Posted February 3, 2015 El problema es.. cuando alguien se baja se pierden todas las misiones o cuando Pedro se baja la misión de Pedro se cancela?En caso de que el problema sea la última remueve la última función y su respectivo evento que se encuentra en el client. Cuando 1 se baja pierden todos las misiones ,por ejemplo hay 3 jugadores , cuando estan dentro del bus , bien , pero cuando 1 sale se le destruye los blips y los markers de todos Link to comment
Tomas Posted February 3, 2015 Share Posted February 3, 2015 function auto(thePlayer,seat) if thePlayer == localPlayer and seat == 0 then if (getElementModel(source) == 431 ) and ( getElementModel (thePlayer) == 156 ) then destroyElement(marker) destroyElement(blip) end end end addEventHandler("onClientVehicleExit",rootElement, auto) Link to comment
Destroyer.- Posted February 3, 2015 Author Share Posted February 3, 2015 Muchas gracias men Link to comment
Recommended Posts