Here...
Code:
new VelocityOffset_0;
new VelocityOffset_1;
new BaseVelocityOffset;
// Declare convar handles
new Handle:hPush;
new Handle:hHeight;
new bool:g_bPush[MAXPLAYERS+1] = { true, ...};
public Plugin:myinfo =
{
name = "BunnyHop",
author = "Soccerdude",
description = "Boost",
version = "1.0.1",
url = "http://sourcemod.net/"
};
public OnPluginStart()
{
//PrintToServer("----------------| BunnyHop Loading |---------------");
// Hook Events
HookEvent("player_jump",PlayerJumpEvent);
// Find offsets
VelocityOffset_0=FindSendPropOffs("CBasePlayer","m_vecVelocity[0]");
if(VelocityOffset_0==-1)
SetFailState("[BunnyHop] Error: Failed to find Velocity[0] offset, aborting");
VelocityOffset_1=FindSendPropOffs("CBasePlayer","m_vecVelocity[1]");
if(VelocityOffset_1==-1)
SetFailState("[BunnyHop] Error: Failed to find Velocity[1] offset, aborting");
BaseVelocityOffset=FindSendPropOffs("CBasePlayer","m_vecBaseVelocity");
if(BaseVelocityOffset==-1)
SetFailState("[BunnyHop] Error: Failed to find the BaseVelocity offset, aborting");
// Create cvars
hPush=CreateConVar("bunnyhop_push","0.35","The forward push when you jump");
hHeight=CreateConVar("bunnyhop_height","1.0","The upward push when you jump");
// Create config
AutoExecConfig();
// Public cvar
CreateConVar("bunnyhop_version","1.0.1","[BunnyHop] Current version of this plugin",FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_UNLOGGED|FCVAR_DONTRECORD|FCVAR_REPLICATED|FCVAR_NOTIFY);
RegConsoleCmd("sm_boost", cmd_boost);
//PrintToServer("----------------| BunnyHop Loaded |---------------");
}
public OnClientConnected(client)
{
g_bPush[client] = true;
}
public Action:cmd_boost(client, args)
{
if(client != 0)
{
g_bPush[client] = g_bPush[client] ? false:true;
ReplyToCommand(client, "Boost %s", g_bPush[client] ? "enabled":"disable");
}
return Plugin_Handled;
}
public PlayerJumpEvent(Handle:event,const String:name[],bool:dontBroadcast)
{
new index=GetClientOfUserId(GetEventInt(event,"userid"));
new Float:finalvec[3], bool:current = g_bPush[index];
finalvec[0]=GetEntDataFloat(index,VelocityOffset_0)* (current ? (GetConVarFloat(hPush)/2.0):0.0);
finalvec[1]=GetEntDataFloat(index,VelocityOffset_1)* (current ? (GetConVarFloat(hPush)/2.0):0.0);
finalvec[2]=GetConVarFloat(hHeight)*50.0;
SetEntDataVector(index,BaseVelocityOffset,finalvec,true);
}