//Made by alphaent

#library "wep_memo"
#include "zcommon.acs"

//To each weapon it corresponds a setweaponmemory and setweaponactual value.

//Each weapon has setweaponmemory set each time you deselect a weapon
//and a different weapon gets a setweaponactual set each time you select a weapon.

//The memory value is detected by this script and it switches to the detected weapon.
//A simple trick that works =P

str WeaponsTextArray[50]={
//		"",			//  00
		"AK47",				//  01
		"AUG",				//  02
		"AWP", 				//  03
		"BIZON", 			//  04
		"C4", 		//  05
		"Breachcharge", 	//  06
		"DEAGLE",			//  07
		"DECOY",	//  08
		"ELITE",			//  09
		"FAMAS",			//  10
		"FIVESEVEN",		//  11
		"FLASHBANG",		//  12
		"G3SG1", 			//  13
		"GALILAR", 			//  14
		"GLOCK", 			//  15
		"HE GRENADE", 		//  16
		"HKP2000",			//  17
		"Incendiary Grenade",		//  18
		"KNIFE",			//  19
		"M4A1",				//  20
		"M249",				//  21
		"MAC10",			//  22
		"MAG7",			 	//  23
		"MP5SD", 		//  24 formerly manifest
		"MOLOTOV", 			//  25
		"MP7", 				//  26
		"MP9",				//  27
		"NEGEV",			//  28
		"NOVA",				//  29
		"P90",				//  30
		"P250",				//  31
		"SAWEDOFF",			//  32
		"SCAR20",	 		//  33
		"SG553", 			//  34
		"SMOKE GRENADE", 	//  35
		"SSG08", 			//  36
		"TASER",			//  37
		"TEC9",				//  38
		"UMP45",			//  39
		"XM1014",			//  40
		"",			//  41
		"",			//  42
		"CZ75A", 			//  43
		"USP", 				//  44
		"M4A1 SILENCED", 	//  45
		"REVOLVER", 		//  46
		"",			//  47
		"",			//  48
		"Healthshot",		//  49
		"MP5SD",			//  50
		};
		

SCRIPT "Weapon_Lastused_Memoryscript" (void) 
{
	int WeaponValue = CheckInventory("SetWeaponMemory");
	
Delay(2); SetWeapon(WeaponsTextArray[WeaponValue-1]);		Delay(1);	Terminate;

}

		

Script "HSPreviousWeapon" (int mode) net clientside
{
	// Valid mode properties:
	// 0: Switch the weapon with the previous slot.
	// 1: Don't change the previous weapon 'slot'.
	// 2: Don't change the current weapon 'slot'.
	// 3: Empty previous weapon slot.
	// 4: Empty current weapon slot.
	// 5: 3 and 4.
	// 6: 1, but use previousweapon.
	// 7: 2, but use previousweapon.
	// By slot, it means recorded weapon.
	str truecurweap;
	str curweap;
	str prevweap;
	switch(mode)
	{
	case 0:
		if (!(GetWeapon()))// && (CheckInventory("Grenade_BlockMemo")==1)) ) 
			Terminate;
		truecurweap = GetWeapon();
//		curweap = GetCvarString("user_currentWeapon");
//		prevweap = GetCvarString("user_previousWeapon");
		SetWeapon(GetCvarString("user_previousWeapon"));
		SetUserCvarString(PlayerNumber(),"user_previousWeapon",GetWeapon());
		delay(5);
		SetUserCvarString(PlayerNumber(),"user_currentWeapon",GetWeapon());
		Terminate;
	case 1:
		if (!(GetWeapon()))
			Terminate;
		SetUserCvarString(PlayerNumber(),"user_currentWeapon",GetWeapon());
		Terminate;
	case 2:
		if (!(GetWeapon()))
			Terminate;
		SetUserCvarString(PlayerNumber(),"user_previousWeapon",GetWeapon());
		Terminate;
	case 3:
		if (!(GetWeapon()))
			Terminate;
		SetUserCvarString(PlayerNumber(),"user_currentWeapon","");
		Terminate;
	case 4:
		if (!(GetWeapon()))
			Terminate;
		SetUserCvarString(PlayerNumber(),"user_previousWeapon","");
		Terminate;
	case 5:
		if (!(GetWeapon()))
			Terminate;
		SetUserCvarString(PlayerNumber(),"user_currentWeapon","");
		SetUserCvarString(PlayerNumber(),"user_previousWeapon","");
		Terminate;
	case 6://original 0 behaviour. moved into 6 to make further experiments on 0
		if (!(GetWeapon()))
			Terminate;
		truecurweap = GetWeapon();
//		curweap = GetCvarString("user_currentWeapon");
//		prevweap = GetCvarString("user_previousWeapon");
		SetWeapon(GetCvarString("user_previousWeapon"));
		SetUserCvarString(PlayerNumber(),"user_previousWeapon",GetCvarString("user_currentWeapon"));
		delay(5);
		SetUserCvarString(PlayerNumber(),"user_currentWeapon",GetCvarString("user_previousWeapon"));
		Terminate;
	case 7:
		if (!(GetWeapon()))
			Terminate;
		SetUserCvarString(PlayerNumber(),"user_previousWeapon",GetWeapon());
		Terminate;
	}
}
