Jump to content

addcommand to bind key


Recommended Posts

I would like to modify this code
addCommandHandler("epilot", for bindkey

 

local animEnable = {}
local syncPlayers = {}

addCommandHandler("epiloto",
    function(player)
        if (not animEnable[player]) then
            animEnable[player] = true
            triggerClientEvent(syncPlayers, "fuga4", player, true)
            outputChatBox("", player, 0, 255, 0, true)
        else
            animEnable[player] = false
            triggerClientEvent(syncPlayers, "fuga4", player, false)
            outputChatBox("", player, 255, 0, 0, true)
        end
    end
)

addEvent("onClientSync", true )
addEventHandler("onClientSync", resourceRoot,
    function()
        table.insert(syncPlayers, client)
        for player, enable in ipairs(animEnable) do
            if (enable) then
                triggerClientEvent(client, "fuuga4", player, true)
            end
        end
    end 
)

addEventHandler("onPlayerQuit", root,
    function()
        for i, player in ipairs(syncPlayers) do
            if source == player then 
                table.remove(syncPlayers, i)
                break
            end 
        end
        if (animEnable[source] == true or animEnable[source] == false) then animEnable[source] = nil end
    end
)


 

 

 

 

Link to comment
  • 2 weeks later...

replace the commandhandler line above the function with this

bindKey(player, "ENTER KEY HERE", "down",
I suggest you get visual studio code for coding and install the MTA LUA extension in it. this will tell you the syntax of functions as you type them and is very handy. the syntax is also available on the wiki. To add the bindkey you would add the required syntax before that function replacing the commandhandler since both commands and binds require a handler function (the long function you have written
Edited by 5150
Link to comment

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