Code:
#include <amxmodx>
#include <xs>
#include <engine>
#include <fakemeta_stocks>
#include <cstrike>
#define PLUGIN "Jumper"
#define VERSION "0.0.1"
//const Float:MAX_TELEPORT_Z = 125.0 // approximative height from where you can fall without taking any damage.
const Float:MAX_TELEPORT_Z = 500.0
new const g_szTeleSnd[] = { "teleport/blinkarrival.wav" };
new const Invalid[] = { "Invalid Location" };
new bool:IsJumper[33];
new iCost, g_iBlinkAcct;
public plugin_init()
{
register_plugin( PLUGIN, VERSION, "ConnerMcLeod/Blizzard" );
g_iBlinkAcct = get_user_msgid("BlinkAcct");
iCost = register_cvar("amx_jumper_cost", "10000");
register_clcmd("drop", "ClientCommand_drop");
register_clcmd("say /buyjumper", "PurchJumper", 0)
}
public plugin_precache()
{
precache_sound(g_szTeleSnd)
}
public client_connect(id) HasJumper( id, false )
public client_disconnect(id) HasJumper( id, false )
public PurchJumper(id)
{
new money = cs_get_user_money(id);
if( money < get_pcvar_num(iCost) )
{
NotEnoughMoney( id );
return PLUGIN_HANDLED;
}
HasJumper( id, true );
cs_set_user_money( id, money - get_pcvar_num(iCost) );
return PLUGIN_HANDLED;
}
public ClientCommand_drop( id )
{
if( get_user_weapon(id) == CSW_KNIFE )
{
if(IsJumper[id])
{
TeleportToAimPoint( id )
return PLUGIN_HANDLED;
}
}
return PLUGIN_CONTINUE
}
// ConnerMcleod's Code
TeleportToAimPoint( id )
{
new Float:coordOrigin[3], Float:coordDest[3], Float:flFraction, Float:vecPlaneNormal[3], Float:vecTemp[3]
pev(id, pev_origin, coordOrigin)
coordOrigin[2] += pev(id, pev_flags) & FL_DUCKING ? 12.0 : 18.0
velocity_by_aim(id, 9999, coordDest)
xs_vec_add(coordDest, coordOrigin, coordDest)
trace_normal(id, coordOrigin, coordDest, vecPlaneNormal)
trace_line(id, coordOrigin, coordDest, coordDest)
traceresult(TR_Fraction, flFraction)
if( flFraction >= 1.0 || point_contents( coordDest ) == CONTENTS_SKY )
{
client_print( id, print_center, "Cannot Teleport Into Sky" );
return 0
}
new const Float:maxs[3] = { 16.0, 16.0, 36.0};
new i
for(i=0; i<3; i++)
{
vecTemp[i] = vecPlaneNormal[i] * maxs[i]
}
xs_vec_add(coordDest, vecTemp, coordDest)
vecTemp[0] = coordDest[0]
vecTemp[1] = coordDest[1]
vecTemp[2] = coordDest[2] - maxs[2]
trace_line(id, coordDest, vecTemp, vecTemp)
new Float:flDist = coordDest[2] - vecTemp[2]
if( flDist < maxs[2] )
{
vecTemp[2] += maxs[2]
if( !trace_hull(vecTemp, HULL_HUMAN) )
{
xs_vec_copy(vecTemp, coordDest)
goto CheckHeight
}
client_print( id, print_center, Invalid );
return 0
}
if( trace_hull(coordDest, HULL_HUMAN) )
{
client_print( id, print_center, Invalid );
return 0
}
CheckHeight:
vecTemp[0] = coordDest[0]
vecTemp[1] = coordDest[1]
vecTemp[2] = coordDest[2] - 9999.0
engfunc(EngFunc_TraceHull, coordDest, vecTemp, DONT_IGNORE_MONSTERS, HULL_HUMAN, FM_NULLENT, 0)
get_tr2(0, TR_flFraction, flFraction)
flFraction *= 9999.0
flFraction -= maxs[2]
if( flFraction > MAX_TELEPORT_Z )
{
client_print( id, print_center, Invalid );
return 0
}
Util_TE_TELEPORT(coordOrigin)
Util_TE_TELEPORT(coordDest)
emit_sound( id, CHAN_AUTO, g_szTeleSnd, 0.6, ATTN_NORM, 0, PITCH_HIGH );
entity_set_origin(id, coordDest)
return 1
}
Util_TE_TELEPORT( const Float:origin[3] )
{
EF_MessageBegin(MSG_PVS, SVC_TEMPENTITY, origin, 0)
write_byte(TE_TELEPORT)
EF_WriteCoord(origin[0])
EF_WriteCoord(origin[1])
EF_WriteCoord(origin[2])
message_end()
}
// End ConnerMcLeods Code
stock HasJumper( id, bool:Jumper )
{
if(Jumper) IsJumper[id] = true;
else IsJumper[id] = false;
return PLUGIN_HANDLED;
}
NotEnoughMoney( id )
{
client_print(id, print_center, "#Cstrike_TitlesTXT_Not_Enough_Money");
message_begin(MSG_ONE_UNRELIABLE, g_iBlinkAcct, .player=id);
{
write_byte(2);
}
message_end();
}