PHP Code:
/* Plugin generated by AMXX-Studio */
#include <amxmodx>
#include <amxmisc>
#include <engine>
#include <fakemeta>
#include <hamsandwich>
#include <fun>
#include <cstrike>
#include <ujbm>
#define PLUGIN "[UJBM] Football"
#define VERSION "1.0"
#define AUTHOR "R_O_O_T"
new Float:ballorigin[3]
new Float:g_neta[3]
new Float:g_netb[3]
new Float:MB[3]
new Float:BB[3]
new ON = 0;
new BallOwner = 0
new bool:exist = true;
new bool:remove = true;
new m_iTrail
new gna
new gnb
new ball[] = "models/jb_ball.mdl"
new BALL_BOUNCE_GROUND[] = "kickball/bounce.wav"
new BALL_KICKED[][] = { "weapons/xbow_hitbod1.wav", "weapons/xbow_hitbod2.wav" }
new SCORED_GOAL[] = "kickball/goal.wav"
public plugin_precache()
{
m_iTrail = precache_model("sprites/smoke.spr")
}
public plugin_init() {
register_plugin(PLUGIN, VERSION, AUTHOR)
register_dictionary("ujbm.txt")
register_concmd("jb_football", "football_on", ADMIN_KICK)
register_concmd("jb_spawnball", "create", ADMIN_KICK)
register_logevent("football_off", 2, "0=World triggered", "1&Restart_Round_")
register_logevent("football_off", 2, "0=World triggered", "1=Game_Commencing")
register_logevent("football_off", 2, "0=World triggered", "1=Round_Start")
RegisterHam(Ham_Killed, "player", "player_killed", 1)
new Copyright[10] = AUTHOR;
new cfg[255]
new mapname[64]
get_mapname(mapname,63)
get_configsdir(cfg,255)
strcat(cfg,"/football/",255)
strcat(cfg,mapname,255)
if (file_exists(cfg))
{
new len = 255;
new text[255]
new x[8],y[8],z[8];new r;
if (!read_file(cfg,0,text,63,len))
exist = false;
else
{
parse(text,r, 7, x,7, y,7, z,7)
ballorigin[0] = str_to_float(x);ballorigin[1] = str_to_float(y);ballorigin[2] = str_to_float(z);
if (r == 'R') remove = true; else remove = false;
}////BALL ORIGIN
if (!read_file(cfg,1,text,63,len)) exist = false;
else
{
parse(text, x,7, y,7, z,7)
g_neta[0] = str_to_float(x);g_neta[1] = str_to_float(y);g_neta[2] = str_to_float(z);
}////GOALNET A
if (!read_file(cfg,2,text,63,len)) exist = false;
else
{
parse(text, x,7, y,7, z,7)
g_netb[0] = str_to_float(x);g_netb[1] = str_to_float(y);g_netb[2] = str_to_float(z);
}/// GOALNET B
if (!read_file(cfg,3,text,63,len)) exist = false;
else
{
parse(text, x,7, y,7, z,7)
MB[0] = str_to_float(x);MB[1] = str_to_float(y);MB[2] = str_to_float(z);
}/// minbox
if (!read_file(cfg,4,text,63,len))
exist = false;
else
{
parse(text, x,7, y,7, z,7)
BB[0] = str_to_float(x);BB[1] = str_to_float(y);BB[2] = str_to_float(z);
}/// maxbox
} else exist = false;
///kids protection
///kids protection
engfunc( EngFunc_PrecacheModel, ball)
engfunc( EngFunc_PrecacheSound, BALL_KICKED[0])
engfunc( EngFunc_PrecacheSound, BALL_KICKED[1])
engfunc( EngFunc_PrecacheSound, BALL_BOUNCE_GROUND)
engfunc( EngFunc_PrecacheSound, SCORED_GOAL)
engfunc( EngFunc_PrecacheModel, "models/chick.mdl")
if (Copyright[6] != 'T' || Copyright[2] != 'O' || Copyright[0] != 'R' || Copyright[4] != 'O' )
return PLUGIN_HANDLED
register_touch("PwnBall", "player", "ball_touch")
register_touch("PwnBall", "*", "touchWorld")
register_touch("PwnBall", "goalnet_a", "touch_goalnet_a")
register_touch("PwnBall", "goalnet_b", "touch_goalnet_b")
if(exist)
{
log_amx("starting football...")
if (remove) destroy;
create(0)
Make_GoalNets()
}
return PLUGIN_CONTINUE
}
public destroy()
{
new ent
// while((
ent = find_ent_in_sphere(-1,ballorigin, 30.0)
//!= 0)
//{
if (is_valid_ent(ent)) remove_entity(ent)
//}
}
new aball
public create(id)
{
if (!cmd_access(id,ADMIN_IMMUNITY,0,0)) return PLUGIN_HANDLED
if (aball) remove_entity(aball)
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] = -10.0
MinBox[1] = -10.0
MinBox[2] = 0.0
MaxBox[0] = 10.0
MaxBox[1] = 10.0
MaxBox[2] = 96.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,1)
}
//save our entity ID to aball variable
if(exist)
{
entity_set_origin(entity,ballorigin)
set_pev(gna, pev_effects, EF_NODRAW)
set_pev(gnb, pev_effects, EF_NODRAW)
}
else
{
new simon = get_simon()
if (is_user_alive(simon))
{
BallOwner = simon
}
}
aball = entity
RegisterHamFromEntity(Ham_Think,entity,"ball_think")
set_pev(entity, pev_nextthink, get_gametime()+0.03);
//glow(entity,200,1,1,1)
//entity_set_float(entity,EV_FL_nextthink,halflife_time() + 0.1)
return PLUGIN_HANDLED
}
/*
public velocity_by_aim2(id, )
vReturn[0] = floatcos( vAngles[1], degrees ) * fDistance
vReturn[1] = floatsin( vAngles[1], degrees ) * fDistance
vReturn[2] = floatsin( -vAngles[0], degrees ) * fDistance
*/
public ball_touch(entity, id)
{
if (!is_user_alive(id) || !is_valid_ent(entity)) return PLUGIN_CONTINUE
new button = entity_get_int(id, EV_INT_button)
new usekey = (button & IN_USE)
if (usekey)
{
//set_pev(aball, pev_nextthink, get_gametime()+0.03)
BallOwner = id;
entity_set_float(entity,EV_FL_framerate,1.0)
message_begin( MSG_BROADCAST, SVC_TEMPENTITY )
write_byte( TE_BEAMFOLLOW )
write_short(entity) // entity
write_short(m_iTrail) // model
write_byte( 5 ) // lifeffffff
write_byte( 8 ) // width
write_byte( random_num (10, 254)) // r, g, b
write_byte( 105 ) // r, g, b
write_byte( 180 ) // r, g, b
write_byte( 106 ) // brightness
message_end()
return PLUGIN_CONTINUE
}
if (BallOwner <= 0)
{
new Float:velocity[3]
if (get_speed(entity) < 300.0)
{
velocity_by_aim(id, random_num(200, 500), velocity)
entity_set_vector(entity,EV_VEC_velocity,velocity)
entity_set_float(entity,EV_FL_framerate,0.6)
}
}
return PLUGIN_CONTINUE
}
new button
new button_use
new button_forward
public ball_think(ent)
{
entity_set_float(ent, EV_FL_nextthink, get_gametime() + 0.02)
if(!is_valid_ent(ent) || BallOwner <= 0)
return PLUGIN_CONTINUE
if (is_user_alive(BallOwner))
{
//if get_speed(BallOwner > 200.0) entity_set_float(ent,EV_FL_framerate,1.0)
//set_pev(ent, pev_nextthink, get_gametime()+0.03);
button = entity_get_int(BallOwner, EV_INT_button)
button_use = (button & IN_USE)
button_forward = (button & IN_FORWARD)
if (!button_use)
{
emit_sound(BallOwner, CHAN_WEAPON, BALL_KICKED[random_num(0,1)], 1.0, ATTN_NORM, 0, PITCH_NORM)
new Float:velocity[3]
entity_get_vector(ent,EV_VEC_origin,velocity)
velocity[2] += 13.0
entity_set_vector(ent,EV_VEC_origin,velocity)
//
if (button_forward)
velocity_by_aim(BallOwner, random_num(1000, 1200), velocity)
else
velocity_by_aim(BallOwner, random_num(800, 1000), velocity)
if (velocity[2] < 30.0) velocity[2] = 100.0// for better aiming
//client_print(0,print_chat, "%f %f %f",velocity[0],velocity[1],velocity[2])
entity_set_vector(ent,EV_VEC_velocity,velocity)
BallOwner = 0
entity_set_float(ent,EV_FL_framerate,1.0)
return PLUGIN_CONTINUE
//entity_set_float(ent, EV_FL_nextthink, get_gametime() + 0.1)
}
if (button_forward)
ball_infront(BallOwner, 75.0)
else
ball_infront(BallOwner, 45.0)
}
return PLUGIN_CONTINUE
}
public ball_infront(id, Float:dist) {
new Float:nOrigin[3]
new Float:vAngles[3] // plug in the view angles of the entity
new Float:vReturn[3] // to get out an origin fDistance away
new Float:testorigin[3]
entity_get_vector(aball,EV_VEC_origin,testorigin)
entity_get_vector(id,EV_VEC_origin,nOrigin)
entity_get_vector(id,EV_VEC_v_angle,vAngles)
vReturn[0] = floatcos( vAngles[1], degrees ) * dist
vReturn[1] = floatsin( vAngles[1], degrees ) * dist
vReturn[0] += nOrigin[0]
vReturn[1] += nOrigin[1]
testorigin[0] = vReturn[0]
testorigin[1] = vReturn[1]
testorigin[2] = nOrigin[2]
new flags = entity_get_int(id, EV_INT_flags)
if(flags & FL_DUCKING)
testorigin[2] -= 5.0
else
testorigin[2] -= 28.0
entity_set_vector(aball,EV_VEC_velocity,Float:{ 0.01, 0.01, 0.01 } )
entity_set_origin(aball,testorigin)
/*
//Sets the angle to face the same as the player.
new Float:ang[3]
entity_get_vector(id,EV_VEC_angles,ang)
ang[0] = 0.0
ang[1] -= 90.0
ang[2] = 0.0
entity_set_vector(aball,EV_VEC_angles,ang)
*/
}
public touchWorld(ball, world) {
if (world == aball || is_user_connected(world))
return PLUGIN_CONTINUE
if (exist && (world == gna || world == gnb))
//// I don't check with a classname because of perfomance
return PLUGIN_CONTINUE
new Float:v[3]
entity_get_vector(ball, EV_VEC_velocity, v)
if (vector_length(v) > 8.0)
{
v[0] = (v[0] * 0.85)
v[1] = (v[1] * 0.85)
v[2] = (v[2] * 0.85)
entity_set_vector(ball, EV_VEC_velocity, v)
}
if(v[2] < -150.0)
{
emit_sound(ball, CHAN_ITEM, BALL_BOUNCE_GROUND, 1.0, ATTN_NORM, 0, PITCH_NORM)
}
if(vector_length(v) < 45.0)
{
entity_set_float(ball,EV_FL_framerate,0.0)
}
else
if(vector_length(v) < 100.0)
{
entity_set_float(ball,EV_FL_framerate,0.7)
}
// client_print(0,print_console, "%f",vector_length(v))
return PLUGIN_HANDLED
}
public Make_GoalNets()
{
gna = create_entity("info_target")
if (gna) {
entity_set_string(gna,EV_SZ_classname,"goalnet_a")
entity_set_model(gna, "models/chick.mdl")
entity_set_int(gna, EV_INT_solid, SOLID_BBOX)
entity_set_int(gna, EV_INT_movetype, MOVETYPE_NONE)
entity_set_vector(gna, EV_VEC_mins, MB)
entity_set_vector(gna, EV_VEC_maxs, BB)
set_entity_visibility(gna, 0)
entity_set_origin(gna,g_neta)
//glow(gn,234,1,1,1)
}
gnb = create_entity("info_target")
if (gnb) {
entity_set_string(gnb,EV_SZ_classname,"goalnet_b")
entity_set_model(gnb, "models/chick.mdl")
entity_set_int(gnb, EV_INT_solid, SOLID_BBOX)
entity_set_int(gnb, EV_INT_movetype, MOVETYPE_NONE)
entity_set_vector(gnb, EV_VEC_mins, MB)
entity_set_vector(gnb, EV_VEC_maxs, BB)
set_entity_visibility(gnb, 0)
entity_set_origin(gnb,g_netb)
//glow(gn,234,1,1,1)
}
}
stock fm_set_rendering(entity, fx = kRenderFxNone, r = 255, g = 255, b = 255, render = kRenderNormal, amount = 16)
{
static Float:color[3]; color[2] = float(b), color[0] = float(r), color[1] = float(g)
set_pev(entity, pev_renderfx, fx)
set_pev(entity, pev_rendercolor, color)
set_pev(entity, pev_rendermode, render)
set_pev(entity, pev_renderamt, float(amount))
return 1
}
public touch_goalnet_a(ball, world)
{
if (ON != 1)return PLUGIN_CONTINUE
emit_sound(ball, CHAN_ITEM, SCORED_GOAL, 1.0, ATTN_NORM, 0, PITCH_NORM)
set_hudmessage(0, 255, 255, -1.0, -1.0, 0, 6.0, 6.0)
show_hudmessage(0, "%L", LANG_SERVER, "UJBM_FOOTBALL_A")
set_pev(world, pev_effects, EF_BRIGHTLIGHT)
fm_set_rendering(world, kRenderFxGlowShell, 150, 150, 250, kRenderTransAlpha, 0)
remove_entity(ball)
set_task(3.0, "create")
return PLUGIN_CONTINUE
}
public touch_goalnet_b(ball, world)
{
if (ON != 1)return PLUGIN_CONTINUE
emit_sound(ball, CHAN_ITEM, SCORED_GOAL, 1.0, ATTN_NORM, 0, PITCH_NORM)
set_hudmessage(0, 255, 255, -1.0, -1.0, 0, 6.0, 6.0)
show_hudmessage(0, "%L", LANG_SERVER, "UJBM_FOOTBALL_A")
set_pev(world, pev_effects, EF_BRIGHTLIGHT)
fm_set_rendering(world, kRenderFxGlowShell, 150, 150, 250, kRenderTransAlpha, 0)
remove_entity(ball)
set_task(3.0, "create")
return PLUGIN_CONTINUE
}
public football_on()
{
if (!ON) ON = 1; else football_off()
set_hudmessage(42, 255, 0, -1.0, 0.40, 0, 6.0, 4.0)
show_hudmessage(0, "%L", LANG_SERVER, "UJBM_FOOTBALL")
return PLUGIN_CONTINUE
}
public football_off()
{
ON = 0;
BallOwner = 0;
remove_entity(aball)
if (exist) create(0)
return PLUGIN_CONTINUE
}
public player_killed(victim, attacker, shouldgib)
{
if (victim == BallOwner) BallOwner = 0
}
/* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
*{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang1049\\ f0\\ fs16 \n\\ par }
*/