How to swap to last weapon?

Guys,in my game,i change weapons by switching between then on integer.That works with the mousewheel and the keyboard,but how can i press the ‘‘Q’’ key to choose my last weapon used?I thought of making a string and then choosing the second to last number on it,but i couldn’t figure out how.Do you guys have any idea how i do this?

252987-swap2.png

i would probably have two variables, weaponEquipped and LastWepEquipped. then when you switch weapons you take the weaponEquipped and set it to lastWepEquipped variable before actually equipping the new weapon and setting it to the weaponEquipped Var