Sign in to follow this  

bindKey (server)

Recommended Posts

Hey I need some help, regarding "bindKey"

so what I basicly want to do is check if the player is pressing down a button, and when he does, I want to return a boolean value.


function keyInput(player, key, keyState)
	if(keyState == "down") then
	outputChatBox("Pressing: " .. key)

function bindKeysWhenPlayerJoin()
	bindKey(source, "lalt", "down", keyInput)
addEventHandler("onPlayerJoin", getRootElement(), bindKeysWhenPlayerJoin)

So basicly I have the basics down, when the player joins the server the keys will bind, and when I press "lalt" then it gets printed out to the player's chat box.

The issue here is though, that I can't use this, for like anything, since I cannot return a value that I can later use.

Let me give an example.


Psuedo code:

I want to check if

- The player is colliding with a static pickup

- The player is pressing lalt

then print a message



function playerPickupCollision(pickup, dimension)
    -- Jobs
    for i = 1, #pickupInformation do
        if(pickup == pickupInformation[i][PICKUP_ID]) then
            outputChatBox(i, source)
            if(pickupInformation[i][TYPE] == "Job" && pressing_key("lalt")) then
                outputChatBox("Press LALT to become a " .. pickupInformation[i][DESCRIPTION], source)
            if(pickupInformation[i][TYPE] == "Property" && pressing_key("lalt")) then
                outputChatBox("This is the " .. pickupInformation[i][DESCRIPTION], source)
addEventHandler("onPlayerPickupHit", getRootElement(), playerPickupCollision)

(pressing_key isn't an actual function. it's the kind of function I want to create)


Thank you!

Share this post

Link to post

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
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.