PHP Code:
public plugin_init()
{
//...
register_think("PwnBall","ball_think")
//...
}
//...
createball() {
new entity = create_entity("info_target")
if (entity) {
entity_set_string(entity,EV_SZ_classname,"PwnBall")
entity_set_model(entity, ball)
entity_set_int(entity, EV_INT_solid, SOLID_BBOX)
entity_set_int(entity, EV_INT_movetype, MOVETYPE_BOUNCE)
new Float:MinBox[3]
new Float:MaxBox[3]
MinBox[0] = -15.0
MinBox[1] = -15.0
MinBox[2] = 0.0
MaxBox[0] = 15.0
MaxBox[1] = 15.0
MaxBox[2] = 12.0
entity_set_vector(entity, EV_VEC_mins, MinBox)
entity_set_vector(entity, EV_VEC_maxs, MaxBox)
glow(entity,ballcolor[0],ballcolor[1],ballcolor[2],10)
entity_set_float(entity,EV_FL_framerate,0.0)
entity_set_int(entity,EV_INT_sequence,0)
}
//save our entity ID to aball variable
aball = entity
entity_set_float(entity,EV_FL_nextthink,halflife_time() + 0.05)
return PLUGIN_HANDLED
}
//...
public ball_think() {
new maxscore = get_pcvar_num(CVAR_SCORE)
if(score[1] >= maxscore || score[2] >= maxscore) {
entity_set_float(aball,EV_FL_nextthink,halflife_time() + 0.05)
return PLUGIN_HANDLED
}
if(is_valid_ent(aball))
{
new Float:gametime = get_gametime()
if(PowerPlay >= MAX_LVL_POWERPLAY && gametime - fire_delay >= 0.3)
on_fire()
if(ballholder > 0)
{
new team = get_user_team(ballholder)
entity_get_vector(ballholder, EV_VEC_origin,testorigin)
if(!is_user_alive(ballholder)) {
new tname[32]
get_user_name(ballholder,tname,31)
remove_task(55555)
set_task(get_pcvar_float(CVAR_RESET),"clearBall",55555)
if(!g_sprint[ballholder])
set_speedchange(ballholder)
format(temp1,63,"%L", LANG_PLAYER, "DROPPED_BALL", TeamNames[team], tname)
//remove glow of owner and set ball velocity really really low
glow(ballholder,0,0,0,0)
ballowner = ballholder
ballholder = 0
testorigin[2] += 5
entity_set_origin(aball, testorigin)
new Float:vel[3], x
for(x=0;x<3;x++)
vel[x] = 1.0
entity_set_vector(aball,EV_VEC_velocity,vel)
entity_set_float(aball,EV_FL_nextthink,halflife_time() + 0.05)
return PLUGIN_HANDLED
}
if(entity_get_int(aball,EV_INT_solid) != SOLID_NOT)
entity_set_int(aball, EV_INT_solid, SOLID_NOT)
//Put ball in front of player
ball_infront(ballholder, 55.0)
new i
for(i=0;i<3;i++)
velocity[i] = 0.0
//Add lift to z axis
new flags = entity_get_int(ballholder, EV_INT_flags)
if(flags & FL_DUCKING)
testorigin[2] -= 10
else
testorigin[2] -= 30
entity_set_vector(aball,EV_VEC_velocity,velocity)
entity_set_origin(aball,testorigin)
}
else {
if(entity_get_int(aball,EV_INT_solid) != SOLID_BBOX)
entity_set_int(aball, EV_INT_solid, SOLID_BBOX)
}
}
entity_set_float(aball,EV_FL_nextthink,halflife_time() + 0.05)
return PLUGIN_HANDLED
}