Jump to content

BindKey Bad argument


Jade

Recommended Posts

S.lua

function openhelpacs(player) 
    if (isObjectInACLGroup("user."..getAccountName(getPlayerAccount(player)), aclGetGroup("TT"))) then 
    triggerClientEvent(player, "openhelp", root) 
end 
end 
  
function resourceStart () 
  bindKey (player,"F3", "down", openhelpacs) 
end 
addEventHandler ("onResourceStart",getResourceRootElement(getThisResource()),resourceStart) 

debugscript:

s.lua:8:Bad argument @ 'bindKey'

Link to comment
  • Moderators

You should defintly check this:

:arrow:Introduction to Scripting

function openhelpacs(player) 
    if (isObjectInACLGroup("user."..getAccountName(getPlayerAccount(player)), aclGetGroup("TT"))) then 
        triggerClientEvent(player, "openhelp", root) 
    end 
end 
  
-- When the resource starts, bind the key for everyone that are already on the server 
function resourceStart () 
    for k, p in ipairs (getElementsByType("player")) do 
        bindKey(p, "F3", "down", openhelpacs, p) 
    end 
end 
addEventHandler ("onResourceStart", resourceRoot, resourceStart) 
  
-- When a new player join, bind the key for him 
function playerJoins() 
    bindKey(source, "F3", "down", openhelpacs, source) 
end 
addEventHandler("onPlayerJoin", root, playerJoins) 

Link to comment
  • Moderators
function resourceStart () 
    for k,v in ipairs(getElementsByType("player")) do  
        bindKey (v,"F3", "down", openhelpacs) 
    end 
end 
addEventHandler("onResourceStart", resourceRoot, resourceStart) 

1 - The binds wont work if players join after the resource as beed started.

2 - The script will still not work because you don't send v as argument.

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