PHP Code:
#include <amxmodx>
#include <fakemeta>
#define CLASS_FIREBALL "Fireball"
new const FIREBALL_SPRITE[] = "models/fireball.spr"
new Float: g_LastFthrow[33]
new cvar_damage, cvar_xdamage, cvar_xforce
public plugin_precache()
{
engfunc(EngFunc_PrecacheModel, FIREBALL_SPRITE);
}
public plugin_init()
{
register_plugin("Skill Fireball", "1.0", "Frostas")
cvar_xforce = register_cvar("fb_xforce", "1500")
cvar_damage = register_cvar("fb_damage", "200")
cvar_xdamage = register_cvar("fb_xdamage","1")
register_forward(FM_PlayerPreThink, "fw_PlayerPreThink")
}
public clcmd_throw(id)
{
static Float: Origin[3], Float: Velocity[3], Float: Angle[3], MinBox[3], MaxBox[3]
pev(id, pev_origin, Origin)
pev(id, pev_velocity, Velocity)
pev(id, pev_angles, Angle)
static Health, Float: damage
Health = get_user_health(id)
damage = get_pcvar_float(cvar_xdamage)
if (Health > damage)
{
static ent ; ent = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "info_target"))
set_pev(ent, pev_classname, CLASS_FIREBALL)
engfunc(EngFunc_SetModel, ent, FIREBALL_SPRITE)
Angle[0] = random_float(1.0, 360.0)
Angle[1] = random_float(1.0, 360.0)
MinBox = { -1.0, -1.0, -1.0 }
MaxBox = { 1.0, 1.0, 1.0 }
set_pev(ent, pev_angles, Angle)
engfunc(EngFunc_SetSize, ent, MinBox, MaxBox)
engfunc(EngFunc_SetOrigin, ent, Origin)
set_pev(ent, pev_movetype, MOVETYPE_TOSS)
set_pev(ent, pev_solid, SOLID_TRIGGER)
set_pev(ent, pev_owner, id)
velocity_by_aim(id, get_pcvar_num(cvar_xforce), Velocity)
set_pev(ent, pev_velocity, Velocity)
set_pev(id, pev_health, Health - damage)
}
else
{
client_print(id, print_center, "You haven't that HP")
}
}
public fw_PlayerPreThink(id)
{
if(!is_user_alive(id))
return FMRES_IGNORED
static Float: Time
static button
button = pev(id, pev_button)
Time = get_gametime()
if (button & IN_USE)
{
if(Time - 1.1 > g_LastFthrow[id])
{
clcmd_throw(id)
g_LastFthrow[id] = Time
}
}
return PLUGIN_CONTINUE;
}