PDA

View Full Version : Last Man Standing Beacon


xTr3m3r
01-25-2017, 22:35
Hello there!

Im struggling really hard with Pawn and I need some help editing a plugin.

The plugin attached is Beacon which makes a blinking circle around you when you get deagle, awp or both. I want it to work only when you are the last Terrorist left but when you have a weapon it should not blink.

If anyone is able to help me I would really appreciate it. Thanks :)

edon1337
01-26-2017, 06:17
#include <amxmodx>
#include <amxmisc>
#include <fakemeta>
#include <cstrike>
#include <fun>

#define MAX_PLAYERS 32
#define UPDATE_INTERVAL 2.0
#define TID_TIMER 9124

new g_snd_path[] = "buttons/blip1.wav"
new g_sprite_path[] = "sprites/white.spr"

new bool:g_got_beacon[MAX_PLAYERS+1]
new g_max_players
new Float:g_t_time
new g_timer_entid
new g_sprite

public plugin_init()
{
register_plugin("Beacon", "1.0", "Sylwester");

g_max_players = get_maxplayers();
create_timer();
}

public plugin_precache()
{
precache_sound(g_snd_path)
g_sprite = precache_model(g_sprite_path)
}

public client_connect(id)
{
g_got_beacon[id] = false
}

public client_PreThink(id)
{
if ( user_has_weapon( id, CSW_AWP ) || user_has_weapon( id, CSW_DEAGLE ) )
{
new players[32], num;
get_players(players, num, "ae", "TERRORIST")

if(is_user_alive(id) && num == 1 && cs_get_user_team(id) == CS_TEAM_T)
g_got_beacon[id] = true
}

else
{
g_got_beacon[id] = false
}
}

public create_timer()
{
g_timer_entid = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString,"info_target"))

if(pev_valid(g_timer_entid))
{
set_pev(g_timer_entid, pev_classname, "beacon_timer")
global_get(glb_time, g_t_time)
set_pev(g_timer_entid, pev_nextthink, g_t_time + UPDATE_INTERVAL)
register_forward(FM_Think,"fwd_Think")
}
else
{
log_amx("Warning: Failed to create timer entity, using task instead")
set_task(UPDATE_INTERVAL, "timer_cycle", TID_TIMER, "", 0, "b")
}
}


public fwd_Think(Ent){
if(Ent != g_timer_entid)
return FMRES_IGNORED
g_t_time += UPDATE_INTERVAL
set_pev(Ent, pev_nextthink, g_t_time)
timer_cycle()
return FMRES_IGNORED
}


public plugin_unpause()
{
if(pev_valid(g_timer_entid))
{
global_get(glb_time, g_t_time)
g_t_time += UPDATE_INTERVAL
set_pev(g_timer_entid, pev_nextthink, g_t_time)
}
}


public timer_cycle()
{
static id
for(id=1; id<=g_max_players; id++)
if(g_got_beacon[id] && is_user_alive(id))
show_beacon(id)
}


public show_beacon(id)
{
static origin[3]
emit_sound(id, CHAN_ITEM, g_snd_path, 1.0, ATTN_NORM, 0, PITCH_NORM)

get_user_origin(id, origin)
message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
write_byte(TE_BEAMCYLINDER)
write_coord(origin[0]) //position.x
write_coord(origin[1]) //position.y
write_coord(origin[2]-20) //position.z
write_coord(origin[0]) //axis.x
write_coord(origin[1]) //axis.y
write_coord(origin[2]+200) //axis.z
write_short(g_sprite) //sprite index
write_byte(0) //starting frame
write_byte(1) //frame rate in 0.1's
write_byte(6) //life in 0.1's
write_byte(10) //line width in 0.1's
write_byte(1) //noise amplitude in 0.01's

if ( user_has_weapon( id, CSW_AWP ) && user_has_weapon( id, CSW_DEAGLE ) )
{
write_byte(0); // r
write_byte(255); // g
write_byte(0); // b
}
else if ( user_has_weapon( id, CSW_AWP ) )
{
write_byte(255); // r
write_byte(0); // g
write_byte(0); // b
}
else
{
write_byte(0); // r
write_byte(0); // g
write_byte(255); // b
}

write_byte(255); // brightness
write_byte(0); // scroll speed in 0.1's
message_end();
}

xTr3m3r
01-26-2017, 13:37
Thank you.

Here is without weapons:

#include <amxmodx>
#include <amxmisc>
#include <fakemeta>
#include <cstrike>
#include <fun>

#define MAX_PLAYERS 32
#define UPDATE_INTERVAL 2.0
#define TID_TIMER 9124

new g_snd_path[] = "buttons/blip1.wav"
new g_sprite_path[] = "sprites/white.spr"

new bool:g_got_beacon[MAX_PLAYERS+1]
new g_max_players
new Float:g_t_time
new g_timer_entid
new g_sprite

public plugin_init()
{
register_plugin("Beacon", "1.0", "Sylwester");

g_max_players = get_maxplayers();
create_timer();
}

public plugin_precache()
{
precache_sound(g_snd_path)
g_sprite = precache_model(g_sprite_path)
}

public client_connect(id)
{
g_got_beacon[id] = false
}

public client_PreThink(id)
{

new players[32], num;
get_players(players, num, "ae", "TERRORIST")

if(is_user_alive(id) && num == 1 && cs_get_user_team(id) == CS_TEAM_T)
{
g_got_beacon[id] = true
}
else
{
g_got_beacon[id] = false
}
}

public create_timer()
{
g_timer_entid = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString,"info_target"))

if(pev_valid(g_timer_entid))
{
set_pev(g_timer_entid, pev_classname, "beacon_timer")
global_get(glb_time, g_t_time)
set_pev(g_timer_entid, pev_nextthink, g_t_time + UPDATE_INTERVAL)
register_forward(FM_Think,"fwd_Think")
}
else
{
log_amx("Warning: Failed to create timer entity, using task instead")
set_task(UPDATE_INTERVAL, "timer_cycle", TID_TIMER, "", 0, "b")
}
}


public fwd_Think(Ent){
if(Ent != g_timer_entid)
return FMRES_IGNORED
g_t_time += UPDATE_INTERVAL
set_pev(Ent, pev_nextthink, g_t_time)
timer_cycle()
return FMRES_IGNORED
}


public plugin_unpause()
{
if(pev_valid(g_timer_entid))
{
global_get(glb_time, g_t_time)
g_t_time += UPDATE_INTERVAL
set_pev(g_timer_entid, pev_nextthink, g_t_time)
}
}


public timer_cycle()
{
static id
for(id=1; id<=g_max_players; id++)
if(g_got_beacon[id] && is_user_alive(id))
show_beacon(id)
}


public show_beacon(id)
{
static origin[3]
emit_sound(id, CHAN_ITEM, g_snd_path, 1.0, ATTN_NORM, 0, PITCH_NORM)

get_user_origin(id, origin)
message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
write_byte(TE_BEAMCYLINDER)
write_coord(origin[0]) //position.x
write_coord(origin[1]) //position.y
write_coord(origin[2]-20) //position.z
write_coord(origin[0]) //axis.x
write_coord(origin[1]) //axis.y
write_coord(origin[2]+200) //axis.z
write_short(g_sprite) //sprite index
write_byte(0) //starting frame
write_byte(1) //frame rate in 0.1's
write_byte(6) //life in 0.1's
write_byte(10) //line width in 0.1's
write_byte(1) //noise amplitude in 0.01's

write_byte(0); // r
write_byte(0); // g
write_byte(255); // b

write_byte(255); // brightness
write_byte(0); // scroll speed in 0.1's
message_end();
}

For anyone searching the same :)

HamletEagle
01-26-2017, 13:57
Change prethink to Ham_Killed, since he wants the effect for the last terrorist alive.