Member
|
05-24-2017
, 06:33
[Help] WalkGuard Block Bombsites
|
#1
|
Hello,
so, I made this: https://forums.alliedmods.net/showpo...&postcount=172
But I'm 99.9% certain that my edit is far from being good, so I would like to ask for help here
I know I'm still making dumb mistakes, please bear with me.
One player reported a "CL_Flush Entity Packet" error but I'm not sure if it's related to the edit I made.
Edited lines:
Global scope
PHP Code:
#define MIN_CTS_BOMBSITE 7 #define HUD_BOMBSITE_DURATION 4.0 #define TASK_SHOW_BLOCK 3000 new bool:g_BlockBombsite, bool:g_HasBombsiteBlock, g_CountCTs, g_HudBombsiteBlocked, g_BlockBombsiteStr[2]
PHP Code:
public plugin_precache() { [...] g_HudBombsiteBlocked = CreateHudSyncObj() }
Modified DrawLine
PHP Code:
public draw_block_line(Float:x1, Float:y1, Float:z1, Float:x2, Float:y2, Float:z2, color[3]) { new start[3] new stop[3]
start[0] = floatround( x1 ) start[1] = floatround( y1 ) start[2] = floatround( z1 )
stop[0] = floatround( x2 ) stop[1] = floatround( y2 ) stop[2] = floatround( z2 )
message_begin( MSG_BROADCAST, SVC_TEMPENTITY )
write_byte( TE_BEAMPOINTS )
write_coord(start[0]) write_coord(start[1]) write_coord(start[2])
write_coord(stop[0]) write_coord(stop[1]) write_coord(stop[2])
write_short( spr_dot )
write_byte( 1 ) // framestart write_byte( 1 ) // framerate write_byte( 4 ) // life in 0.1's write_byte( 25 ) // width write_byte( 0 ) // noise
write_byte( color[0] ) // r, g, b write_byte( color[1] ) // r, g, b write_byte( color[2] ) // r, g, b
write_byte( 200 ) // brightness write_byte( 0 ) // speed
message_end() }
Modified ShowZoneBox to work without editor (show to all players)
PHP Code:
public show_zone_cross(entity) { entity -= TASK_SHOW_BLOCK if (!pev_valid(entity)) return
new Float:pos[3] pev(entity, pev_origin, pos)
new Float:mins[3], Float:maxs[3] pev(entity, pev_mins, mins) pev(entity, pev_maxs, maxs)
mins[0] += pos[0] mins[1] += pos[1] mins[2] += pos[2] maxs[0] += pos[0] maxs[1] += pos[1] maxs[2] += pos[2]
// x draw_block_line(maxs[0], maxs[1], maxs[2], maxs[0], mins[1], mins[2], zone_color_red) draw_block_line(maxs[0], maxs[1], mins[2], maxs[0], mins[1], maxs[2], zone_color_red) draw_block_line(mins[0], maxs[1], maxs[2], mins[0], mins[1], mins[2], zone_color_red) draw_block_line(mins[0], maxs[1], mins[2], mins[0], mins[1], maxs[2], zone_color_red) // y draw_block_line(mins[0], mins[1], mins[2], maxs[0], mins[1], maxs[2], zone_color_red) draw_block_line(maxs[0], mins[1], mins[2], mins[0], mins[1], maxs[2], zone_color_red) draw_block_line(mins[0], maxs[1], mins[2], maxs[0], maxs[1], maxs[2], zone_color_red) draw_block_line(maxs[0], maxs[1], mins[2], mins[0], maxs[1], maxs[2], zone_color_red) // z draw_block_line(maxs[0], maxs[1], maxs[2], mins[0], mins[1], maxs[2], zone_color_red) draw_block_line(maxs[0], mins[1], maxs[2], mins[0], maxs[1], maxs[2], zone_color_red) draw_block_line(maxs[0], maxs[1], mins[2], mins[0], mins[1], mins[2], zone_color_red) draw_block_line(maxs[0], mins[1], mins[2], mins[0], maxs[1], mins[2], zone_color_red) }
Execute on each Event_RoundStart()
PHP Code:
check_bombsite_availability() { new n_Players, a_Players[32] get_players( a_Players, n_Players )
// reset g_CountCTs = 0 g_HasBombsiteBlock = false
for ( new i; i < n_Players; i++ ) { if ( cs_get_user_team(a_Players[i]) == CS_TEAM_CT ) g_CountCTs++ }
g_BlockBombsite = !(g_CountCTs >= MIN_CTS_BOMBSITE)
for ( new i; i < maxzones; i++ ) { new z = zone[i] new zm = pev(z, ZONEID)
if ( ZONEMODE:zm == ZM_BLOCK_ALL_BOMBSITE_A || ZONEMODE:zm == ZM_BLOCK_ALL_BOMBSITE_B ) { g_HasBombsiteBlock = true
if ( g_BlockBombsite ) { set_pev( z, pev_solid, SOLID_BBOX )
remove_task( TASK_SHOW_BLOCK + z ) set_task( 0.2, "show_zone_cross", TASK_SHOW_BLOCK + z, _, _, "b" )
if ( ZONEMODE:zm == ZM_BLOCK_ALL_BOMBSITE_A ) formatex( g_BlockBombsiteStr, charsmax(g_BlockBombsiteStr), "A" ) else formatex( g_BlockBombsiteStr, charsmax(g_BlockBombsiteStr), "B" ) } else { set_pev( z, pev_solid, SOLID_NOT )
if ( task_exists( TASK_SHOW_BLOCK + z ) ) remove_task( TASK_SHOW_BLOCK + z ) } } }
if ( g_BlockBombsite && n_Players > 0 && g_HasBombsiteBlock ) { for ( new i; i < n_Players; i++ ) { if ( !is_user_connected(a_Players[i]) ) continue
if ( is_user_alive(a_Players[i]) ) { set_hudmessage( 255, 0, 0, -1.0, 0.2, 0, 3.0, HUD_BOMBSITE_DURATION, 0.5, 1.0, -1 ) ShowSyncHudMsg( a_Players[i], g_HudBombsiteBlocked, "%L", a_Players[i], "WALKGUARD_BLOCK_BOMBSITE_HUD", MIN_CTS_BOMBSITE, g_BlockBombsiteStr ) } }
return }
return }
PHP Code:
public Event_RoundStart() { [...] check_bombsite_availability() }
PHP Code:
public ZoneTouch(player, zone) { [...]
if ( ZONEMODE:zm == ZM_BLOCK_ALL_BOMBSITE_A || ZONEMODE:zm == ZM_BLOCK_ALL_BOMBSITE_B ) { if ( g_BlockBombsite ) { client_print( player, print_center, "%L", player, "WALKGUARD_BLOCK_BOMBSITE_PRINT", g_BlockBombsiteStr, MIN_CTS_BOMBSITE ) } }
[...] }
I hope you guys can help make this code great again.
A message that only shows once after all bombsites are enabled again would be cool too, and I already had it working, but then I got lost again and ended up deleting it...
- LegacyCode
Last edited by LegacyCode; 05-24-2017 at 06:48.
|
|