Doongogar Posted June 11, 2022 Share Posted June 11, 2022 Bem, eu queria fazer um codigo no qual um staff poderia dar tp no carro mais proximo, porém que não tenha um piloto Link to comment
FernandoMTA Posted June 14, 2022 Share Posted June 14, 2022 (edited) function irCarroProximo(thePlayer, cmd) -- checar permissao de staff aqui local x,y,z = getElementPosition(thePlayer) local int, dim = getElementInterior(thePlayer), getElementDimension(thePlayer) local closestVehicle = nil local smallestDistance = nil for k, vehicle in ipairs(getElementsByType("vehicle")) do local vx,vy,vz = getElementPosition(vehicle) local vint, vdim = getElementInterior(vehicle), getElementDimension(vehicle) -- verificar se tao no mesmo mundo if vint == int and vdim == dim then -- verificar se n tem ngm dentro if not getVehicleController(vehicle) then -- verificar posicao local dist = getDistanceBetweenPoints3D(x,y,z, vx,vy,vz) if (smallestDistance == nil) or (dist < smallestDistance) then smallestDistance = dist closestVehicle = vehicle end end end end if not closestVehicle then outputChatBox("Nenhum veículo desocupado foi encontrado", thePlayer, 255,0,0) return end local vx,vy,vz = getElementPosition(closestVehicle) setElementPosition(thePlayer, vx, vy, vz +3) outputChatBox("Teleportado para o veículo mais próximo#ffffff "..vx..", "..vy..", "..vz, thePlayer, 0,255,0, true) end addCommandHandler("ircarroproximo", irCarroProximo, false, false) se tiver alguma dúvida não hesite @SciptNovato Edited June 14, 2022 by FernandoMTA 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