Tycka Posted October 26, 2014 Share 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? Link to comment
Scripting Moderators Sarrum Posted October 26, 2014 Scripting Moderators Share Posted October 26, 2014 Are you using this code on the client side? Link to comment
Tycka Posted October 26, 2014 Author Share Posted October 26, 2014 No, using at server side. Link to comment
Anubhav Posted October 26, 2014 Share 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) Link to comment
Tycka Posted October 27, 2014 Author Share Posted October 27, 2014 Now I get this: Bad argument @ 'getPedWeaponSlot' Link to comment
Moderators Citizen Posted October 27, 2014 Moderators Share 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) Link to comment
Anubhav Posted October 27, 2014 Share 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) Link to comment
Tycka Posted October 27, 2014 Author Share 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 Link to comment
Tycka Posted October 27, 2014 Author Share Posted October 27, 2014 Fixed. Thanks who try help Link to comment
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