I didn't exactly write this disco code myself, I found it on the forum but I've made quite a few edits. Sometimes when it's called it works, but other times it crashes a few seconds into the disco or as soon as its activated. It does'nt leave an error log. I'm quite sure it works when I'm the only person in the server.
Here's what I have:
PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <fakemeta>
#include <engine>
#define write_coord_f(%0) engfunc(EngFunc_WriteCoord,%0)
new const gDiscoClass[] = "disco"
new gDiscoSprite, gDiscoEnt, gDiscoPlayer;
public plugin_precache()
{
gDiscoSprite = precache_model("sprites/laserbeam.spr");
}
public plugin_init()
{
register_think( gDiscoClass, "thinkDisco" );
register_clcmd( "say /start", "cmdStart" );
}
public cmdStart( id )
{
gDiscoPlayer = id;
new Float:Origin[ 3 ];
pev( id, pev_origin, Origin )
gDiscoEnt = create_entity( "info_target" );
set_pev(gDiscoEnt,pev_classname,gDiscoClass)
engfunc(EngFunc_SetSize,gDiscoEnt,Float:{-311.0,-1.0,-1.0},Float:{311.0,1.0,1.0})
engfunc(EngFunc_SetOrigin,gDiscoEnt,Origin)
set_pev(gDiscoEnt,pev_effects,EF_BRIGHTFIELD)
set_pev(gDiscoEnt,pev_solid,SOLID_BBOX)
set_pev(gDiscoEnt,pev_movetype,MOVETYPE_TOSS)
set_pev(gDiscoEnt,pev_owner,id)
set_pev(gDiscoEnt,pev_nextthink,get_gametime()+0.1)
set_task( 20.0, "DiscoEnd", id );
return PLUGIN_HANDLED_MAIN;
}
public thinkDisco( gDiscoEnt )
{
if( !is_valid_ent( gDiscoEnt ) )
return PLUGIN_HANDLED;
static Float:Origin[ 3 ];
static Float:End[ 3 ];
static Float:Position[ 3 ];
pev( gDiscoPlayer, pev_origin, Origin );
End[0] = 1000.0
End[1] = 1000.0
End[2] = 1000.0
trace_line( gDiscoPlayer, Origin, End,Position )
message_begin( MSG_BROADCAST, SVC_TEMPENTITY )
write_byte(TE_BEAMDISK)
write_coord_f(Origin[0])
write_coord_f(Origin[1])
write_coord_f(Origin[2])
write_coord_f(1000.0)
write_coord_f(1000.0)
write_coord_f(1000.0)
write_short(gDiscoSprite)
write_byte(0)
write_byte(0)
write_byte(1)
write_byte(5)
write_byte(50)
write_byte(random_num(1,255))
write_byte(random_num(1,255))
write_byte(random_num(1,255))
write_byte(200)
write_byte(30)
message_end()
set_pev( gDiscoEnt, pev_nextthink,get_gametime() + 0.1 )
return PLUGIN_CONTINUE;
}
public DiscoEnd( id )
{
remove_entity_name( gDiscoClass );
return PLUGIN_CONTINUE;
}
Please don't worry about the efficiency in relation to an on/off variable and who can use it, that's simple, right now I just really want to get it working so it won't crash the server.
Thankyou!