Tycka Posted October 26, 2014 Posted October 26, 2014 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?
Scripting Moderators Sarrum Posted October 26, 2014 Scripting Moderators Posted October 26, 2014 Are you using this code on the client side?
Anubhav Posted October 26, 2014 Posted October 26, 2014 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)
Tycka Posted October 27, 2014 Author Posted October 27, 2014 Now I get this: Bad argument @ 'getPedWeaponSlot'
Moderators Citizen Posted October 27, 2014 Moderators Posted October 27, 2014 No, using at server side. Just use it in the client-side and boom it works. (if isElementAttachedToBone is defined on client-side too)
Anubhav Posted October 27, 2014 Posted October 27, 2014 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)
Tycka Posted October 27, 2014 Author Posted October 27, 2014 No, using at server side. Just use it in the client-side and boom it works. (if isElementAttachedToBone is defined on client-side too) When I use it on client side them I dont get any error or warning, but them code didint work
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now