Jump to content

Help me, please


Abohak

Recommended Posts

bindKey("aim_weapon", "both",function(key, state)

local weapon = getPedWeapon(getLocalPlayer())

if weapon ~= 0 and weapon ~=1 and weapon ~= 34 then

if state == "down" then

addEventHandler("onClientRender", root, drawCrosshair)

else

removeEventHandler("onClientRender", root, drawCrosshair)

end

end

end

)

[ [18:30:03] Starting c_dayz [ [18:30:05] WARNING: c_dayz/cross_pod.lua:11: Bad argument @ 'bindKey' [Expected [ player at argument 1, got string 'aim_weapon'] [ [18:30:05] Start up of resource c_dayz cancelled by script [ [18:30:05] Stopping c_dayz [ [18:30:05] start: Resource 'c_dayz' start was requested (Start up of resource ca [ ncelled by script)

What's the problem here?

Link to comment

The first argument of bindKey is the element to bind the key of. Try this:

bindKey(localPlayer, "aim_weapon", "both", 
    function(key, state)  
    local weapon = getPedWeapon(localPlayer) 
    if weapon ~= 0 and weapon ~=1 and weapon ~= 34 then 
        if state == "down" then  
            addEventHandler("onClientRender", root, drawCrosshair) 
        else 
            removeEventHandler("onClientRender", root, drawCrosshair) 
        end  
    end 
end 
) 

Link to comment
The first argument of bindKey is the element to bind the key of. Try this:
bindKey(localPlayer, "aim_weapon", "both", 
    function(key, state)  
    local weapon = getPedWeapon(localPlayer) 
    if weapon ~= 0 and weapon ~=1 and weapon ~= 34 then 
        if state == "down" then  
            addEventHandler("onClientRender", root, drawCrosshair) 
        else 
            removeEventHandler("onClientRender", root, drawCrosshair) 
        end  
    end 
end 
) 

You're first argument is localPlayer would let me think this is client side but client side bindKey's first argument is not a player element since client side's player argument always equals localPlayer.

bool bindKey ( string key, string keyState, function handlerFunction,  [ var arguments, ... ] ) 

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