Ok you just make an array and define it. It can hold as much information as you want for each gun (clips, bullets, amount of damage, weapon upgrades... whatever you want). The very basic is just clips and bullets. The current weapon thats being used can be put into a variable (in the code snip I use "CGun").
The shift key increases CGun until it sees the first gun in the array has more than zero clips or bullets. If it reaches the end it wraps around to the start of the array.
The enter key simulates picking up new guns (very basic... it can pick guns that you already have).
set text opaque
dim Gun(9,1)
` Gun(xx,0) = Clips
` Gun(xx,1) = Number of bullets
` If you want say a knife for the default weapon
` when you run out of ammo for the others as long as
` this doesn't change the knife will always be with
` you.
Gun(0,1)=1
` Handgun
Gun(1,0)=10
Gun(1,1)=25
` Shotgun
Gun(2,0)=5
Gun(2,1)=2
CGun=0
tim=timer()
text 0,100,"Press LEFT-SHIFT to cycle weapons."
text 0,115,"Press ENTER to add a random weapon (it may change weapons that already exist)."
do
` Shift Key
if keystate(42) and timer()>tim+200
` This will increase the current selected gun until
` a gun is found that has either clips or ammo
repeat
inc CGun
` If Cgun reaches the end of the array go to the start
if CGun=10 then CGun=0
until Gun(CGun,1)>0
` Reset the timer so the gun selection isn't too fast
tim=timer()
endif
` Enter (pick a random gun and add bullets)
` This is to show how to add clips/bullets to guns
` when you pick them up in the game
if keystate(28) and timer()>tim+200
CGun=rnd(8)+1
Gun(CGun,0)=rnd(20)
Gun(CGun,1)=rnd(200)
tim=timer()
endif
text 0,0,"Current Gun = "+str$(CGun)
text 0,15,"Clips = "+str$(Gun(CGun,0))+" "
text 0,30,"Ammo = "+str$(Gun(CGun,1))+" "
loop
