//-------------------------------------------------------------------------------------------
// PlayerGetSet v1.0
// by Don
// 9/24/06
//
// Description:
// This script registers 2 commands, playerget and playerset.
//
// Installation:
// Create a directory called playergetset under cstrike/addons/eventscripts.
// Copy this file(es_playergetset.txt) to this directory.
// Put "es_load playergetset" into your autoexec.cfg.
// Restart your server.
//
// Use: playerget <item>
// playerget primary <var> <userid> [var_index] - Get the players Primary weapon
// playerget secondary <var> <userid> [var_index] - Get the players Secondary weapon
// playerget he <var> <userid> [var_index] - 1/0 if the player has an HE Grenade
// playerget sg <var> <userid> [var_index] - 1/0 if the player has a Smoke Grenade
// playerget fb <var> <userid> - 1/0 if the player has a Flashbang
// playerget c4 <var> <userid> [var_index] - 1/0 if the player has a Bomb
// playerget weaponindex <var> <userid> <weapon_name> - Get the index of the player's weapon
// playerget ammo <var> <userid> <weapon / slot> - Get the amount of ammo in the player's reserve
// playerget clip <var> <userid> <weapon / slot> - Get the amount of ammo in the player's clip
// playerget viewangle <userid> <return pitch> <return yaw> <return roll> - Get the angle the player is looking
// playerget health <var> <userid> - Get the player's health
// playerget armor <var> <userid> - Get the player's armor
// playerget speed <var> <userid> - Get the player's speed
// playerget cash <var> <userid> - Get the player's cash
// playerget defuser <var> <userid> - 1/0 if the player has a defuser
//
// Use: playerset <item>
// playerset ammo <userid> <weapon / slot> <amount> - Set the amount of ammo in the player's reserve
// playerset clip <userid> <weapon / slot> <amount> - Set the amount of ammo in the player's clip
// playerset health <userid> <var> - Set the player's health
// playerset armor <userid> <var> - Set the player's armor
// playerset speed <userid> <var> - Set the player's speed
// playerset cash <userid> <var> - Set the player's cash
// playerset defuser <userid> <var> - Give or take the player's defuser
// playerset nightvision <userid> <var> - Give or take the player's nightvision
// playerset nightvisionon <userid> <var> - Set the player's nightvision on or off
//
// [var_index] is optional - will return the index of the weapon.
//
//-------------------------------------------------------------------------------------------
block load
{
//	es_xdoblock corelib/playergetset/playergetset_register
	es_xdoblock playergetset/playergetset_register
}

block unload
{
	es_xkeygroupdelete _primaryweapons
	es_xkeygroupdelete _secondaryweapons
}

block playergetset_register
{
	es_xsetinfo _playergetset_find 0
	es_xsetinfo _playergetset_owner 0
	es_xsetinfo _playergetset_userid 0
	es_xsetinfo _playergetset_tempid 0
	es_xsetinfo _playergetset_tempvar 0
	es_xsetinfo _playergetset_cmd 0
	es_xsetinfo _playergetset_arg1 0
	es_xsetinfo _playergetset_arg2 0
	es_xsetinfo _playergetset_arg3 0
	es_xsetinfo _playergetset_arg4 0
	es_xsetinfo _playergetset_temparg1 0
	es_xsetinfo _playergetset_temparg2 0
	es_xsetinfo _playergetset_temparg3 0
	es_xsetinfo _playergetset_hasparam 0
//	es_xdoblock corelib/playergetset/createprimary
//	es_xdoblock corelib/playergetset/createsecondary
	es_xdoblock playergetset/createprimary
	es_xdoblock playergetset/createsecondary
//	es_xregcmd playerget corelib/playergetset/_playerget "Get various user items"
//	es_xregcmd playerset corelib/playergetset/_playerset "Set various user items"
	es_xregcmd playerget playergetset/_playerget "Get various user items"
	es_xregcmd playerset playergetset/_playerset "Set various user items"
}

block _playerget
{
	es_xgetargc _playergetset_arg1
	if (server_var(_playergetset_arg1) > 1) do
	{
		es_xgetargv _playergetset_cmd 1
		if (server_var(_playergetset_cmd) == viewangle) do
		{
			es_xgetargv _playergetset_userid 2
		}
		else do
		{
			es_xgetargv _playergetset_userid 3
		}
		es es_xgetuserid _playergetset_userid server_var(_playergetset_userid)
		if (server_var(_playergetset_userid) = 0) do
		{
			es_dbgmsg 0 Player not found!
		}
		else do
		{
			es_xsetinfo _playergetset_block 0
//			es es_xformat _playergetset_block "corelib/playergetset/get%1" server_var(_playergetset_cmd)
			es es_xformat _playergetset_block "playergetset/get%1" server_var(_playergetset_cmd)
			es es_xdoblock server_var(_playergetset_block)
		}
	}
	else do
	{
		es_dbgmsg 0 Type playerget primary|secondary|he|sg|fb|c4|ammo|clip|weaponindex|viewangle|health|armor|speed|defuser
	}
}

block _playerset
{
	es_xgetargc _playergetset_arg1
	if (server_var(_playergetset_arg1) > 1) do
	{
		es_xgetargv _playergetset_userid 2
		es es_xgetuserid _playergetset_userid server_var(_playergetset_userid)
		if (server_var(_playergetset_userid) = 0) do
		{
			es_dbgmsg 0 Player not found!
		}
		else do
		{
			es_xgetargv _playergetset_cmd 1
			es_xsetinfo _playergetset_block 0
//			es es_xformat _playergetset_block "corelib/playergetset/set%1" server_var(_playergetset_cmd)
			es es_xformat _playergetset_block "playergetset/set%1" server_var(_playergetset_cmd)
			es es_xdoblock server_var(_playergetset_block)
		}
	}
	else do
	{
		es_dbgmsg 0 Type playerset ammo|clip|health|armor|speed|cash|defuser|nightvision|nightvisionon
	}
}

block getweaponindex
{
	es_xgetargc _playergetset_arg1
	if (server_var(_playergetset_arg1) > 3) do
	{
		es_xgetargv _playergetset_arg2 2
		es_xgetargv _playergetset_arg3 4
		if (weapon_ notin server_var(_playergetset_arg3)) do
		{
			es_format _playergetset_arg3 "weapon_%1" server_var(_playergetset_arg3)
		}
		es es_xsetinfo server_var(_playergetset_arg2) 0
		es_xsetinfo _playergetset_find 0
		es es_xgetplayerhandle _playergetset_owner server_var(_playergetset_userid)
		es es_xcreateentitylist _playergetset_weapons server_var(_playergetset_arg3)
		es es_xkeygroupfilter _playergetset_weapons only m_Howner server_var(_playergetset_owner)
//		es_xforeachkey _playergetset_tempid in _playergetset_weapons "es_xdoblock corelib/playergetset/getindex"
		es_xforeachkey _playergetset_tempid in _playergetset_weapons "es_xdoblock playergetset/getindex"
		es_xkeygroupdelete _playergetset_weapons
	}
	else do
	{
		es_dbgmsg 0 Syntax : playerget weaponindex <var> <userid> <weapon_name>
	}
}

block getprimary
{
	es_xgetargc _playergetset_arg1
	if (server_var(_playergetset_arg1) > 3) do
	{
		es_xgetargv _playergetset_arg2 2
		es_xgetargv _playergetset_arg3 4
		es es_xsetinfo server_var(_playergetset_arg2) 0
		es es_xsetinfo server_var(_playergetset_arg3) 0
		es_xsetinfo _playergetset_find 0
		es es_xgetplayerhandle _playergetset_owner server_var(_playergetset_userid)
//		es_xforeachkey wep in _primaryweapons "es_xdoblock corelib/playergetset/checkall"
		es_xforeachkey wep in _primaryweapons "es_xdoblock playergetset/checkall"
	}
	else do
	{
		es_dbgmsg 0 Syntax : playerget primary <var> <userid> [var_index]
	}
}

block getsecondary
{
	es_getargc _playergetset_arg1
	if (server_var(_playergetset_arg1) > 3) do
	{
		es_xgetargv _playergetset_arg2 2
		es_xgetargv _playergetset_arg3 4
		es es_xsetinfo server_var(_playergetset_arg2) 0
		es es_xsetinfo server_var(_playergetset_arg3) 0
		es_xsetinfo _playergetset_find 0
		es es_xgetplayerhandle _playergetset_owner server_var(_playergetset_userid)
//		es_xforeachkey wep in _secondaryweapons "es_xdoblock corelib/playergetset/checkall"
		es_xforeachkey wep in _secondaryweapons "es_xdoblock playergetset/checkall"
	}
	else do
	{
		es_dbgmsg 0 Syntax : playerget secondary <var> <userid> [var_index]
	}
}

block gethe
{
	es_xgetargc _playergetset_arg1
	if (server_var(_playergetset_arg1) > 3) do
	{
		es_xgetargv _playergetset_arg2 2
		es_xgetargv _playergetset_arg3 4
		es_setinfo server_var(_playergetset_arg2) 0
		es_setinfo server_var(_playergetset_arg3) 0
		es_xsetinfo _playergetset_find 0
		es es_xgetplayerprop server_var(_playergetset_arg2) server_var(_playergetset_userid) "CBasePlayer.localdata.m_iAmmo.011"
		es es_xgetplayerhandle _playergetset_owner server_var(_playergetset_userid)
		es_xcreateentitylist _playergetset_weapons weapon_hegrenade
		es es_xkeygroupfilter _playergetset_weapons only m_Howner server_var(_playergetset_owner)
//		es_xforeachkey _playergetset_tempid in _playergetset_weapons "es_xdoblock corelib/playergetset/weapon_list"
		es_xforeachkey _playergetset_tempid in _playergetset_weapons "es_xdoblock playergetset/weapon_list"
		es_xkeygroupdelete _playergetset_weapons
		if (server_var(_playergetset_find) == weapon_hegrenade) do
		{
			es es_xsetinfo server_var(_playergetset_arg2) 1
			es es_xsetinfo server_var(_playergetset_arg3) server_var(_playergetset_tempid)
		}
	}
	else do
	{
		es_dbgmsg 0 Syntax : playerget he <var> <userid> [var_index]
	}
}

block getfb
{
	es_xgetargc _playergetset_arg1
	if (server_var(_playergetset_arg1) > 3) do
	{
		es_xgetargv _playergetset_arg2 2
		es_xgetargv _playergetset_arg3 4
		es es_xsetinfo server_var(_playergetset_arg2) 0
		es es_xsetinfo server_var(_playergetset_arg3) 0
		es_xsetinfo _playergetset_find 0
		es es_xgetplayerprop server_var(_playergetset_arg2) server_var(_playergetset_userid) "CBasePlayer.localdata.m_iAmmo.012"
	}
	else do
	{
		es_dbgmsg 0 Syntax : playerget fb <var> <userid>
	}
}

block getsg
{
	es_xgetargc _playergetset_arg1
	if (server_var(_playergetset_arg1) > 3) do
	{
		es_xgetargv _playergetset_arg2 2
		es_xgetargv _playergetset_arg3 4
		es es_xsetinfo server_var(_playergetset_arg2) 0
		es es_xsetinfo server_var(_playergetset_arg3) 0
		es_xsetinfo _playergetset_find 0
		es es_xgetplayerprop server_var(_playergetset_arg2) server_var(_playergetset_userid) "CBasePlayer.localdata.m_iAmmo.013"
		es_xcreateentitylist _playergetset_weapons weapon_smokegrenade
		es es_xkeygroupfilter _playergetset_weapons only m_Howner server_var(_playergetset_owner)
//		es_xforeachkey _playergetset_tempid in _playergetset_weapons "es_xdoblock corelib/playergetset/weapon_list"
		es_xforeachkey _playergetset_tempid in _playergetset_weapons "es_xdoblock playergetset/weapon_list"
		es_xkeygroupdelete _playergetset_weapons
		if (server_var(_playergetset_find) == weapon_smokegrenade) do
		{
			es es_xsetinfo server_var(_playergetset_arg2) 1
			es es_xsetinfo server_var(_playergetset_arg3) server_var(_playergetset_tempid)
		}
	}
	else do
	{
		es_dbgmsg 0 Syntax : playerget sg <var> <userid> [var_index]
	}
}

block getc4
{
	es_xgetargc _playergetset_arg1
	if (server_var(_playergetset_arg1) > 3) do
	{
		es_xgetargv _playergetset_arg2 2
		es_xgetargv _playergetset_arg3 4
		es es_xsetinfo server_var(_playergetset_arg2) 0
		es es_xsetinfo server_var(_playergetset_arg3) 0
		es_xsetinfo _playergetset_find 0
		es es_xgetplayerhandle _playergetset_owner server_var(_playergetset_userid)
		es_xcreateentitylist _playergetset_weapons weapon_c4
		es es_xkeygroupfilter _playergetset_weapons only m_Howner server_var(_playergetset_owner)
//		es_xforeachkey _playergetset_tempid in _playergetset_weapons "es_xdoblock corelib/playergetset/weapon_list"
		es_xforeachkey _playergetset_tempid in _playergetset_weapons "es_xdoblock playergetset/weapon_list"
		es_xkeygroupdelete _playergetset_weapons
		if (server_var(_playergetset_find) == weapon_c4) do
		{
			es es_xsetinfo server_var(_playergetset_arg2) 1
			es es_xsetinfo server_var(_playergetset_arg3) server_var(_playergetset_tempid)
		}
	}
	else do
	{
		es_dbgmsg 0 Syntax : playerget c4 <var> <userid> [var_index]
	}
}

block getammo
{
	es_xgetargc _playergetset_temparg1
	if (server_var(_playergetset_temparg1) > 3) do
	{
		es_xgetargv _playergetset_temparg2 2
		es_xgetargv _playergetset_temparg3 4
		es es_xsetinfo server_var(_playergetset_temparg2) 0
		if (server_var(_playergetset_temparg3) != 1) do
		{
			if (server_var(_playergetset_temparg3) != 2) do
			{
				if (weapon_ notin server_var(_playergetset_temparg3)) do
				{
					es_format _playergetset_temparg3 "weapon_%1" server_var(_playergetset_temparg3)
				}
				es_xsetinfo _weapon_slot 1
//				es es_xforeachkey _playergetset_tempid in _primaryweapons "es_xdoblock corelib/playergetset/findslot"
				es es_xforeachkey _playergetset_tempid in _primaryweapons "es_xdoblock playergetset/findslot"
				es_xsetinfo _weapon_slot 2
//				es es_xforeachkey _playergetset_tempid in _secondaryweapons "es_xdoblock corelib/playergetset/findslot"
				es es_xforeachkey _playergetset_tempid in _secondaryweapons "es_xdoblock playergetset/findslot"
			}
		}
		if (server_var(_playergetset_temparg3) == 1) do
		{
			es playerget primary _playergetset_temparg3 server_var(_playergetset_userid)
			if (server_var(_playergetset_temparg3) != 0) do
			{
				es es_xkeygetvalue _playergetset_tempvar _primaryweapons server_var(_playergetset_temparg3) ammo 
				es getplayerinfo _playergetset_tempid server_var(_playergetset_userid) index
				es es_xgetindexprop server_var(_playergetset_temparg2) server_var(_playergetset_tempid) server_var(_playergetset_tempvar)
			}
		}
		if (server_var(_playergetset_temparg3) == 2) do
		{
			if (server_var(_playergetset_temparg3) != 0) do
			{
				es playerget secondary _playergetset_temparg3 server_var(_playergetset_userid)
				es es_xkeygetvalue _playergetset_tempvar _secondaryweapons server_var(_playergetset_temparg3) ammo 
				es getplayerinfo _playergetset_tempid server_var(_playergetset_userid) index
				es es_xgetindexprop server_var(_playergetset_temparg2) server_var(_playergetset_tempid) server_var(_playergetset_tempvar)
			}
		}
	}
	else do
	{
		es_dbgmsg 0 Syntax : playerget ammo <var> <userid> <weapon / slot>
	}
}

block getclip
{
	es_xgetargc _playergetset_temparg1
	if (server_var(_playergetset_temparg1) > 3) do
	{
		es_xsetinfo _playergetset_temparg3 0
		es_xgetargv _playergetset_temparg2 2
		es_xgetargv _playergetset_temparg3 4
		es es_xsetinfo server_var(_playergetset_temparg2) 0
		if (server_var(_playergetset_temparg3) != 1) do
		{
			if (server_var(_playergetset_temparg3) != 2) do
			{
				if (weapon_ notin server_var(_playergetset_temparg3)) do
				{
					es_format _playergetset_temparg3 "weapon_%1" server_var(_playergetset_temparg3)
				}
				es_xsetinfo _weapon_slot 1
//				es es_xforeachkey _playergetset_tempid in _primaryweapons "es_xdoblock corelib/playergetset/findslot"
				es es_xforeachkey _playergetset_tempid in _primaryweapons "es_xdoblock playergetset/findslot"
				es_xsetinfo _weapon_slot 2
//				es es_xforeachkey _playergetset_tempid in _secondaryweapons "es_xdoblock corelib/playergetset/findslot"
				es es_xforeachkey _playergetset_tempid in _secondaryweapons "es_xdoblock playergetset/findslot"
			}
		}
		if (server_var(_playergetset_temparg3) == 1) do
		{
			es playerget primary _playergetset_temparg3 server_var(_playergetset_userid) server_var(_playergetset_tempid)
			if (server_var(_playergetset_temparg3) != 0) do
			{
				es es_xkeygetvalue _playergetset_tempvar _primaryweapons server_var(_playergetset_temparg3) clip
				es es_xgetindexprop server_var(_playergetset_temparg2) server_var(_playergetset_tempid) server_var(_playergetset_tempvar)
			}
		}
		if (server_var(_playergetset_temparg3) == 2) do
		{
			es playerget secondary _playergetset_temparg3 server_var(_playergetset_userid) server_var(_playergetset_tempid)
			if (server_var(_playergetset_temparg3) != 0) do
			{
				es es_xkeygetvalue _playergetset_tempvar _secondaryweapons server_var(_playergetset_temparg3) clip
				es es_xgetindexprop server_var(_playergetset_temparg2) server_var(_playergetset_tempid) server_var(_playergetset_tempvar)
			}
		}
	}
	else do
	{
		es_dbgmsg 0 Syntax : playerget clip <var> <userid> <weapon / slot>
	}
}

block getcash
{
	es_xgetargc _playergetset_arg1
	if (server_var(_playergetset_arg1) > 2) do
	{
		es_xgetargv _playergetset_arg2 2
		es es_xsetinfo server_var(_playergetset_arg2) 0
		es_getplayerprop server_var(_playergetset_arg2) server_var(_playergetset_userid) CCSPlayer.m_iAccount
	}
	else do
	{
		es_dbgmsg 0 Syntax : playerget cash <var>  <userid>
	}
}

block getdefuser
{
	es_xgetargc _playergetset_arg1
	if (server_var(_playergetset_arg1) > 2) do
	{
		es_xgetargv _playergetset_arg2 2
		es es_xsetinfo server_var(_playergetset_arg2) 0
		es_getplayerprop server_var(_playergetset_arg2) server_var(_playergetset_userid) CCSPlayer.m_bHasDefuser
	}
	else do
	{
		es_dbgmsg 0 Syntax : playerget defuser <var>  <userid>
	}
}

block getspeed
{
	es_xgetargc _playergetset_arg1
	if (server_var(_playergetset_arg1) > 2) do
	{
		es_xgetargv _playergetset_arg2 2
		es es_xsetinfo server_var(_playergetset_arg2) 0
		es_getplayerprop server_var(_playergetset_arg2) server_var(_playergetset_userid) CCSPlayer.baseclass.localdata.m_flLaggedMovementValue
	}
	else do
	{
		es_dbgmsg 0 Syntax : playerget speed <var>  <userid>
	}
}

block getarmor
{
	es_xgetargc _playergetset_arg1
	if (server_var(_playergetset_arg1) > 2) do
	{
		es_xgetargv _playergetset_arg2 2
		es es_xsetinfo server_var(_playergetset_arg2) 0
		es_getplayerprop server_var(_playergetset_arg2) server_var(_playergetset_userid) CCSPlayer.m_ArmorValue
	}
	else do
	{
		es_dbgmsg 0 Syntax : playerget armor <var>  <userid>
	}
}

block gethealth
{
	es_xgetargc _playergetset_arg1
	if (server_var(_playergetset_arg1) > 2) do
	{
		es_xgetargv _playergetset_arg2 2
		es es_xsetinfo server_var(_playergetset_arg2) 0
		es_getplayerprop server_var(_playergetset_arg2) server_var(_playergetset_userid) CCSPlayer.baseclass.m_iHealth
	}
	else do
	{
		es_dbgmsg 0 Syntax : playerget health <var>  <userid>
	}
}

block getviewangle
{
	es_xgetargc _playergetset_arg1
	if (server_var(_playergetset_arg1) > 4) do
	{
		es_xgetargv _playergetset_arg2 3
		es_xgetargv _playergetset_arg3 4
		es_xgetargv _playergetset_arg4 5
		es es_xsetinfo server_var(_playergetset_arg2) 0
		es es_xsetinfo server_var(_playergetset_arg3) 0
		es es_xsetinfo server_var(_playergetset_arg4) 0
		es_getplayerprop _playergetset_arg1 server_var(_playergetset_userid) CCSPlayer.baseclass.baseclass.baseclass.baseclass.baseclass.baseclass.m_angRotation
		es es_xsplitvectorstring server_var(_playergetset_arg2) server_var(_playergetset_arg3) server_var(_playergetset_arg4) server_var(_playergetset_arg1)
		es es_xgetplayerprop server_var(_playergetset_arg2) server_var(_playergetset_userid) CCSPlayer.m_angEyeAngles[0]
		es es_xgetplayerprop server_var(_playergetset_arg3) server_var(_playergetset_userid) CCSPlayer.m_angEyeAngles[1]
		if (server_var(server_var(_playergetset_arg3)) < 0) then es_xmath server_var(_playergetset_arg3) + 360
	}
	else do
	{
		es_dbgmsg 0 Syntax : playerget viewangle  <userid> <return pitch> <return yaw> <return roll>
	}

}

block setnightvisionon
{
	es_xgetargc _playergetset_arg1
	if (server_var(_playergetset_arg1) > 2) do
	{
		es_xgetargv _playergetset_arg2 3
		if (server_var(_playergetset_arg2) >= 0) do
		{
			if (server_var(_playergetset_arg2) <= 1) do
			{
				es_setplayerprop server_var(_playergetset_userid) CCSPlayer.m_bNightVisionOn server_var(_playergetset_arg2)
			}
		}
	}
	else do
	{
		es_dbgmsg 0 Syntax : playerset nightvisionon <userid> 1/0
	}
}

block setnightvision
{
	es_xgetargc _playergetset_arg1
	if (server_var(_playergetset_arg1) > 2) do
	{
		es_xgetargv _playergetset_arg2 3
		if (server_var(_playergetset_arg2) >= 0) do
		{
			if (server_var(_playergetset_arg2) <= 1) do
			{
				es_setplayerprop server_var(_playergetset_userid) CCSPlayer.m_bHasNightVision server_var(_playergetset_arg2)
			}
		}
	}
	else do
	{
		es_dbgmsg 0 Syntax : playerset nightvision <userid> 1/0
	}
}

block setdefuser
{
	es_xgetargc _playergetset_arg1
	if (server_var(_playergetset_arg1) > 2) do
	{
		es_xgetargv _playergetset_arg2 3
		if (server_var(_playergetset_arg2) >= 0) do
		{
			if (server_var(_playergetset_arg2) <= 1) do
			{
				es_setplayerprop server_var(_playergetset_userid) CCSPlayer.m_bHasDefuser server_var(_playergetset_arg2)
			}
		}
	}
	else do
	{
		es_dbgmsg 0 Syntax : playerset defuser <userid> 1/0
	}
}

block setcash
{
	es_xgetargc _playergetset_arg1
	if (server_var(_playergetset_arg1) > 2) do
	{
		es_xgetargv _playergetset_arg2 3
		if (server_var(_playergetset_arg2) >= 0) do
		{
			if (server_var(_playergetset_arg2) < 16001) do
			{
				es_setplayerprop server_var(_playergetset_userid) CCSPlayer.m_iAccount server_var(_playergetset_arg2)
			}
		}
	}
	else do
	{
		es_dbgmsg 0 Syntax : playerset cash <userid> <var>
	}
}

block setspeed
{
	es_xgetargc _playergetset_arg1
	if (server_var(_playergetset_arg1) > 2) do
	{
		es_xgetargv _playergetset_arg2 3
		if (server_var(_playergetset_arg2) >= 0) do
		{
			es_setplayerprop server_var(_playergetset_userid) CCSPlayer.baseclass.localdata.m_flLaggedMovementValue server_var(_playergetset_arg2)
		}
	}
	else do
	{
		es_dbgmsg 0 Syntax : playerset speed <userid> <var>
	}
}

block setarmor
{
	es_xgetargc _playergetset_arg1
	if (server_var(_playergetset_arg1) > 2) do
	{
		es_xgetargv _playergetset_arg2 3
		if (server_var(_playergetset_arg2) >= 0) do
		{
			es_setplayerprop server_var(_playergetset_userid) CCSPlayer.m_ArmorValue server_var(_playergetset_arg2)
		}
	}
	else do
	{
		es_dbgmsg 0 Syntax : playerset armor <userid> <var>
	}
}

block sethealth
{
	es_xgetargc _playergetset_arg1
	if (server_var(_playergetset_arg1) > 2) do
	{
		es_xgetargv _playergetset_arg2 3
		if (server_var(_playergetset_arg2) >= 0) do
		{
			es_setplayerprop server_var(_playergetset_userid) CCSPlayer.baseclass.m_iHealth server_var(_playergetset_arg2)
		}
	}
	else do
	{
		es_dbgmsg 0 Syntax : playerset health <userid> <var>
	}
}

block setclip
{
	es_xgetargc _playergetset_temparg1
	if (server_var(_playergetset_temparg1) > 3) do
	{
		es_xgetargv _playergetset_temparg2 4
		es_xgetargv _playergetset_temparg3 3
		if (server_var(_playergetset_temparg3) != 1) do
		{
			if (server_var(_playergetset_temparg3) != 2) do
			{
				if (weapon_ notin server_var(_playergetset_temparg3)) do
				{
					es_format _playergetset_temparg3 "weapon_%1" server_var(_playergetset_temparg3)
				}
				es_xsetinfo _weapon_slot 1
//				es es_xforeachkey _playergetset_tempid in _primaryweapons "es_xdoblock corelib/playergetset/findslot"
				es es_xforeachkey _playergetset_tempid in _primaryweapons "es_xdoblock playergetset/findslot"
				es_xsetinfo _weapon_slot 2
//				es es_xforeachkey _playergetset_tempid in _secondaryweapons "es_xdoblock corelib/playergetset/findslot"
				es es_xforeachkey _playergetset_tempid in _secondaryweapons "es_xdoblock playergetset/findslot"
			}
		}
		if (server_var(_playergetset_temparg3) == 1) do
		{
			es playerget primary _playergetset_temparg3 server_var(_playergetset_userid) server_var(_playergetset_tempid)
			es es_xkeygetvalue _playergetset_tempvar _primaryweapons server_var(_playergetset_temparg3) clip
			es es_xsetindexprop server_var(_playergetset_tempid) server_var(_playergetset_tempvar) server_var(_playergetset_temparg2)
		}
		if (server_var(_playergetset_temparg3) == 2) do
		{
			es playerget secondary _playergetset_temparg3 server_var(_playergetset_userid) server_var(_playergetset_tempid)
			es es_xkeygetvalue _playergetset_tempvar _secondaryweapons server_var(_playergetset_temparg3) clip
			es es_xsetindexprop server_var(_playergetset_tempid) server_var(_playergetset_tempvar) server_var(_playergetset_temparg2)
		}
	}
	else do
	{
		es_dbgmsg 0 Syntax : playerset clip <userid> <weapon / slot> <amount>
	}
}

block setammo
{
	es_xgetargc _playergetset_temparg1
	if (server_var(_playergetset_temparg1) > 3) do
	{
		es_xgetargv _playergetset_temparg2 4
		es_xgetargv _playergetset_temparg3 3
		if (server_var(_playergetset_temparg3) != 1) do
		{
			if (server_var(_playergetset_temparg3) != 2) do
			{
				if (weapon_ notin server_var(_playergetset_temparg3)) do
				{
					es_format _playergetset_temparg3 "weapon_%1" server_var(_playergetset_temparg3)
				}
				es_xsetinfo _weapon_slot 1
//				es es_xforeachkey _playergetset_tempid in _primaryweapons "es_xdoblock corelib/playergetset/findslot"
				es es_xforeachkey _playergetset_tempid in _primaryweapons "es_xdoblock playergetset/findslot"
				es_xsetinfo _weapon_slot 2
//				es es_xforeachkey _playergetset_tempid in _secondaryweapons "es_xdoblock corelib/playergetset/findslot"
				es es_xforeachkey _playergetset_tempid in _secondaryweapons "es_xdoblock playergetset/findslot"
			}
		}
		if (server_var(_playergetset_temparg3) == 1) do
		{
			es playerget primary _playergetset_temparg3 server_var(_playergetset_userid)
			es es_xkeygetvalue _playergetset_tempvar _primaryweapons server_var(_playergetset_temparg3) ammo 
			es getplayerinfo _playergetset_tempid server_var(_playergetset_userid) index
			es es_xsetindexprop server_var(_playergetset_tempid) server_var(_playergetset_tempvar) server_var(_playergetset_temparg2)
		}
		if (server_var(_playergetset_temparg3) == 2) do
		{
			es playerget secondary _playergetset_temparg3 server_var(_playergetset_userid)
			es es_xkeygetvalue _playergetset_tempvar _secondaryweapons server_var(_playergetset_temparg3) ammo 
			es getplayerinfo _playergetset_tempid server_var(_playergetset_userid) index
			es es_xsetindexprop server_var(_playergetset_tempid) server_var(_playergetset_tempvar) server_var(_playergetset_temparg2)
		}
	}
	else do
	{
		es_dbgmsg 0 Syntax : playerset ammo <userid> <weapon / slot> <amount>
	}
}

block findslot
{
	if (server_var(_playergetset_tempid) == server_var(_playergetset_temparg3)) do
	{
		es es_xsetinfo _playergetset_temparg3 server_var(_weapon_slot)
	}
}

block checkall
{
	es es_xcreateentitylist _playergetset_weapons server_var(wep)
	es es_xkeygroupfilter _playergetset_weapons only m_Howner server_var(_playergetset_owner)
	es_xsetinfo _playergetset_find 0
//	es_xforeachkey _playergetset_tempid in _playergetset_weapons "es_xdoblock corelib/playergetset/weapon_list"
	es_xforeachkey _playergetset_tempid in _playergetset_weapons "es_xdoblock playergetset/weapon_list"
	es_xkeygroupdelete _playergetset_weapons
}

block weapon_list
{
	es es_xkeygetvalue _playergetset_find _playergetset_weapons server_var(_playergetset_tempid) Classname
	if (weapon_ in server_var(_playergetset_find)) do
	{
		es es_xsetinfo server_var(_playergetset_arg2) server_var(_playergetset_find)
		es es_xsetinfo server_var(_playergetset_arg3) server_var(_playergetset_tempid)
	}
}

block getindex
{
	es es_xkeygetvalue _playergetset_find _playergetset_weapons server_var(_playergetset_tempid) Classname
	if (weapon_ in server_var(_playergetset_find)) do
	{
		es es_xsetinfo server_var(_playergetset_arg2) server_var(_playergetset_tempid)
	}
}

block createprimary
{
	es_xkeygroupcreate _primaryweapons
	es_xkeycreate _primaryweapons weapon_awp
	es_xkeysetvalue _primaryweapons weapon_awp ammo "CCSPlayer.baseclass.localdata.m_iAmmo.005"
	es_xkeysetvalue _primaryweapons weapon_awp clip "CWeaponAWP.baseclass.baseclass.baseclass.LocalWeaponData.m_iClip1"
	es_xkeycreate _primaryweapons weapon_scout
	es_xkeysetvalue _primaryweapons weapon_scout ammo "CCSPlayer.baseclass.localdata.m_iAmmo.002"
	es_xkeysetvalue _primaryweapons weapon_scout clip "CWeaponScout.baseclass.baseclass.baseclass.LocalWeaponData.m_iClip1"
	es_xkeycreate _primaryweapons weapon_aug
	es_xkeysetvalue _primaryweapons weapon_aug ammo "CCSPlayer.baseclass.localdata.m_iAmmo.002"
	es_xkeysetvalue _primaryweapons weapon_aug clip "CWeaponAug.baseclass.baseclass.baseclass.LocalWeaponData.m_iClip1"
	es_xkeycreate _primaryweapons weapon_mac10
	es_xkeysetvalue _primaryweapons weapon_mac10 ammo "CCSPlayer.baseclass.localdata.m_iAmmo.008"
	es_xkeysetvalue _primaryweapons weapon_mac10 clip "CWeaponMAC10.baseclass.baseclass.baseclass.LocalWeaponData.m_iClip1"
	es_xkeycreate _primaryweapons weapon_tmp
	es_xkeysetvalue _primaryweapons weapon_tmp ammo "CCSPlayer.baseclass.localdata.m_iAmmo.006"
	es_xkeysetvalue _primaryweapons weapon_tmp clip "CWeaponTMP.baseclass.baseclass.baseclass.LocalWeaponData.m_iClip1"
	es_xkeycreate _primaryweapons weapon_mp5navy
	es_xkeysetvalue _primaryweapons weapon_mp5navy ammo "CCSPlayer.baseclass.localdata.m_iAmmo.006"
	es_xkeysetvalue _primaryweapons weapon_mp5navy clip "CWeaponMP5Navy.baseclass.baseclass.baseclass.LocalWeaponData.m_iClip1"
	es_xkeycreate _primaryweapons weapon_ump45
	es_xkeysetvalue _primaryweapons weapon_ump45 ammo "CCSPlayer.baseclass.localdata.m_iAmmo.008"
	es_xkeysetvalue _primaryweapons weapon_ump45 clip "CWeaponUMP45.baseclass.baseclass.baseclass.LocalWeaponData.m_iClip1"
	es_xkeycreate _primaryweapons weapon_p90
	es_xkeysetvalue _primaryweapons weapon_p90 ammo "CCSPlayer.baseclass.localdata.m_iAmmo.010"
	es_xkeysetvalue _primaryweapons weapon_p90 clip "CWeaponP90.baseclass.baseclass.baseclass.LocalWeaponData.m_iClip1"
	es_xkeycreate _primaryweapons weapon_galil
	es_xkeysetvalue _primaryweapons weapon_galil ammo "CCSPlayer.baseclass.localdata.m_iAmmo.003"
	es_xkeysetvalue _primaryweapons weapon_galil clip "CWeaponGalil.baseclass.baseclass.baseclass.LocalWeaponData.m_iClip1"
	es_xkeycreate _primaryweapons weapon_famas
	es_xkeysetvalue _primaryweapons weapon_famas ammo "CCSPlayer.baseclass.localdata.m_iAmmo.003"
	es_xkeysetvalue _primaryweapons weapon_famas clip "CWeaponFamas.baseclass.baseclass.LocalWeaponData.m_iClip1"
	es_xkeycreate _primaryweapons weapon_ak47
	es_xkeysetvalue _primaryweapons weapon_ak47 ammo "CCSPlayer.baseclass.localdata.m_iAmmo.002"
	es_xkeysetvalue _primaryweapons weapon_ak47 clip "CAK47.baseclass.baseclass.baseclass.LocalWeaponData.m_iClip1"
	es_xkeycreate _primaryweapons weapon_sg552
	es_xkeysetvalue _primaryweapons weapon_sg552 ammo "CCSPlayer.baseclass.localdata.m_iAmmo.003"
	es_xkeysetvalue _primaryweapons weapon_sg552 clip "CWeaponSG552.baseclass.baseclass.baseclass.LocalWeaponData.m_iClip1"
	es_xkeycreate _primaryweapons weapon_sg550
	es_xkeysetvalue _primaryweapons weapon_sg550 ammo "CCSPlayer.baseclass.localdata.m_iAmmo.003"
	es_xkeysetvalue _primaryweapons weapon_sg550 clip "CWeaponSG550.baseclass.baseclass.baseclass.LocalWeaponData.m_iClip1"
	es_xkeycreate _primaryweapons weapon_g3sg1
	es_xkeysetvalue _primaryweapons weapon_g3sg1 ammo "CCSPlayer.baseclass.localdata.m_iAmmo.002"
	es_xkeysetvalue _primaryweapons weapon_g3sg1 clip "CWeaponG3SG1.baseclass.baseclass.baseclass.LocalWeaponData.m_iClip1"
	es_xkeycreate _primaryweapons weapon_m249
	es_xkeysetvalue _primaryweapons weapon_m249 ammo "CCSPlayer.baseclass.localdata.m_iAmmo.004"
	es_xkeysetvalue _primaryweapons weapon_m249 clip "CWeaponM249.baseclass.baseclass.baseclass.LocalWeaponData.m_iClip1"
	es_xkeycreate _primaryweapons weapon_m4a1
	es_xkeysetvalue _primaryweapons weapon_m4a1 ammo "CCSPlayer.baseclass.localdata.m_iAmmo.003"
	es_xkeysetvalue _primaryweapons weapon_m4a1 clip "CWeaponM4A1.baseclass.baseclass.baseclass.LocalWeaponData.m_iClip1"
	es_xkeycreate _primaryweapons weapon_m3
	es_xkeysetvalue _primaryweapons weapon_m3 ammo "CCSPlayer.baseclass.localdata.m_iAmmo.007"
	es_xkeysetvalue _primaryweapons weapon_m3 clip "CWeaponM3.baseclass.baseclass.LocalWeaponData.m_iClip1"
	es_xkeycreate _primaryweapons weapon_xm1014
	es_xkeysetvalue _primaryweapons weapon_xm1014 ammo "CCSPlayer.baseclass.localdata.m_iAmmo.007"
	es_xkeysetvalue _primaryweapons weapon_xm1014 clip "CWeaponXM1014.baseclass.baseclass.LocalWeaponData.m_iClip1"
}

block createsecondary
{
	es_xkeygroupcreate _secondaryweapons
	es_xkeycreate _secondaryweapons weapon_glock
	es_xkeysetvalue _secondaryweapons weapon_glock ammo "CCSPlayer.baseclass.localdata.m_iAmmo.006"
	es_xkeysetvalue _secondaryweapons weapon_glock clip "CWeaponGlock.baseclass.baseclass.LocalWeaponData.m_iClip1"
	es_xkeycreate _secondaryweapons weapon_usp
	es_xkeysetvalue _secondaryweapons weapon_usp ammo "CCSPlayer.baseclass.localdata.m_iAmmo.008"
	es_xkeysetvalue _secondaryweapons weapon_usp clip "CWeaponUSP.baseclass.baseclass.LocalWeaponData.m_iClip1"
	es_xkeycreate _secondaryweapons weapon_p228
	es_xkeysetvalue _secondaryweapons weapon_p228 ammo "CCSPlayer.baseclass.localdata.m_iAmmo.009"
	es_xkeysetvalue _secondaryweapons weapon_p228 clip "CWeaponP228.baseclass.baseclass.LocalWeaponData.m_iClip1"
	es_xkeycreate _secondaryweapons weapon_deagle
	es_xkeysetvalue _secondaryweapons weapon_deagle ammo "CCSPlayer.baseclass.localdata.m_iAmmo.001"
	es_xkeysetvalue _secondaryweapons weapon_deagle clip "CDEagle.baseclass.baseclass.LocalWeaponData.m_iClip1"
	es_xkeycreate _secondaryweapons weapon_elite
	es_xkeysetvalue _secondaryweapons weapon_elite ammo "CCSPlayer.baseclass.localdata.m_iAmmo.006"
	es_xkeysetvalue _secondaryweapons weapon_elite clip "CWeaponElite.baseclass.baseclass.LocalWeaponData.m_iClip1"
	es_xkeycreate _secondaryweapons weapon_fiveseven
	es_xkeysetvalue _secondaryweapons weapon_fiveseven ammo "CCSPlayer.baseclass.localdata.m_iAmmo.010"
	es_xkeysetvalue _secondaryweapons weapon_fiveseven clip "CWeaponFiveSeven.baseclass.baseclass.LocalWeaponData.m_iClip1"
}
