Raised This Month: $ Target: $400
 0% 

[Help] WalkGuard Block Bombsites


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
LegacyCode
Member
Join Date: Apr 2017
Old 05-24-2017 , 06:33   [Help] WalkGuard Block Bombsites
Reply With Quote #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_CountCTsg_HudBombsiteBlocked,
    
g_BlockBombsiteStr[2
PHP Code:
public plugin_precache() {
    [...]
    
g_HudBombsiteBlocked CreateHudSyncObj()

Modified DrawLine
PHP Code:
public draw_block_line(Float:x1Float:y1Float:z1Float:x2Float:y2Float:z2color[3]) {
    new 
start[3]
    new 
stop[3]

    
start[0] = floatroundx1 )
    
start[1] = floatroundy1 )
    
start[2] = floatroundz1 )

    
stop[0] = floatroundx2 )
    
stop[1] = floatroundy2 )
    
stop[2] = floatroundz2 )

    
message_beginMSG_BROADCASTSVC_TEMPENTITY )

    
write_byteTE_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_shortspr_dot )

    
write_byte)    // framestart
    
write_byte)    // framerate
    
write_byte)    // life in 0.1's
    
write_byte25 )    // width
    
write_byte)     // noise

    
write_bytecolor[0] )   // r, g, b
    
write_bytecolor[1] )   // r, g, b
    
write_bytecolor[2] )   // r, g, b

    
write_byte200 )      // brightness
    
write_byte)       // 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(entitypev_originpos)

    new 
Float:mins[3], Float:maxs[3]
    
pev(entitypev_minsmins)
    
pev(entitypev_maxsmaxs)

    
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_Playersa_Players[32]
    
get_playersa_Playersn_Players )

    
// reset
    
g_CountCTs 0
    g_HasBombsiteBlock 
false

    
for ( new in_Playersi++ )
    {
        if ( 
cs_get_user_team(a_Players[i]) == CS_TEAM_CT )
            
g_CountCTs++
    }

    
g_BlockBombsite = !(g_CountCTs >= MIN_CTS_BOMBSITE)

    for ( new 
imaxzonesi++ )
    {
        new 
zone[i]
        new 
zm pev(zZONEID)

        if ( 
ZONEMODE:zm == ZM_BLOCK_ALL_BOMBSITE_A || ZONEMODE:zm == ZM_BLOCK_ALL_BOMBSITE_B )
        {
            
g_HasBombsiteBlock true

            
if ( g_BlockBombsite )
            {
                
set_pevzpev_solidSOLID_BBOX )

                
remove_taskTASK_SHOW_BLOCK )
                
set_task0.2"show_zone_cross"TASK_SHOW_BLOCK z__"b" )

                if ( 
ZONEMODE:zm == ZM_BLOCK_ALL_BOMBSITE_A )
                    
formatexg_BlockBombsiteStrcharsmax(g_BlockBombsiteStr), "A" )
                else
                    
formatexg_BlockBombsiteStrcharsmax(g_BlockBombsiteStr), "B" )
            }
            else
            {
                
set_pevzpev_solidSOLID_NOT )

                if ( 
task_existsTASK_SHOW_BLOCK ) )
                    
remove_taskTASK_SHOW_BLOCK )
            }
        }
    }

    if ( 
g_BlockBombsite && n_Players && g_HasBombsiteBlock )
    {
        for ( new 
in_Playersi++ )
        {
            if ( !
is_user_connected(a_Players[i]) ) continue

            if ( 
is_user_alive(a_Players[i]) )
            {
                
set_hudmessage25500, -1.00.203.0HUD_BOMBSITE_DURATION0.51.0, -)
                
ShowSyncHudMsga_Players[i], g_HudBombsiteBlocked"%L"a_Players[i], "WALKGUARD_BLOCK_BOMBSITE_HUD"MIN_CTS_BOMBSITEg_BlockBombsiteStr )
            }
        }

        return
    }

    return

PHP Code:
public Event_RoundStart() {
    [...]
    
check_bombsite_availability()

PHP Code:
public ZoneTouch(playerzone) {
    [...]

    if ( 
ZONEMODE:zm == ZM_BLOCK_ALL_BOMBSITE_A || ZONEMODE:zm == ZM_BLOCK_ALL_BOMBSITE_B )
    {
        if ( 
g_BlockBombsite )
        {
            
client_printplayerprint_center"%L"player"WALKGUARD_BLOCK_BOMBSITE_PRINT"g_BlockBombsiteStrMIN_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.
LegacyCode is offline
 


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 10:34.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode