Code:
public cmdShoot(id)
{
new origin[3], Float:fOrigin[3]
new Float:velocity[3]
get_user_origin(id,origin,1)
IVecFVec(origin, fOrigin)
new ePlasmaBall = create_entity("info_target")
entity_set_string(ePlasmaBall, EV_SZ_classname, "PlasmaBall")
new Float:posAdjust[3] //Used for adjusting the starting position
velocity_by_aim(id, 70, posAdjust) //You can replace 50 with whatever
fOrigin[0] += posAdjust[0]
fOrigin[1] += posAdjust[1]
fOrigin[2] += posAdjust[2]
entity_set_vector(ePlasmaBall, EV_VEC_origin, fOrigin)
entity_set_vector(ePlasmaBall, EV_VEC_origin,fOrigin)
new Float:maxs[3] = {0.2,0.2,0.5}
new Float:mins[3] = {-0.2,-0.2,-0.5}
entity_set_size(ePlasmaBall,mins,maxs)
entity_set_int(ePlasmaBall,EV_INT_solid, SOLID_BBOX)
entity_set_int(ePlasmaBall,EV_INT_movetype,MOVETYPE_FLYMISSILE)
entity_set_float(ePlasmaBall,EV_FL_framerate,1.0)
entity_set_int(ePlasmaBall, EV_INT_rendermode, 5)
entity_set_float(ePlasmaBall, EV_FL_renderamt, 255.0)
entity_set_float(ePlasmaBall, EV_FL_scale, 1.20)
entity_set_model(ePlasmaBall, "sprites/plasma.spr")
emit_sound(ePlasmaBall, CHAN_AUTO, "misc/plasma_shoot.wav", 1.0, ATTN_NORM, 0, PITCH_NORM)
VelocityByAim(id,200,velocity)
entity_set_vector(ePlasmaBall,EV_VEC_velocity,velocity)
entity_set_edict(ePlasmaBall, EV_ENT_owner, id)
// Create a trail...
/* Broadcast to all players*/
message_begin(MSG_BROADCAST, SVC_TEMPENTITY)// TE_BEAMFOLLOW ( msg #22) create a line of decaying beam segments until entity stops moving
write_byte(22) // msg id
write_short(ePlasmaBall) // short (entity:attachment to follow)
write_short(gTrailModel) // short (sprite index)
write_short(20) // byte (life in 0.1's) ( length )
write_short(8) // byte (line width in 0.1's)
write_byte(42) // byte (color) red
write_byte(170) // byte (color) green
write_byte(255) // byte (color) blue
write_byte(50) // byte (brightness)
message_end() // msg complete
}