Jump to content

[Help]Bus Job Bug


Narunix

Recommended Posts

- Hello I have an error in this appeal that when 2 players grab the same job is ultra bugea ie for example when a player enters the marker before or after my to me and another marker shows look to better understand

* A player starts the job and grab a bus and is the first to go through the marker and is the NEXT

* The player automatically after the will and the NEXT also bypassing the first marker

- That's the bug here a part of the script where I think this error

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, "Cylinder", 4.0, 255, 255, 255, 255) 
blip = createBlipAttachedTo( marker, 41, 3, 0, 0, 255, 255 ) 
addEventHandler("onClientMarkerHit",marker,onBusStopHit) 
end) 
  
function onBusStopHit(hitPlayer) 
if not hitPlayer == client then return end 
triggerServerEvent("bus_finish",client,client) 
if isElement(blip) then destroyElement(blip) end 
if isElement(marker) then 
removeEventHandler("onClientMarkerHit",marker,onBusStopHit) 
destroyElement(marker)  
  end 
end 
  
addEventHandler("onClientVehicleExit",rootElement, 
function () 
if isElement(marker) then 
removeEventHandler("onClientMarkerHit",marker,onBusStopHit) 
destroyElement(marker)  
end 
if isElement(blip) then destroyElement(blip) end 
end) 

o tal vez sea este..

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 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("Has Comenzado tu trabajo!", 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(1,50) 
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) 

If you help me with this, I upload the resource to the community but compilare and I'll upload it in different languages ​​if I may.

Link to comment

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...