#pragma semicolon 1
#pragma newdecls required
#include <sourcemod>

public Plugin myinfo =
{
	name = "JumpBoost",
	author = "BotoX",
	description = "",
	version = "1.0",
	url = ""
};

ConVar g_CVar_sm_jumpboost;
int g_ivecAbsVelocity;

public void OnPluginStart()
{
	HookEvent("player_jump", OnPlayerJump, EventHookMode_Post);

	g_CVar_sm_jumpboost = CreateConVar("sm_jumpboost", "1.05", "Jump boost.", 0, true, 0.0, true, 10.0);

	AutoExecConfig(true, "plugin.JumpBoost");
}

public void OnMapStart()
{
	g_ivecAbsVelocity = FindDataMapInfo(0, "m_vecAbsVelocity");
}

public void OnPlayerJump(Event event, const char[] name, bool dontBroadcast)
{
	int userid = GetEventInt(event, "userid");
	if(g_CVar_sm_jumpboost.FloatValue != 1.0)
		RequestFrame(OnPlayerJumpPost, userid);
}

public void OnPlayerJumpPost(int userid)
{
	int client = GetClientOfUserId(userid);
	if(!client)
		return;

	float vecAbsVelocity[3];
	GetEntDataVector(client, g_ivecAbsVelocity, vecAbsVelocity);

	vecAbsVelocity[2] *= g_CVar_sm_jumpboost.FloatValue;

	SetEntDataVector(client, g_ivecAbsVelocity, vecAbsVelocity);
}
