Jump to content

bindKey problem


Overkillz

Recommended Posts

These days Im getting stupid problems.

IDK why this doesnt work

function changelang() 
    outputChatBox("Si functiona") 
end 
bindKey( source, "F1", "down", changelang ) 

Its server side (I wont do it client side)

Debugscript says something wrong at bindkey argument 1

I hope u can tell me why it doesnt do that.

Regards

Link to comment

your first argument should be the player who gets the command, source is a source of an event in this case source is undefined. If you wouldn't want to use source you should do it clientside since it requires not player argument.

You can for example loop through all players, serversided and attach the command too. Most events have the player of cause as the source but always double check the source on the wiki, sometimes it's a vehicle or a marker, ...

Link to comment

You need to bind it for everyone and when a player joins.

Like this:

addEventHandler("onPlayerJoin",root, 
    function () 
        bindKey( source, "F1", "down", changelang ) 
    end 
) 
  
addEventHandler("onResourceStart",resourceRoot, 
    function () 
        for index, player in ipairs(getElementsByType("player")) do 
            bindKey( player, "F1", "down", changelang ) 
        end 
    end 
) 

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