Custom Weapon Switcher Skeleton

I wrote a small script that handles weapon switching binds, sounds, and drawing states for custom weapon switchers. Custom drawing code just needs to be placed in the DrawWeaponHUD function and the rest will be handled by the skeleton. Selection information like the current slot and weapons are instance variables to the file that are available to the drawing method. Time comparisons are all done with RealTime.


addons/darkrpmodification-master/lua/darkrp_modules/miscshit/cl_switcher.lua:339: attempt to index a nil value
stack traceback:
	addons/darkrpmodification-master/lua/darkrp_modules/miscshit/cl_switcher.lua:339: in function 'fn'
	addons/ulib/lua/ulib/shared/hook.lua:109: in function <addons/ulib/lua/ulib/shared/hook.lua:92>
	[C]: in function '•‎​‬‪•'

  1. unknown - [C]:-


Any file that has cl_ in darkrp modules gets run clientside.
Doesn’t matter if it’s a darkrp module or not, It’s just neatly organized.

Fixed, thank you

thank you so much for this skeleton, but i have a little problem. How do i make an animation? for example this is what i currently have:
when i scroll the whole thing just pop up i want to add some black bar to each one to show wich one u scrolling at for example: (this last one is only a draw.RoundedBox

Interpolate your drawing. Instead of just drawing the box at the desired position, use the “flSelectTime” variable in the skeleton to progressively reach the desired position. You can use

Lerp with the fraction being math.min(1, (RealTime() - flSelectTime) / ANIMATION_TIME)

Fixed invprev and invnext doing the reverse of their intended effect, the repo has been updated. Thanks YuRaNnNzZZ!

Thanks for this.