Instead of glow, I added fire on the ball.
PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#include <engine>
#include <fakemeta>
#include <hamsandwich>
#define redball_classname "redball_class"
#define redball_model "models/kickball/ball.mdl"
#define redball_firemodel "sprites/flame.spr"
new g_redball_menu, g_redball_firemodelid
public plugin_init()
{
register_plugin("[Jailbreak] Redball", "1.0", "xPaw / Xalus")
// Register: Clcmds
register_clcmd("say /redball", "redball_clcmd")
// Register: Logevents
register_logevent("server_roundend", 2, "1=Round_End")
// Create global menu
g_redball_menu = menu_create("\dJailbreak\r Red ball", "redball_menu_handler")
menu_additem(g_redball_menu, "Spawn ball")
menu_additem(g_redball_menu, "Remove balls")
}
public plugin_precache()
{
precache_model(redball_model)
g_redball_firemodelid = precache_model(redball_firemodel)
}
public server_roundend()
{
redball_remove()
}
public redball_clcmd(client)
{
if( (is_user_alive(client) && cs_get_user_team(client) == CS_TEAM_CT)
|| is_user_admin(client) )
{
menu_display(client, g_redball_menu)
}
return PLUGIN_HANDLED
}
public redball_menu_handler(client, menu, item)
{
if( item != MENU_EXIT
&& (is_user_alive(client) || is_user_admin(client)) )
{
if(!item)
{
redball_spawn(client)
return
}
redball_remove(client)
}
}
redball_remove(client = 0)
{
remove_entity_name(redball_classname)
if(client)
{
new client_name[32]
get_user_name(client, client_name, charsmax(client_name))
client_print(0, print_chat, ">Jailbreak> %s removed all redballs.", client_name)
}
}
redball_spawn(client)
{
new ball_entity = create_entity("info_target")
if(is_valid_ent(ball_entity))
{
entity_set_string(ball_entity, EV_SZ_classname, redball_classname)
entity_set_int(ball_entity, EV_INT_solid, SOLID_BBOX)
entity_set_int(ball_entity, EV_INT_movetype, MOVETYPE_BOUNCE)
entity_set_float(ball_entity, EV_FL_health, 300.0)
entity_set_float(ball_entity, EV_FL_takedamage, 1.0)
entity_set_model(ball_entity, redball_model)
entity_set_size(ball_entity, Float:{-15.0, -15.0, 0.0}, Float:{15.0, 15.0, 12.0})
new client_aimorigin[3], Float:ball_origin[3]
get_user_origin(client, client_aimorigin, 3)
client_aimorigin[2] += 10
IVecFVec(client_aimorigin, ball_origin)
entity_set_origin(ball_entity, ball_origin)
entity_set_vector(ball_entity, EV_VEC_velocity, Float:{0.0, 0.0, 0.0})
new client_name[32]
get_user_name(client, client_name, charsmax(client_name))
client_print(0, print_chat, ">Jailbreak> %s spawned a redball.", client_name)
// Register stuff
RegisterHamFromEntity(Ham_Touch, ball_entity, "redball_touch", 1)
RegisterHamFromEntity(Ham_TakeDamage, ball_entity, "redball_damage", 0)
RegisterHamFromEntity(Ham_Think, ball_entity, "redball_think", 0)
entity_set_float(ball_entity, EV_FL_nextthink, get_gametime( ) + 0.05)
}
}
public redball_think(ball_entity)
{
if(is_valid_ent(ball_entity))
{
entity_set_float(ball_entity, EV_FL_nextthink, get_gametime( ) + 0.05)
new Float:ball_origin[3]
entity_get_vector(ball_entity, EV_VEC_origin, ball_origin)
new Float:flRand = random_float(1.0, 5.0);
message_begin(MSG_BROADCAST, SVC_TEMPENTITY);
write_byte(TE_SPRITE);
engfunc(EngFunc_WriteCoord, ball_origin[0]); // Position
engfunc(EngFunc_WriteCoord, ball_origin[1]);
engfunc(EngFunc_WriteCoord, ball_origin[2] + flRand * 5.0) // 120;
write_short(g_redball_firemodelid); // Sprite index
write_byte(floatround(flRand)); // Scale
write_byte(50); // Brightness
message_end();
}
}
public redball_touch(ball_entity, client)
{
if(is_valid_ent(ball_entity))
{
if(is_user_alive(client) )
{
if(cs_get_user_team(client) == CS_TEAM_CT)
{
redball_kick(ball_entity, client, 2000)
return
}
redball_kick(ball_entity, client, 550)
user_kill(client)
return
}
new Float:ball_velocity[3]
entity_get_vector(ball_entity, EV_VEC_velocity, ball_velocity)
if(floatround( vector_length( ball_velocity ) ) > 10)
{
ball_velocity[0] *= 0.90;
ball_velocity[1] *= 0.90;
ball_velocity[2] *= 0.90;
entity_set_vector(ball_entity, EV_VEC_velocity, ball_velocity)
}
}
}
public redball_damage(ball_entity, inflictor, attacker, Float:damage, damagebits)
{
if( is_valid_ent(ball_entity)
&& is_user_alive(attacker) )
{
new Float:ball_health = entity_get_float(ball_entity, EV_FL_health)
if(ball_health >= 0.0
&& (ball_health - damage) <= 0.0)
{
new client_name[32]
get_user_name(attacker, client_name, charsmax(client_name))
client_print(0, print_chat, ">Jailbreak> %s killed the redball.", client_name)
return
}
redball_kick(ball_entity, attacker, 500)
}
}
redball_kick(ball_entity, client, power)
{
new Float:ball_origin[3], Float:ball_velocity[3]
entity_get_vector(ball_entity, EV_VEC_origin, ball_origin)
velocity_by_aim(client, power, ball_velocity)
ball_velocity[2] += 30.0
entity_set_vector(ball_entity, EV_VEC_velocity, ball_velocity)
}