Raised This Month: $51 Target: $400
 12% 

Bomb Status [ V 1.7 ]


Post New Thread Reply   
 
Thread Tools Display Modes
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 06-15-2014 , 08:11   Re: Bomb Status
Reply With Quote #31

Code:
+ Added posibility to change hud color by cvar.
+ Added /hudon & /hudoff for turning hud on/off.
+ Added a spam protection for commands.
+ Added a new swapped map: de_train.
+ Added a new file where you can write on which map plugin should not run.
+ Moved all files in Bomb Status folder.
+ Added a cvar to enable/ disable commands
+ Added logs.
+ Added a cvar to control logs ( default 0 )
+ Optimized a bit ShowHud function.
This are new changes, now you can disable hud when you don't need it. I'm waiting for some feedbacks.
HamletEagle is offline
EthicalHacker007
Veteran Member
Join Date: May 2014
Old 06-15-2014 , 09:47   Re: Bomb Status
Reply With Quote #32

You should give credits to Backstabnoob as he suggested you many optimizations. Post style seems to be copied from Arkshine. Good job though. Will definitely test it when I get time and will post my results here.
__________________
EthicalHacker007 is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 06-15-2014 , 09:53   Re: Bomb Status
Reply With Quote #33

Quote:
Originally Posted by EthicalHacker007 View Post
You should give credits to Backstabnoob as he suggested you many optimizations. Post style seems to be copied from Arkshine. Good job though. Will definitely test it when I get time and will post my results here.
I think that I added credits, but see now that I don't. I'm waiting for your feedback

Last edited by HamletEagle; 06-15-2014 at 10:00.
HamletEagle is offline
ArabicMan
Veteran Member
Join Date: Feb 2014
Location: مصر
Old 06-15-2014 , 10:59   Re: Bomb Status
Reply With Quote #34

Quote:
Originally Posted by HamletEagle View Post
Code:
+ Added posibility to change hud color by cvar.
+ Added /hudon & /hudoff for turning hud on/off.
+ Added a spam protection for commands.
+ Added a new swapped map: de_train.
+ Added a new file where you can write on which map plugin should not run.
+ Moved all files in Bomb Status folder.
+ Added a cvar to enable/ disable commands
+ Added logs.
+ Added a cvar to control logs ( default 0 )
+ Optimized a bit ShowHud function.
This are new changes, now you can disable hud when you don't need it. I'm waiting for some feedbacks.
Good. You mean of make hud off that the plugin disabled?
ArabicMan is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 06-15-2014 , 11:09   Re: Bomb Status
Reply With Quote #35

Quote:
Originally Posted by ArabicMan View Post
Good. You mean of make hud off that the plugin disabled?
2 posibilites :
-just disable it for YOU with /hudoff ( every player can do this if the command is activated ). You can re-enable it with /hudon.
-add the map name in blocked_maps.ini and plugin wont run on that map.

Now you should be able to control it better.

Last edited by HamletEagle; 06-15-2014 at 11:11.
HamletEagle is offline
ArabicMan
Veteran Member
Join Date: Feb 2014
Location: مصر
Old 06-15-2014 , 11:12   Re: Bomb Status
Reply With Quote #36

Now it's better and i can use it GREAT JOB.
ArabicMan is offline
EthicalHacker007
Veteran Member
Join Date: May 2014
Old 06-16-2014 , 12:39   Re: Bomb Status
Reply With Quote #37

Tested this plugin. There's a bug / suggestion.
After I planted the c4 and after it's successful explosion. Planter: EH007 changed to Carrier: EH007. I think you should add this one
Code:
Status: Dropped/Carried/Bombed
I also found out a bug. Take 2 players. A and B. A has spawned with c4 on first round, now round starts after few seconds (5-7) I enter this cvar sv_restart 1 and game restarts. Now bomb carrier is B but still it shows A. Understood? When you restart the game the plugin doesn't update the info. Rest is fine.

Regards,
EH007
__________________
EthicalHacker007 is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 06-16-2014 , 12:48   Re: Bomb Status
Reply With Quote #38

Quote:
Originally Posted by EthicalHacker007 View Post
Tested this plugin. There's a bug / suggestion.
After I planted the c4 and after it's successful explosion. Planter: EH007 changed to Carrier: EH007. I think you should add this one
Code:
Status: Dropped/Carried/Bombed
I also found out a bug. Take 2 players. A and B. A has spawned with c4 on first round, now round starts after few seconds (5-7) I enter this cvar sv_restart 1 and game restarts. Now bomb carrier is B but still it shows A. Understood? When you restart the game the plugin doesn't update the info. Rest is fine.

Regards,
EH007
Thanks for testing, now I'm going to fix this.

PHP Code:
/*Copyleft 2014
Plugin thread: https://forums.alliedmods.net/showthread.php?t=241320

Bomb Status
========


Description: Shows a hud message with the following information about the bomb:

Bomb Planted : Yes/No
BombSite : A/B/No
Status : Dropped/Carried
Carrier/Planter : Name/ No ( if the bomb was planted will show Planter: Name )
Distance To Bomb: Distance/No

Let's explain better:

BombPlanted: if the bomb is planted, it will show Yes, otherwise it will show NO. 
BombSites: if the bomb is not planted will show No, otherwise it will show A / B. 
Status: will show Dropped if the bomb is on the ground, Carried if a player has the bomb.
Carrier: if the bomb is not on the ground will show the name of the player who has it, otherwise will show No. In the case which the bomb is planted , will shows the name of player who planted it. 
Distance To Bomb: if planted will display the distance, else will show NO.


Changelog:

V 0.1: 
+ Initial Release. 
V 0.2: 
+ Add two versions: dhud / HUD classic. 
+ Fix bug when name was displayed incorrectly.
V 0.3: 
+ Add cvar bomb_status_team (which them see the hud) 
+ Optimization for detecting the distance to the bomb site. 
V 0.4: 
+ Now there is only one version with HUD and dhud. 
+ Adding cvar bomb_hud_type 
+ Big  optimization for checking the distance between the bomb and the bomb site 
+ Arrange the code   
V 0.5:
+ Lowered the hold time for hud messages
+ Now HudSyncObjects are cached
+ Added is_user_connected check in GetName function
V 0.6:
+ Renamed almost all variables.
+ Now the plugin will be paused if we aren't running a map with bomb sites.
+ Removed some useless blocks of code.
+ Solved some problems with arrays.
+ Added a global task.
+ Fixed some problems in formatex.
+ Lowered the hold time for hud. 
+ Increased the task time ( now it's 1.0 ).
+ Removed an useless var in GetName stock.
+ Fixed a bug when bomb status is displayed incorrectly.
V 0.7:
+ Removed dhudmessages, now only normal hud messages are used.
+ Remove hud type cvar.
+ Optimized show hud function
V 0.8:
+ Added posibility to change hud color by cvar.
+ Added /hudon & /hudoff for turning hud on/off.
+ Added a spam protection for commands.
+ Added a new swapped map: de_train.
+ Added a new file where you can write on which map plugin should not run.
+ Moved all files in Bomb Status folder.
+ Added a cvar to enable/ disable commands
+ Added logs.
+ Added a cvar to control logs ( default 0 )
+ Optimized a bit ShowHud function.

*/

#include < amxmodx > 
#include < amxmisc >
#include < fakemeta > 
#include < engine > 
#include < csx >
#include < cstrike >

#define SPAM_TIME 10.0

new boolg_bMapHasBombSitesboolg_bIsMapSwappedboolg_bBombPlantedboolg_bHudOn 33 ], boolg_bBlocked 33 ],
boolg_bCommandsOn boolg_bBombExploded

new g_iBombSites ], g_iValue 0g_iStatus ,szName33 ] , g_iTeam g_HudSyncg_iFile  ] [ 128 ],
szPath 128 ], g_HudColor ],  g_iColor ] , g_iCommandsStatus g_iLogsStatus

new const g_szFileNames  [ ] [ ]   =  {
    
    
"swapped_maps.ini",
    
"blocked_maps.ini"
    
}
new const 
g_szFolderName    [ ]  =  "Bomb Status";

new 
Floatg_fBombSitesOrigins ] [ ] , Floatg_fBombOrigins ]

public 
plugin_init ( ) {
    
    
register_plugin "Bomb Status" "0.8" "HamletEagle" )
    
    
register_logevent("Logevent_BombDropped"3"2=Dropped_The_Bomb")
    
register_logevent("Logevent_BombCollected"3"2=Got_The_Bomb")
    
register_logevent("Logevent_SpawnedWithBomb"3"2=Spawned_With_The_Bomb")
    
register_logevent("Logevent_RoundEnd"2"1=Round_End"
    
    
register_event("HLTV""event_new_round""a""1=0""2=0")    
    
    
g_iTeam register_cvar "bomb_status_team" "0" )
    
    
/*
    0 - everyone can see the hud
    1 - only t can see the hud
    2 - only ct can see the hud
    
    */
    
    /* Color for hud in rgb format */
    
g_HudColor  ] = register_cvar "hud_r_color" "0" )
    
g_HudColor  ] = register_cvar "hud_g_color" "255" )
    
g_HudColor  ] = register_cvar "hud_b_color" "85" 
    
    
g_iCommandsStatus register_cvar "bomb_status_commands""1" )
    
/*
    0 - deactivated
    1- activated
    */
    
    
g_iLogsStatus register_cvar "bomb_status_logs" "0" )
    
/*
    0 - no logs
    1 - logs on
    */
    
    
    
g_HudSync =  CreateHudSyncObj ( ) 
    
    
set_task1.0"ShowHud"__"b" )
    
    
register_clcmd "say /hudon" "CmdHudOn" )
    
register_clcmd "say /hudoff" "CmdHudOff" )
}

public 
plugin_cfg ( ) {
    
    new 
Dir64 ];
    
get_configsdir Dirsizeof Dir ) - )
    
    
formatex szPath sizeof szPath ) -1"%s/%s"Dirg_szFolderName  );
    
    for ( new 
i++ )
        
formatex g_iFile [  ] , 127 "%s/%s"szPath g_szFileNames  ]);
    
    if ( ! 
dir_exists szPath ) )
        
mkdir szPath )
    
    if( ! 
file_existsg_iFile ]   )  )
    {
        
write_fileg_iFile ],  ";Here you will write the swapped maps." )
        
write_fileg_iFile ],  ";A map is swapped when it has inversed bomb site." )
        
write_fileg_iFile ],  ";If the plugin display incorectly the Bomb Site where the bomb is planted" )
        
write_fileg_iFile ],  ";add the map name here." )
        
write_fileg_iFile ],  "de_dust2" )
        
write_fileg_iFile ],  "de_chateau" )
        
write_file(g_iFile  ],  "de_train" )
        
    }
    
    if ( ! 
file_exists g_iFile ] ) ) 
    {
        
        
write_file(  g_iFile ],  ";Here you will write maps on which plugin is disabled" )
        
write_file(  g_iFile ],  ";If you want to restrict pluin in de_dust2 you will here" )
        
write_file(  g_iFile ],  ";de_dust2 ( without ; )" )
        
    }
    
    for ( new 
0  ++ )
        
g_iColor ] = get_pcvar_num g_HudColor ] )
    
    if ( 
get_pcvar_num (  g_iCommandsStatus ) ==)
        
g_bCommandsOn true
    
    LoadFile 
( )    
    
CheckAndFindBombSites ( )
    
}

public 
event_new_round ( ) {
    
    for ( new 
0  ++ )
        
g_iColor ] = get_pcvar_num g_HudColor ] )
    
    if ( 
get_pcvar_num (  g_iCommandsStatus ) ==)
        
g_bCommandsOn true    
    
    g_bBombExploded 
false
    
}


public 
LoadFile ( ) {
    
    new 
szMapName 33]
    
get_mapname szMapNamesizeof szMapName ) -)
    
    new 
szData128 ],szLine32 ]
    
    new 
iFile  ]
    
    for ( new 
++ ) {
        
        
iFile ]  =  fopeng_iFile ], "rt"  );    
        
        if ( 
iFile ] ) {
            
            while(  !
feofiFile ] )  ) 
            {
                
                
fgets(  iFile ] , szDatasizeof szData ) -1  )
                
                if( !
szData] || szData] == ';' || ( szData] == '/' && szData] == '/' ) ) 
                    continue
                
                
parseszDataszLinesizeof szLine ) -)
                
                if( 
equal(  szMapNameszLine )  ) {
                    
                    if ( 
== 0) {
                        
                        
g_bIsMapSwapped true        
                        
if ( get_pcvar_num g_iLogsStatus  ) == 
                            
log_amx "Detected a swapped map." )
                        
                        
                    }
                    else   {
                        
                        if ( 
get_pcvar_num g_iLogsStatus  ) == 
                            
log_amx "Plugin is restricted on this map, stopped" )
                        
                        
pause "a" )
                        
                    }
                    
                }
            }
            
        }
        
        
fclose iFile ] )
    }
    
}

public 
CheckAndFindBombSites ( ) {
    
    if ( 
g_bIsMapSwapped ) {
        
        
g_iBombSites ] = find_ent_by_class ( -"func_bomb_target" )
        
g_iBombSites ] = find_ent_by_class g_iBombSites ] , "func_bomb_target" )
        
    }
    
    else {
        
        
g_iBombSites ] = find_ent_by_class ( -"func_bomb_target" )
        
g_iBombSites ] = find_ent_by_class g_iBombSites ] , "func_bomb_target" )
        
    }
    
    if ( 
pev_valid g_iBombSites ] ) || pev_valid g_iBombSites ] ) )
        
g_bMapHasBombSites  true
    
    
if ( ! g_bMapHasBombSites ) {
        
        if ( 
get_pcvar_num g_iLogsStatus  ) == 
            
log_amx "No bomb sites, plugin paused" )
        
pause "a" )
        
        
    }
    if ( 
pev_valid g_iBombSites ] ) )
        
get_brush_entity_origin g_iBombSites ] , g_fBombSitesOrigins ] ) 
    
    if ( 
pev_valid g_iBombSites ] ) )
        
get_brush_entity_origin g_iBombSites ] , g_fBombSitesOrigins ] )
    
}

public 
bomb_planted planter ) {
    
    new 
Bomb find_ent_by_model ( -1"grenade""models/w_c4.mdl" )
    
    if ( 
pev_valid Bomb ) )
        
pev Bomb pev_origin g_fBombOrigins )
    
    
g_bBombPlanted true
    
    
new Float:iDist ]
    
    for ( new 
++ )
        
iDist ] = get_distance_f g_fBombOrigins g_fBombSitesOrigins ]  )
    
    if ( 
iDist ] < iDist ] ) 
        
g_iValue 1
    
else 
        
g_iValue 2
    
    get_user_name 
planter szNamesizeof szName ) -)
    
g_iStatus 1
}

public 
Logevent_BombDropped ( )  
    
g_iStatus 1

public Logevent_BombCollected ( ) {
    
    
set_task 0.1 ,"GetName" )
    
g_iStatus 0    
    
}

public 
Logevent_SpawnedWithBomb ( ) 
    
set_task 0.1 "GetName" )
    
public 
ShowHud (  ) {
    
    new 
Float:PlayerOrigins[3]
    new 
HudMessage 128 ]
    
    if ( ! 
g_bBombPlanted && ! g_bBombExploded ) {
        
        if ( 
g_iStatus == )
            
formatex HudMessagesizeof HudMessage ) -"Bomb Planted :No^nBombSite: No^nStatus:Dropped ^nCarrier:No^nDistante To Bomb: No" )
        
        else
            
formatex HudMessagesizeof HudMessage ) -"Bomb Planted :No^nBombSite: No^nStatus:Carried^nCarrier:%s^nDistante To Bomb:No",szName)    
        
    }
    
    if ( 
g_bBombExploded && ! g_bBombPlanted 
        
formatex HudMessagesizeof HudMessage ) -"Bomb Planted :No^nBombSite: No^nStatus:Bombed ^nCarrier:No^nDistante To Bomb: No" )
    
    
    
    
    static 
iPlayers32 ] , iPlayersNumidi
    
    
switch ( get_pcvar_num g_iTeam ) ) {
        
        case 
1get_playersiPlayersiPlayersNum"ce""TERRORIST" )
        case 
2get_playersiPlayersiPlayersNum"ce""CT" )
        default: 
get_playersiPlayers,iPlayersNum"c" )   
        
    }
    
    if( !
iPlayersNum )
        return;
    
    for( 
0iPlayersNumi++ )
    {
        
id iPlayers];
        
        if ( ! 
g_bHudOn id ] )
            continue 
        
        
        if ( 
g_bBombPlanted )  {
            
            
pev(idpev_originPlayerOrigins)
            
formatex HudMessagesizeof HudMessage ) -"Bomb Planted :Yes^nBombSite: %s^nStatus:Planted^nPlanter:%s^nDistante To Bomb: %i",g_iValue == "A" :"B"szNamefloatround get_distance_f (PlayerOriginsg_fBombOrigins) / 100 ) )
            
        }
        
        
        
set_hudmessageg_iColor ], g_iColor ], g_iColor ], 0.00.1506.03.0)
        
ShowSyncHudMsgid ,  g_HudSync  HudMessage)
        
    }
    
}

public 
client_putinserver id )
    
g_bHudOn id ] = true


public CmdHudOn id ) {
    
    if ( !
g_bCommandsOn )
        
client_print id print_chat "[ AMXX ] This command is disabled" )
    
    else if ( 
g_bBlocked id ] )
        
client_print id print_chat "[ AMXX ] You have to wait %.1f seconds to use this command again" SPAM_TIME )
    
    else if ( 
g_bHudOn id ] )
        
client_print id print_chat "[ AMXX ] Hud is already on" )
    
    else {
        
        
g_bHudOn id ] = true
        client_print 
id print_chat "[ AMXX ] You have just enabled your hud" )
        
g_bBlocked id ] = true
        set_task 
SPAM_TIME "RemoveBlock"id )
    }
}

public 
CmdHudOff id ) {
    
    if ( !
g_bCommandsOn )
        
client_print id print_chat "[ AMXX ] This command is disabled" )
    
    else if ( 
g_bBlocked id ] )
        
client_print id print_chat "[ AMXX ] You have to wait %.1f seconds to use this command again" SPAM_TIME )
    
    else if ( !  
g_bHudOn id ] )
        
client_print id print_chat "[ AMXX ] Hud is already off" )
    
    else {
        
        
g_bHudOn id ] = false
        client_print 
id print_chat "[ AMXX ] You have just disabled your hud" )
        
g_bBlocked id ] = true
        set_task 
SPAM_TIME "RemoveBlock"id )
    }
    
}

public 
RemoveBlock id )   {
    
    
g_bBlocked id ] = false
    remove_task 
id )
    
}

public 
bomb_explode ( ) {
    
    
g_bBombPlanted false
    g_bBombExploded 
true
}

public 
bomb_defused ( )
    
g_bBombPlanted false

public Logevent_RoundEnd ( ) {
    
    
g_bBombPlanted false    
    g_iStatus 

    
}

public 
GetName ( ) {
    
    new 
EntOwneriBomb
    iBomb 
=  find_ent_by_class(-1"weapon_c4")
    
    if ( 
pev_valid iBomb )  ) {
        
        
EntOwner pev(iBombpev_owner)    
        
        if ( 
is_user_connected EntOwner ) )    
            
get_user_name EntOwner szName sizeof szName ) -)    
        
    }
    
    

Test it, if it's working I will uplod it to main post. I can't test now

Last edited by HamletEagle; 06-16-2014 at 13:31.
HamletEagle is offline
EthicalHacker007
Veteran Member
Join Date: May 2014
Old 06-17-2014 , 08:30   Re: Bomb Status
Reply With Quote #39

Tested the above code. Yup, it fixed that "sv_restart" bug and also added "Bombed" status. GJ. But I've found more bugs.

1)
kill/suicide & bot kill


2)
Round End bug


Some suggestions
1)Planting Status
Current available statuses are
Code:
Status: Dropped/Carried/Bombed
so add one more.
Code:
Status: Dropped/Carried/Bombed/Planting
When the player is planting the bomb, the status will be changed to "Planting".

2)Time remaining for explosion
Currently your plugin shows the following info
Bomb planted
Bombsite
And blah blah.
Add this one
Explosion in: 35 means 35 seconds till c4 explosion. But don't show it always, this will only be shown when c4 is successfully planted. (After "the bomb has been planted" voice)

Finally there's a typo in your script and thread
It shows "Distante to bomb" and in your first post here

Quote:
I think that it's need a better explanation

Blah-blah.

Distance to Bomb: if planted will display the distance, else will show NO[/FONT
Regards,
EH007
__________________

Last edited by EthicalHacker007; 06-17-2014 at 08:33. Reason: BBCode
EthicalHacker007 is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 06-17-2014 , 09:13   Re: Bomb Status
Reply With Quote #40

Removed.


Firstly I really want to thank you for your interest in making this plugin better. I fixed/ added everything you told me, now I'm waiting for you to test.

Note that this is only a test version, code shoud not be fully optimized, I will do this when I'm sure that it's working correctly.

Last edited by HamletEagle; 06-17-2014 at 10:36.
HamletEagle is offline
Reply



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 11:21.


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