Jump to content

Darle Velocidad a un auto


Brad96

Recommended Posts

function sp(vehicle) 
setElementVelocity ( vehicle , 0 , 50 , 0) 
end  
  
function bind() 
bindKey (vehicle , "mouse1" , "down" , sp) 
end 
addEventHandler ("onPlayerVehicleEnter",getRootElement(),bind 

que pasa ahi ? no funciona

function sp(player) 
 local vehicle = getPedOccupiedVehicle ( player) 
setElementVelocity ( vehicle , 0 , 50 , 0) 
end  
  
function bind() 
bindKey (source, "mouse1" , "down" , sp) 
end 
addEventHandler ("onPlayerVehicleEnter",getRootElement(),bind 

Link to comment

try

function sp(player) 
 local vehicle = getPedOccupiedVehicle ( player) 
setElementSpeed(vehicle, "kph", 50) 
end 
  
function bind() 
bindKey (source, "mouse1" , "down" , sp) 
end 
addEventHandler ("onPlayerVehicleEnter",getRootElement(),bind) 
  
function setElementSpeed(element, unit, speed) -- only work if element is moving! 
    if (unit == nil) then unit = 0 end 
    if (speed == nil) then speed = 0 end 
    speed = tonumber(speed) 
    local acSpeed = getElementSpeed(element, unit) 
    if (acSpeed~=false) then -- if true - element is valid, no need to check again 
        local diff = speed/acSpeed 
        local x,y,z = getElementVelocity(element) 
        setElementVelocity(element,x*diff,y*diff,z*diff) 
        return true 
    end 
  
    return false 
end 
  
function getElementSpeed(element,unit) 
    if (unit == nil) then unit = 0 end 
    if (isElement(element)) then 
        local x,y,z = getElementVelocity(element) 
        if (unit=="mph" or unit==1 or unit =='1') then 
            return (x^2 + y^2 + z^2) ^ 0.5 * 100 
        else 
            return (x^2 + y^2 + z^2) ^ 0.5 * 1.8 * 100 
        end 
    else 
        outputDebugString("Not an element. Can't get speed") 
        return false 
    end 
end 

Link to comment
  • Recently Browsing   0 members

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