Jump to content

[HELP]Jump Car Command


Mahdi0793

Recommended Posts

Posted

I want to command this code in order to turn the car jump mode on and off help me :(?

 

bindKey ( "lshift","down",
function  () 
    local vehicle = getPedOccupiedVehicle(localPlayer) 
    if (isVehicleOnGround( vehicle ) == true) then           
    local sx,sy,sz = getElementVelocity ( vehicle ) 
                    setElementVelocity( vehicle ,sx, sy, sz+0.55 ) 
    end 
end 
)

 

Posted
44 minutes ago, Mahdi0793 said:

I want to command this code in order to turn the car jump mode on and off help me :(?

 

bindKey ( "lshift","down",
function  () 
    local vehicle = getPedOccupiedVehicle(localPlayer) 
    if (isVehicleOnGround( vehicle ) == true) then           
    local sx,sy,sz = getElementVelocity ( vehicle ) 
                    setElementVelocity( vehicle ,sx, sy, sz+0.55 ) 
    end 
end 
)

 

Please Help Me :(

Posted

try this:

function jumpKey()
	if not isPedInVehicle(localPlayer) then return end

	local vehicle = getPedOccupiedVehicle(localPlayer)
	if vehicle and getVehicleController(vehicle) == localPlayer then
		local vehType = getVehicleType(vehicle)
		if vehType == "Plane" or vehType == "Helicopter" then return end
		local sx, sy, sz = getElementVelocity(vehicle)
		setElementVelocity(vehicle, sx, sy, sz + 0.33)
	end
end
addCommandHandler("jumpc",jumpKey)

 

Posted
15 minutes ago, SinaAmp said:

try this:

function jumpKey()
	if not isPedInVehicle(localPlayer) then return end

	local vehicle = getPedOccupiedVehicle(localPlayer)
	if vehicle and getVehicleController(vehicle) == localPlayer then
		local vehType = getVehicleType(vehicle)
		if vehType == "Plane" or vehType == "Helicopter" then return end
		local sx, sy, sz = getElementVelocity(vehicle)
		setElementVelocity(vehicle, sx, sy, sz + 0.33)
	end
end
addCommandHandler("jumpc",jumpKey)

 

Work in the same shift and turn the command on and off, the same on and off

1 minute ago, Mahdi0793 said:

Work in the same shift and turn the command on and off, the same on and off

That is, when it is on, only the shift works

Posted

Test this:

commands "jumpc" and "cancelj"

function jumpKey()
	if not isPedInVehicle(localPlayer) then return end
	local vehicle = getPedOccupiedVehicle(localPlayer)
	if vehicle and getVehicleController(vehicle) == localPlayer then
		local vehType = getVehicleType(vehicle)
		if vehType == "Plane" or vehType == "Helicopter" then return end
		local sx, sy, sz = getElementVelocity(vehicle)
        setElementVelocity(vehicle, sx, sy, sz + 2)
	end
end
addCommandHandler("jumpc",jumpKey)

function cjumpKey()
	if not isPedInVehicle(localPlayer) then return end
    local vehicle = getPedOccupiedVehicle(localPlayer)
	if vehicle and getVehicleController(vehicle) == localPlayer then
		local vehType = getVehicleType(vehicle)
		if vehType == "Plane" or vehType == "Helicopter" then return end
		local sx, sy, sz = getElementVelocity(vehicle)
        local px, py, pz = getElementPosition(vehicle)
        setElementPosition(vehicle,px,py,35.33)
    end
end


addCommandHandler("cancelj",cjumpKey)

 

Posted
local jumpActivated = false

function jumpVehicle()
  if jumpActivated == true then
    local vehicle = getPedOccupiedVehicle(localPlayer)
    if vehicle then
       if isVehicleOnGround(vehicle) then
          local vx, vy, vz = getElementVelocity(vehicle)
          setElementVelocity(vehicle, vx, vy, vz+0.5)
       end
    end
  elseif jumpActivated == false then
    outputChatBox("#FF0000[CAR JUMP]: #FFFfffCar Jump is not activated, please use /ecarjump to activate", 255, 255, 255, true)
  end
end
bindKey("lshift", "down", jumpVehicle)

function activateJump()
  if jumpActivated == false then
    jumpActivated = true
    elseif jumpActivated == true then
    jumpActivated = false
    end
  end
addCommandHandler("ecarjump", activateJump)

Is this what you want?

Posted
22 minutes ago, Hydra said:
local jumpActivated = false

function jumpVehicle()
  if jumpActivated == true then
    local vehicle = getPedOccupiedVehicle(localPlayer)
    if vehicle then
       if isVehicleOnGround(vehicle) then
          local vx, vy, vz = getElementVelocity(vehicle)
          setElementVelocity(vehicle, vx, vy, vz+0.5)
       end
    end
  elseif jumpActivated == false then
    outputChatBox("#FF0000[CAR JUMP]: #FFFfffCar Jump is not activated, please use /ecarjump to activate", 255, 255, 255, true)
  end
end
bindKey("lshift", "down", jumpVehicle)

function activateJump()
  if jumpActivated == false then
    jumpActivated = true
    elseif jumpActivated == true then
    jumpActivated = false
    end
  end
addCommandHandler("ecarjump", activateJump)

Is this what you want?

Thank you very much. Can you enable and disable this code as above?

 

g_P = getLocalPlayer() 
rocketTimer = false
function rocket()

    if not rocketTimer and isPedInVehicle(g_P) then

        local occupiedVehicle = getPedOccupiedVehicle(g_P)

        local rotX,rotY,rotZ = getElementRotation(occupiedVehicle)

        local x, y, z = getElementPosition(occupiedVehicle)

        local matrix = getElementMatrix(occupiedVehicle)

        local offX = 0 * matrix[1][1] + 1 * matrix[2][1] + 0 * matrix[3][1] + 1 * matrix[4][1]

        local offY = 0 * matrix[1][2] + 1 * matrix[2][2] + 0 * matrix[3][2] + 1 * matrix[4][2]

        local offZ = 0 * matrix[1][3] + 1 * matrix[2][3] + 0 * matrix[3][3] + 1 * matrix[4][3]

        local vx = offX - x

        local vy = offY - y

        local vz = offZ - z

        x = 0 * matrix[1][1] + 3 * matrix[2][1] + 0 * matrix[3][1] + 1 * matrix[4][1]

        y = 0 * matrix[1][2] + 3 * matrix[2][2] + 0 * matrix[3][2] + 1 * matrix[4][2]

        z = 0 * matrix[1][3] + 3 * matrix[2][3] + 0 * matrix[3][3] + 1 * matrix[4][3]

        createProjectile(g_P, 19, x, y, z, 200, nil, 0, 0, 360 - rotZ, vx, vy, vz)

        rocketTimer = setTimer(function() rocketTimer = false end, 3000, 1)

    else

        outputChatBox("#ff00003 Sec Wait!", 0, 0, 0, true)

    end

end

function onResourceStart()

    bindKey("lctrl", "down", rocket)

end

addEventHandler("onClientResourceStart", resourceRoot, onResourceStart)

 

Posted
13 hours ago, Mahdi0793 said:

Thank you very much. Can you enable and disable this code as above?

 

g_P = getLocalPlayer() 
rocketTimer = false
function rocket()

    if not rocketTimer and isPedInVehicle(g_P) then

        local occupiedVehicle = getPedOccupiedVehicle(g_P)

        local rotX,rotY,rotZ = getElementRotation(occupiedVehicle)

        local x, y, z = getElementPosition(occupiedVehicle)

        local matrix = getElementMatrix(occupiedVehicle)

        local offX = 0 * matrix[1][1] + 1 * matrix[2][1] + 0 * matrix[3][1] + 1 * matrix[4][1]

        local offY = 0 * matrix[1][2] + 1 * matrix[2][2] + 0 * matrix[3][2] + 1 * matrix[4][2]

        local offZ = 0 * matrix[1][3] + 1 * matrix[2][3] + 0 * matrix[3][3] + 1 * matrix[4][3]

        local vx = offX - x

        local vy = offY - y

        local vz = offZ - z

        x = 0 * matrix[1][1] + 3 * matrix[2][1] + 0 * matrix[3][1] + 1 * matrix[4][1]

        y = 0 * matrix[1][2] + 3 * matrix[2][2] + 0 * matrix[3][2] + 1 * matrix[4][2]

        z = 0 * matrix[1][3] + 3 * matrix[2][3] + 0 * matrix[3][3] + 1 * matrix[4][3]

        createProjectile(g_P, 19, x, y, z, 200, nil, 0, 0, 360 - rotZ, vx, vy, vz)

        rocketTimer = setTimer(function() rocketTimer = false end, 3000, 1)

    else

        outputChatBox("#ff00003 Sec Wait!", 0, 0, 0, true)

    end

end

function onResourceStart()

    bindKey("lctrl", "down", rocket)

end

addEventHandler("onClientResourceStart", resourceRoot, onResourceStart)

 


g_P = getLocalPlayer() 
rocketTimer = false
rocketActivated = false

function rocket()
if rocketActivated == true then
    if not rocketTimer and isPedInVehicle(g_P) then
        local occupiedVehicle = getPedOccupiedVehicle(g_P)
        local rotX,rotY,rotZ = getElementRotation(occupiedVehicle)
        local x, y, z = getElementPosition(occupiedVehicle)
        local matrix = getElementMatrix(occupiedVehicle)
        local offX = 0 * matrix[1][1] + 1 * matrix[2][1] + 0 * matrix[3][1] + 1 * matrix[4][1]
        local offY = 0 * matrix[1][2] + 1 * matrix[2][2] + 0 * matrix[3][2] + 1 * matrix[4][2]
        local offZ = 0 * matrix[1][3] + 1 * matrix[2][3] + 0 * matrix[3][3] + 1 * matrix[4][3]
        local vx = offX - x
        local vy = offY - y
        local vz = offZ - z
        x = 0 * matrix[1][1] + 3 * matrix[2][1] + 0 * matrix[3][1] + 1 * matrix[4][1]
        y = 0 * matrix[1][2] + 3 * matrix[2][2] + 0 * matrix[3][2] + 1 * matrix[4][2]
        z = 0 * matrix[1][3] + 3 * matrix[2][3] + 0 * matrix[3][3] + 1 * matrix[4][3]
        createProjectile(g_P, 19, x, y, z, 200, nil, 0, 0, 360 - rotZ, vx, vy, vz)
        rocketTimer = setTimer(function() rocketTimer = false end, 3000, 1)
    else
        outputChatBox("#ff00003 Sec Wait!", 0, 0, 0, true)
    end
else
outputChatBox("#ff0000Rocket is not enabled please use /erocket", 255, 255, 255, true)
end
end
bindKey("lctrl", "down", rocket)

function rocketEnable()
   if rocketActivated == false then
      rocketActivated = true
   elseif rocketActivated == true then
      rocketActivated = false
   end
end
addCommandHandler("erocket", rocketEnable)

Try this

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...