Jump to content

How to bind key?


Military Guy

Recommended Posts

Posted

Instead of entering a command, I will assign a key

I added bindKey 

but it not working

help me please

 

function bomb ( player )
local car = getPedOccupiedVehicle ( player )
local x, y, z = getElementPosition(player)
    if (getElementModel(car) == 520) then
            bindKey("3", "down", bomb) 
              outputChatBox ( "Сброс бомб", player )
        setTimer ( AirstrikeThrow, 51, 1, player )
    end

end 
addCommandHandler ( "jetbomb", bomb )


function AirstrikeThrow ( player, x, y, z )

    triggerClientEvent ( getRootElement(), "AirstrikeThrowDo", getRootElement(), airStrikeTrash, player )
end

Posted (edited)

I've used DeepSeek to fix your code, there is this result:

 

-- Define the bomb function
function bomb(player)
    local car = getPedOccupiedVehicle(player)
    if getElementModel(car) == 520 then
        outputChatBox("Сброс бомб", player)
        local x, y, z = getElementPosition(player)
        setTimer(AirstrikeThrow, 51, 1, player, x, y, z)
    end
end

-- Bind the "3" key to the bomb function for each player when they spawn or enter the vehicle
function bindBombKey(player)
    bindKey(player, "3", "down", bomb)
end

-- Add event handlers to bind the key when the player spawns or enters a vehicle
addEventHandler("onPlayerJoin", root, bindBombKey)
addEventHandler("onVehicleEnter", root, function(player) bindBombKey(player) end)

-- Define the AirstrikeThrow function
function AirstrikeThrow(player, x, y, z)
    triggerClientEvent(getRootElement(), "AirstrikeThrowDo", getRootElement(), player)
end

 

Edited by xMKHx
Wrong Code

UDC:RPG Owner
13 Years Experience
______________________________________

 

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