WeeD1 Posted April 7, 2019 Share Posted April 7, 2019 (edited) Oi gente, estou com um problema, já pesquisei em alguns tópicos aqui no forum, mas não achei uma solução para isso, alguém que possa me ajudar? WARNING: drift\c.lua:14: Bad usage @ 'addEventHandler' ['onClientPlayerWasted' with this function is already handled] WARNING: drift\c.lua:15: Bad usage @ 'addEventHandler' ['onClientRender' with this function is already handled] WARNING: drift\c.lua:16: Bad usage @ 'addEventHandler' ['onClientPreRender' with this function is already handled] Código: function checkVehicle(vehicleEntered) local isForcedFalse = forcedEvents[eventName] ~= true if localPlayer.inVehicle == inVehicle and isForcedFalse then return end local tempVehicle = vehicleEntered or getPedOccupiedVehicle(localPlayer) local seat = getPedOccupiedVehicleSeat(localPlayer) inVehicle = ((seat == 0 and allowedType[tempVehicle.vehicleType]) and (isForcedFalse and localPlayer.inVehicle or false) or false) if inVehicle and seat==0 then vehicle = tempVehicle addEventHandler("onClientVehicleDamage",vehicle,onCollide) addEventHandler("onClientElementDestroy",vehicle,checkVehicle) addEventHandler("onClientPlayerWasted",localPlayer,checkVehicle) addEventHandler("onClientRender",root,drawMeter) addEventHandler("onClientPreRender", root, updateFPS) elseif not inVehicle and vehicle then removeEventHandler("onClientVehicleDamage",vehicle,onCollide) removeEventHandler("onClientElementDestroy",vehicle,checkVehicle) removeEventHandler("onClientPlayerWasted",localPlayer,checkVehicle) removeEventHandler("onClientRender",root,drawMeter) removeEventHandler("onClientPreRender", root, updateFPS) vehicle=nil end end Edited April 7, 2019 by WeeD1 Link to comment
#DeltaSCR Posted April 7, 2019 Share Posted April 7, 2019 Poste o resto de seu código, esses erros significam que os eventos já foram adicionados em outra parte do código Link to comment
WeeD1 Posted April 7, 2019 Author Share Posted April 7, 2019 local screenWidth,screenHeight = guiGetScreenSize() local score = 0 local combo = 0 local multiplier = 1 local failDrift = false local size = 2.5 local fps = getFPSLimit() local vehicle local inVehicle = false local multipliers = { {100000,5}, {50000,4}, {25000,3}, {10000,2}, {0,1}, } local screen = {guiGetScreenSize()}; local x, y = (screen[1]/1366), (screen[2]/768) local textX = screenWidth/2 local textY = screenHeight/4 local lineY = 45 local textScale = 2.5 local red = tocolor(255, 255, 255) local green = tocolor(255, 255, 255) local font = "default-bold" local alignX = "center" local alignY = "center" local gui = {} local allowedType = { ["Automobile"] = true, ["Quad"] = true, ["Monster Truck"] = true, } local forcedEvents = { ["onClientElementDestroy"] = true, ["onClientPlayerWasted"] = true, } local function convertNumber ( number ) local formatted = number while true do formatted, k = string.gsub(formatted, "^(-?%d+)(%d%d%d)", '%1.%2') if ( k==0 ) then break end end return formatted end local function checkVehicleHandling() if not isElement(vehicle) then return end local flags = getVehicleHandling(vehicle)["handlingFlags"] if (bitAnd( flags, 32 ) == 32) or (bitAnd( flags, 64 ) == 64) then return true end end local function driftEnd (endscore,endcombo) local oldBestDrift = getElementData (localPlayer,"Best Drift") or 0 local oldTotalDrift = getElementData (localPlayer,"Total Drift") or 0 score = 0 combo = 0 if endscore ~= 0 then setElementData(localPlayer,"Total Drift",math.floor(endscore+oldTotalDrift)) setElementData(localPlayer,"Last Drift",math.floor(endscore)) end if endscore > oldBestDrift then setElementData(localPlayer,"Best Drift",endscore) end if endscore >= 2000 then triggerServerEvent("onDriftEnd",localPlayer,endscore) triggerEvent("onClientDriftEnd",localPlayer,endscore) end end local function calculateAngle () if not allowedType[vehicle.vehicleType] then return 0,0 end if not isVehicleOnGround(vehicle) then return 0,0 end if failDrift then return 0,0 end local vx,vy,vz = getElementVelocity(vehicle) local rx,ry,rz = getElementRotation(vehicle) local sn,cs = -math.sin(math.rad(rz)), math.cos(math.rad(rz)) local speed = (vx^2 + vy^2 + vz^2)^(0.5) local modV = math.sqrt(vx*vx + vy*vy) local cosX = (sn*vx + cs*vy)/modV if modV <= 0.2 then return 0,0 end if cosX > 0.966 or cosX < 0 then return 0,0 end return math.deg(math.acos(cosX))*0.5,speed end local function updateFPS(msSinceLastFrame) fps = (1 / msSinceLastFrame) * 1000 end local function resetFail() failDrift = false showScore=false end local function onCollide(attacker) if attacker or failDrift then return end failDrift = true driftEnd(0,0) setTimer(resetFail,2000,1) end local function drawMeter () if isWorldSpecialPropertyEnabled("hovercars") then return end if checkVehicleHandling() then return end if not isElement(vehicle) then return end if localPlayer.vehicle ~= vehicle then removeEventHandler("onClientVehicleDamage",vehicle,onCollide) removeEventHandler("onClientElementDestroy",vehicle,checkVehicle) removeEventHandler("onClientPlayerWasted",localPlayer,checkVehicle) removeEventHandler("onClientRender",root,drawMeter) removeEventHandler("onClientPreRender", root, updateFPS) vehicle=nil inVehicle=false checkVehicle() return end local angle,speed = calculateAngle() if isTimer (resetTimer) and angle ~= 0 then killTimer(resetTimer) showScore = true if comboReady then combo = combo + 1 comboReady = false end end if angle == 0 then if not isTimer(resetTimer) then comboReady = true resetTimer = setTimer (function() if score == 0 then return end driftEnd (score,combo) score = 0 combo = 0 showScore = false end,1300,1) end end local gameSpeed = getGameSpeed() for k,v in ipairs(multipliers) do local pointsNeeded,multi = unpack(multipliers[k]) if score > pointsNeeded then multiplier = multi break end end local fpsMultiplier = 100/fps local angleScore = angle/2 local speedScore = speed*3 local driftScore = angleScore*speedScore local addScore = math.floor(driftScore*multiplier) local gameSpeedFixedScore = math.floor(gameSpeed*addScore) score = score + math.floor(fpsMultiplier*gameSpeedFixedScore) if showScore then local color = (failDrift and red or green) --dxDrawText ("Pontos de Drift x"..tostring(combo),textX,0,textX,textY-lineY,color,textScale,font,alignX,alignY) dxDrawText (convertNumber(score),textX,0,textX,textY,color,textScale,font,alignX,alignY) end end function checkVehicle(vehicleEntered) local isForcedFalse = forcedEvents[eventName] ~= true if localPlayer.inVehicle == inVehicle and isForcedFalse then return end local tempVehicle = vehicleEntered or getPedOccupiedVehicle(localPlayer) local seat = getPedOccupiedVehicleSeat(localPlayer) inVehicle = ((seat == 0 and allowedType[tempVehicle.vehicleType]) and (isForcedFalse and localPlayer.inVehicle or false) or false) if inVehicle and seat==0 then vehicle = tempVehicle addEventHandler("onClientVehicleDamage",vehicle,onCollide) addEventHandler("onClientElementDestroy",vehicle,checkVehicle) addEventHandler("onClientPlayerWasted",localPlayer,checkVehicle) addEventHandler("onClientRender",root,drawMeter) addEventHandler("onClientPreRender", root, updateFPS) elseif not inVehicle and vehicle then removeEventHandler("onClientVehicleDamage",vehicle,onCollide) removeEventHandler("onClientElementDestroy",vehicle,checkVehicle) removeEventHandler("onClientPlayerWasted",localPlayer,checkVehicle) removeEventHandler("onClientRender",root,drawMeter) removeEventHandler("onClientPreRender", root, updateFPS) vehicle=nil end end local function loadRecords(records,maxPosition,myAcc) grid:Clear() local guestID = 0 for position,record in ipairs(records) do local player,score,name,isGuest = record.username,record.score,record.playername,record.isGuest if isGuest == "true" then guestID=guestID+1 if myAcc == "guest" then myAcc = hash("sha512",getPlayerSerial()) end end grid:AddItem(1,tostring(position)) grid:AddItem(2,name) grid:AddItem(3,(isGuest == "true" and "guest_"..tostring(guestID) or player)) grid:AddItem(4,convertNumber(score)) if player == myAcc then end end end Link to comment
WeeD1 Posted April 8, 2019 Author Share Posted April 8, 2019 Alguém pra ajudar? por favor. Link to comment
Gw8 Posted April 9, 2019 Share Posted April 9, 2019 function checkVehicle(vehicleEntered) local isForcedFalse = forcedEvents[eventName] ~= true if localPlayer.inVehicle == inVehicle and isForcedFalse then return end local tempVehicle = vehicleEntered or getPedOccupiedVehicle(localPlayer) local seat = getPedOccupiedVehicleSeat(localPlayer) inVehicle = ((seat == 0 and allowedType[tempVehicle.vehicleType]) and (isForcedFalse and localPlayer.inVehicle or false) or false) if inVehicle and seat==0 then vehicle = tempVehicle removeEventHandler("onClientPlayerWasted",localPlayer,checkVehicle) removeEventHandler("onClientRender",root,drawMeter) removeEventHandler("onClientPreRender", root, updateFPS) addEventHandler("onClientVehicleDamage",vehicle,onCollide) addEventHandler("onClientElementDestroy",vehicle,checkVehicle) addEventHandler("onClientPlayerWasted",localPlayer,checkVehicle) addEventHandler("onClientRender",root,drawMeter) addEventHandler("onClientPreRender", root, updateFPS) elseif not inVehicle and vehicle then removeEventHandler("onClientVehicleDamage",vehicle,onCollide) removeEventHandler("onClientElementDestroy",vehicle,checkVehicle) removeEventHandler("onClientPlayerWasted",localPlayer,checkVehicle) removeEventHandler("onClientRender",root,drawMeter) removeEventHandler("onClientPreRender", root, updateFPS) vehicle=nil end end 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