#include <metahook.h>
#include "exportfuncs.h"
#include "engfuncs.h"
#include "client.h"

void (*pfnCMD_Slot1)(void);
void (*pfnCMD_Slot2)(void);
void (*pfnCMD_Slot3)(void);
void (*pfnCMD_Slot4)(void);
void (*pfnCMD_Slot5)(void);
void (*pfnCMD_ScoreDown)(void);
void (*pfnCMD_ScoreUp)(void);
void (*pfnCMD_LastInv)(void);

void CMD_Slot1(void)
{
	if(!g_iMenu && g_iWeaponID && g_WeaponInfo[g_iWeaponID].iState)
	{
		gEngfuncs.pfnClientCmd("switch 1");
		g_WeaponSelect = 1;
		return;
	}
	return pfnCMD_Slot1();
}

void CMD_Slot2(void)
{
	if(!g_iMenu && g_iWeaponID && g_WeaponInfo[g_iWeaponID].iState)
	{
		gEngfuncs.pfnClientCmd("switch 2");
		g_WeaponSelect = 2;
		return;
	}
	return pfnCMD_Slot2();
}

void CMD_Slot3(void)
{
	if(!g_iMenu && g_iWeaponID && g_WeaponInfo[g_iWeaponID].iState)
	{
		gEngfuncs.pfnClientCmd("switch 3");
		g_WeaponSelect = 3;
		return;
	}
	return pfnCMD_Slot3();
}

void CMD_Slot4(void)
{
	if(!g_iMenu && g_iWeaponID && g_WeaponInfo[g_iWeaponID].iState)
	{
		gEngfuncs.pfnClientCmd("switch 4");
		g_WeaponSelect = 4;
		return;
	}
	return pfnCMD_Slot4();
}

void CMD_Slot5(void)
{
	if(!g_iMenu && g_iWeaponID && g_WeaponInfo[g_iWeaponID].iState)
	{
		gEngfuncs.pfnClientCmd("switch 5");
		g_WeaponSelect = 5;
		return;
	}
	return pfnCMD_Slot5();
}

void CMD_ScoreDown(void)
{
	//not done yet
	//pfnCMD_ScoreDown();
	g_ScoreBoardEnabled = 1;
}

void CMD_ScoreUp(void)
{
	//not done yet
	//pfnCMD_ScoreUp();
	g_ScoreBoardEnabled = 0;
}

int pfnAddCommand(char *szCmds, void (*pFunction)(void))
{
	if (!strcmp(szCmds, "+scores"))
	{
		return gEngfuncs.pfnAddCommand(szCmds, CMD_ScoreDown);
	}
	if (!strcmp(szCmds, "-scores"))
	{
		return gEngfuncs.pfnAddCommand(szCmds, CMD_ScoreUp);
	}
	if (!strcmp(szCmds, "+showscores"))
	{
		pfnCMD_ScoreDown = pFunction;
		return gEngfuncs.pfnAddCommand(szCmds, CMD_ScoreDown);
	}
	if (!strcmp(szCmds, "-showscores"))
	{
		pfnCMD_ScoreUp = pFunction;
		return gEngfuncs.pfnAddCommand(szCmds, CMD_ScoreUp);
	}
	if (!strcmp(szCmds, "slot1"))
	{
		pfnCMD_Slot1 = pFunction;
		return gEngfuncs.pfnAddCommand(szCmds, CMD_Slot1);
	}
	if (!strcmp(szCmds, "slot2"))
	{
		pfnCMD_Slot2 = pFunction;
		return gEngfuncs.pfnAddCommand(szCmds, CMD_Slot2);
	}
	if (!strcmp(szCmds, "slot3"))
	{
		pfnCMD_Slot3 = pFunction;
		return gEngfuncs.pfnAddCommand(szCmds, CMD_Slot3);
	}
	if (!strcmp(szCmds, "slot4"))
	{
		pfnCMD_Slot4 = pFunction;
		return gEngfuncs.pfnAddCommand(szCmds, CMD_Slot4);
	}
	if (!strcmp(szCmds, "slot5"))
	{
		pfnCMD_Slot5 = pFunction;
		return gEngfuncs.pfnAddCommand(szCmds, CMD_Slot5);
	}
	/*if (!strcmp(szCmds, "lastinv"))
	{
		pfnCMD_LastInv = pFunction;
		return gEngfuncs.pfnAddCommand(szCmds, CMD_LastInv);
	}*/
	return gEngfuncs.pfnAddCommand(szCmds, pFunction);
}