Jump to content

How fix this warning?


Tycka

Recommended Posts

local alpha = 255  
  
bindKey ( "aim_weapon", "both",  
  function ( _, state )  
   if getPedWeaponSlot ( localPlayer ) == 6 then  
    if ( state == "down" ) then  
     alpha = 0  
    elseif ( state == "up" ) then  
     alpha = 255  
    end  
    for _, v in ipairs ( getElementsByType ( "object", root, true ) ) do  
     if isElementAttachedToBone ( v ) then  
      local id = getElementModel ( v )  
      if ( id == 1853 ) then  
       setElementAlpha ( v, alpha )  
      end  
     end  
    end  
   end  
  end  
)   

That DayZ code and when I start resource I get that warning:

Bad argument @ 'bindKey' 

What wrong?

Link to comment
  
local alpha = 255 
  
  function bind( _, state ) 
   if getPedWeaponSlot ( localPlayer ) == 6 then 
    if ( state == "down" ) then 
     alpha = 0 
    elseif ( state == "up" ) then 
     alpha = 255 
    end 
    for _, v in ipairs ( getElementsByType ( "object", root, true ) ) do 
     if isElementAttachedToBone ( v ) then 
      local id = getElementModel ( v ) 
      if ( id == 1853 ) then 
       setElementAlpha ( v, alpha ) 
      end 
     end 
    end 
   end 
  end 
  function bindk() 
    if eventName == "onPlayerJoin" then 
        bindKey(source, "aim_weapon", "both", bind) 
    else 
        for i, v in ipairs(getElementsByType("player")) do 
        bindKey(v, "aim_weapon", "both", bind) 
    end 
    end 
  end 
  addEventHandler("onResourceStart", getResourceRootElement(getThisResource()), bindk) 
  addEventHandler("onPlayerJoin", root, bindk) 
  
  
  

Link to comment
  
  
local alpha = 255 
  
  function bind( t, state ) 
   if getPedWeaponSlot ( t ) == 6 then 
    if ( state == "down" ) then 
     alpha = 0 
    elseif ( state == "up" ) then 
     alpha = 255 
    end 
    for _, v in ipairs ( getElementsByType ( "object", root, true ) ) do 
     if isElementAttachedToBone ( v ) then 
      local id = getElementModel ( v ) 
      if ( id == 1853 ) then 
       setElementAlpha ( v, alpha ) 
      end 
     end 
    end 
   end 
  end 
  function bindk() 
    if eventName == "onPlayerJoin" then 
        bindKey(source, "aim_weapon", "both", bind) 
    else 
        for i, v in ipairs(getElementsByType("player")) do 
        bindKey(v, "aim_weapon", "both", bind) 
    end 
    end 
  end 
  addEventHandler("onResourceStart", getResourceRootElement(getThisResource()), bindk) 
  addEventHandler("onPlayerJoin", root, bindk) 
  
  
  
  

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