AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   New Plugin Submissions (https://forums.alliedmods.net/forumdisplay.php?f=26)
-   -   Bomb Status [ V 1.7 ] (https://forums.alliedmods.net/showthread.php?t=241320)

HamletEagle 06-01-2014 10:50

Bomb Status [ V 1.7 ]
 
3 Attachment(s)

Bomb Status 1.7
Release: 01.06.2014 | Last Update: 01.07.2016

Table of Contents

Description top


Shows a hud message with the following information about the bomb. It also has
a configuration file: bombstatus_configuration.ini
Read below to understand how to use them.

It's able to show this info:
  • Bomb Planted : Yes/No
  • BombSite : A/B/No
  • Status : Dropped/Carried/Bombed/Planting
  • Carrier/Planter : Name/ No ( if the bomb was planted will show Planter: Name )
  • Distance To Bomb: Distance
  • Explosion in: Time
  • Defuse: DefuseKit/Default

I think that it's need a better explanation:
  • 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, Planting if the bomb is in planting process, Bombed if bomb exploded.
  • 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 it won't be displayed
  • Explosion in: if planted will display display this new info with the time until explosion. If bomb exploded, it won't display it any longer.
  • Defuse: if the player that defuse the bomb has a defuse kit it will show DefuseKit, else will show defult. When defuse proces stop,this info will dissapear.

This will also provide a command to control hud, in case it produce lag for you or sth like this.
  • Turn hud on.
  • Turn hud off.

Because some maps have reversed* bomb sites you may need to add this map in bombstatus_configuration.ini, under the [SWAPPED MAPS] key, if not plugin won't work correctly or use the menu so you can configure directly in game.
Also, if you find bugs please reply here with this info: plugin version, map name, problem description and others plugin that use hud messages or interact with the bomb.

Requirements top


Please make sure you have all the requirements:
  • Okapi module.
  • Cvar Util module.
  • An updated server without dproto.
    It may work into your outdated server with dproto, but if it doesn't, I won't help you.
Installation top

To install the plugin:
  1. Download the resources from this post. You need to get the source and compile it locally.
  2. Put bomb_status.amxx in addons/amxmodx/plugins
  3. Open addons/amxmodx/configs/plugins.ini and add at the end of this file bomb_status.amxx
  4. You can put the sma file into addons/amxmodx/sources but this is not mandatory.
  5. Put bombstatus.txt into [tt]addons/amxmodx/data/lang[/tt
  6. Restart the server/change map.

To install okapi:
  1. Download okapi_bin.zip and extrat the arhive.
  2. Copy okapi_amxx.dll/okapi_amxx_i386.so depending on your operation system into addons/amxmodx/modules
  3. The module will be auto-loaded, you don't need to add it into modules.ini

To install Cvar Util:
  1. Download cvar-util-files-1.6.zip and extrat the arhive.
  2. Copy cvar_util_amxx.dll/cvar_util_amxx_i386.so depending on your operation system into addons/amxmodx/modules
  3. The module will be auto-loaded, you don't need to add it into modules.ini

To compile locally:
  • First way:
    1. Download AMX Mod X for windows/linux from main site
    2. Extract somewhere the arhive and remember the folder!
    3. Copy the content from include folder from the okapi arhive into addons/amxmodx/scripting/include( in the folder created in the step 2 ).
    4. Download the source of the plugin( bomb_status.sma) from this post and drag it over the compile.exe(scripting folder from the arhive created at step 2)
    5. It will create a new folder called compiled. Open it and you will find your compiled plugin( bomb_status.amxx )
  • Second way:
    1. Go to http://spider.limetech.org/
    2. Copy/paste the code from the .sma file into the website.
    3. Under the big blue Compile button you see a box which Drop .inc files here
    4. Then press Compile and Download

If you don't know/want to compile locally, download the attached AMXX file(not the one from Get Plugin link).
Commands top

I've added the fallowing command:
  • say /ch_hud_state: Turn hudmessage on/off with say
  • say_team /ch_hud_state: Turn hudmessage on/off with say_team
  • bombstatus_cfgmenu: Open configuration menu so you won't need to edit the cfg file manually.

Write it once and it will disable the hud, write it after the spam protection(see below) and it will turn it on again.

A spam protection exists and it can be controled by cvar.
Cvars top


This cvars allow you to turn on/off most of the features and to control the way in which the plugin works.
  • bomb_status_team:
    • Control which team see the hud.
    • 0 - everyone can see it | 1 - only t | 2 - only ct
  • hud_r_color | hud_g_color | hud_b_color:
    • Allow you to change default hud color
    • Default: r - 0 | g - 255 | b - 85
    • Colors are in rgb format ( use paint to select a new one if you don't know them )
  • bomb_status_commands:
    • Allow you to enable/disable hud commands.
    • 0 - disabled | 1 - enable
  • bomb_status_c_spamtime:
    • Change the delay for the commands(the spam protection)
    • Default: 10 - this mean that the player needs to wait 10 seconds to use the command again.
  • bomb_status_logs:
    • Allow you to disable/enable logs.
    • At certain times, plugin will write some messages into server console, to let you know what happen.
    • 0 - disable | 1 - enable
  • bomb_status_disable_tp:
    • Allow to restrict teleportation after bomb was planted
    • Admin may abuse and teleport directly in order to defuse
    • 0 - disable | 1 - enable

Configuration top


1.Adding a map as swapped:
You have two ways of adding a map as swapped, but firstly let's find out what a swapped map is. Some maps have reversed bombsite so it means that instead of A it will show B and instead of B will be A.

1.1 Add the map into the file:
  • Go to addons/amxmodx/configs/bombstatus_configuration.ini
  • Under the [SWAPPED MAPS] key add your map name as it is in your maps dir.
  • Change map to apply the changes.
1.2 Using the configuration menu
  • While in game write bombstatus_cfgmenu
  • If the map is detected as swapped you will have the option to make it Normal. If it's detected as normal you will have an option to make it Swapped
  • Under menu title you will have current map status.
  • Use Teleport menu to go in A/B as they are detected by the plugin so you can check if the current config si correct. If not, reverse options.

2.Adding a map as blocked:
Open addons/amxmodx/configs/bombstatus_configuration.ini and under BLOCKED MAPS section add your map name and change the map to apply changes.

To acces the menu you need ban acces(flag "d") but it can be changed:
PHP Code:

const AdminAcces ADMIN_BAN 

Credits top
ChangeLog top
  • 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
    • Arrange the code
    • Added swapped_maps.ini file
  • 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.
    • 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.
  • V 0.9:
    • Fixed a bug when a new round start.
    • Fixed a bug when you kill yourself.
    • Added a new bomb status: Bombed
    • Fixed a bug with sv_restart 1
    • Added a new status: Planting
    • Added a new hud info : Explosion in.
  • V 1.0:
    • Fixed a bug with planting status.
    • Changed hud position.
    • Some informations are displayed only when needed.
    • Removed useless checks.
    • Added a new info : Defuse : DefuseKit/ Default
    • Fixed a typo: Distante instead of Distance
  • V 1.1:
    • Renamed some variables
    • Added some comments
    • Fixed a possible bug in the very first round
    • Now using bitsum for booleans with 33 cells
    • Arranged the code
  • V 1.2:
    • Added all Hornet's improvements.
    • When players num is 0,hud is canceled.
  • V 1.3:
    • A lot of changes in terms of code
    • Merged the two configuration file into one.
    • Fixed some potential bugs.
  • V 1.4:
    • Added configuration menu
    • Improved planting status detection.
  • V 1.6:
    • Fixed defusing status, not it's working properly
    • Fixed a bug when time remaining untile explosion is not properly updated
    • Fixed a bug when, on some maps, teleport function will stuck you into the ground or into some boxes
    • Fixed a bug with removing line from file when tempfile path get wrong
    • Fixed a bug with adding lines to file when it leave a space after last line and the new added
    • Fixed registering twice Ham_WeaponIdle
    • Improved code readability
    • Fixed a wrong key in lang file
    • Added new translations into ml file
    • Now mp_c4timer is cached with CvarCache native
    • Removed treemap search
    • Teleport menu is now global
    • Teleport menu is not destroyed in plugin_end
    • Optimized FindBombSites function, now with 50% less native calls by doing some tricks
    • Fixed defusing status won't ever show up into hud
    • Fixed defusing status doesn't dissappear when defusion is canceled
    • Now using just a command to turn hud on/off, more convenient
    • Added check to see if c4 is valid in AddPlayerItem
    • Fixed origin swapping, now it's properly implemented
    • Fixed throwable c4 being detected as running even if not.
  • V 1.7:
    • Fixed a bug when planting status is not removed on GameCommencing event or NewRound
    • Fixed a bug with teleport function where on small bombsite it fails.
    • Fixed a bug with teleport function where, on some maps it teleport you above ground and you get fall damage
    • Fixed bugs with bombsite detection.
    • Added detection by infodecal entities which never fail. If no infodecals, it uses the standard method.
    • Added teleportation restrictions in freezetime and after bomb is planted(by cvar)
    • Fixed a bug when teleport function would transfer you to wrong bomb site.
    • Code cleaned and improved.

red_bull2oo6 06-01-2014 11:26

Re: Bomb Status
 
sweet, nice idea..
i have no servers right now.. but when i will, i'll use it for sure.

LE: you can make a global task to show the hud, and loop all players instead individual task..

HamletEagle 06-01-2014 11:38

Re: Bomb Status
 
Quote:

Originally Posted by red_bull2oo6 (Post 2145326)
sweet, nice idea..
i have no servers right now.. but when i will, i'll use it for sure.

LE: you can make a global task to show the hud, and loop all players instead individual task..

Thx for your oppinion. I'm going to make a global task or a thinking entity.

wickedd 06-01-2014 11:41

Re: Bomb Status
 
If the bomb is planted, how can someone be carrying it?

HamletEagle 06-01-2014 11:53

Re: Bomb Status
 
Quote:

Originally Posted by wickedd (Post 2145337)
If the bomb is planted, how can someone be carrying it?

If the bomb is planted it will display the name of the player that planted it. Read the description better before asking something. If you saw this in the one of the image, they are older ( 0.1 version ) , I'll make new photos when I have time.

ArabicMan 06-01-2014 11:59

Re: Bomb Status
 
The message will be appear permanently?

wickedd 06-01-2014 12:01

Re: Bomb Status
 
1 Attachment(s)
I read the description. The picture you posted shows something different, that's why I asked the question.

HamletEagle 06-01-2014 12:04

Re: Bomb Status
 
Quote:

Originally Posted by wickedd (Post 2145354)
I read the description. The picture you posted shows something different, that's why I asked the question.

The picture is very old ( 0.1 version ). Now everything is ok, but I have to make new photos, when I have time.

Quote:

Originally Posted by ArabicMan (Post 2145351)
The message will be appear permanently?

Yes, it will be permanent, but I tested it on a 32/32 server with bots and it doesn't produce lag. If you have a sugestions, when it should not be displayed I'm glad to hear it.

Backstabnoob 06-01-2014 12:12

Re: Bomb Status
 
  • PHP Code:

    set_task 0.1 "ShowHud" id 

  • Why? You're displaying the message for 12 seconds. There's absolutely no reason to reshow it every 0.1 seconds. Also it will look really silly with director hud messages, because they have no channels and they will just overlap one over another so after those 12 seconds you'll have a big nice block of color if the content of the message changes a lot.
  • Also, cache the hud sync objects.
  • In GetName, check if the user is connected to the server. You don't even have to use this, just remove it entirely and get the name directly in the HUD function, just cache the bomb ent ID.
  • Also, instead of copying the contents of dhudmessage.inc, just leave it in the includes and point to it in your thread in case it gets updated or something.

I didn't look thoroughly but that's what you should start with if you want this to get approved.

ArabicMan 06-01-2014 12:14

Re: Bomb Status
 
It will make lag you can make cvar that control of that i can make it permanently or every x sec i think it will be better.

Backstabnoob 06-01-2014 12:17

Re: Bomb Status
 
Quote:

Originally Posted by ArabicMan (Post 2145368)
It will make lag you can make cvar that control of that i can make it permanently or every x sec i think it will be better.

What's the point of your post?

HamletEagle 06-01-2014 12:23

Re: Bomb Status
 
Quote:

Originally Posted by Backstabnoob (Post 2145365)
  • PHP Code:

    set_task 0.1 "ShowHud" id 

  • Why? You're displaying the message for 12 seconds. There's absolutely no reason to reshow it every 0.1 seconds. Also it will look really silly with director hud messages, because they have no channels and they will just overlap one over another so after those 12 seconds you'll have a big nice block of color if the content of the message changes a lot.
  • Also, cache the hud sync objects.
  • In GetName, check if the user is connected to the server. You don't even have to use this, just remove it entirely and get the name directly in the HUD function, just cache the bomb ent ID.
  • Also, instead of copying the contents of dhudmessage.inc, just leave it in the includes and point to it in your thread in case it gets updated or something.

I didn't look thoroughly but that's what you should start with if you want this to get approved.

1. I need to update it every 0.1 second, in order to catch immediately every change ( bomb dropped,planted etc ). But I can't make the hud to stay only for 0.1 seconds, it will cause a awful bug. I think that it should remain like this.
2. Will be added.
3. I'll add the check and when I have time will remove GetName.
4. Some peoples are lazy, if the plugin can't be directly compiled they won't use it.
5. Some peoples wanted it to be with dhud, so I maked a cvar. It will remain as it is.

ArabicMan I really don't see the reason to do this.

ArabicMan 06-01-2014 12:29

Re: Bomb Status
 
Quote:

Originally Posted by Backstabnoob (Post 2145370)
What's the point of your post?

I want to control message with cvar like what i said "Message appear permanently or every x sec"
the point that i manage to control this. (Sorry for my bad english)

YamiKaitou 06-01-2014 12:34

Re: Bomb Status
 
Quote:

Originally Posted by HamletEagle (Post 2145375)
1. I need to update it every 0.1 second, in order to catch immediately every change ( bomb dropped,planted etc ). But I can't make the hud to stay only for 0.1 seconds, it will cause a awful bug. I think that it should remain like this.

Then decrease the amount of time you hold the message. 0.1 seconds is not needed, every 1 second would be better

Quote:

4. Some peoples are lazy, if the plugin can't be directly compiled they won't use it.
Poor excuse.

HamletEagle 06-01-2014 12:46

Re: Bomb Status
 
Quote:

Originally Posted by YamiKaitou (Post 2145383)
Then decrease the amount of time you hold the message. 0.1 seconds is not needed, every 1 second would be better


Poor excuse.

Wrong, 1.0 it's not ok,but I decreased the amount of time the hud is hold. It's not an excuse, adding a link to a file will not make my life better or not, but this is the truth, peopels are lazy.

When I finish all this changes I'll release a new version. Thanks all of you for this advices.

Backstabnoob 06-01-2014 12:55

Re: Bomb Status
 
As for that "terrible bug" you're talking about, you most likely mean flickering (which will happen with dhud). The solution to that is simple - reshow the message each second and set the holdtime to 1.1 seconds.

DonKisgot 06-01-2014 14:37

Re: Bomb Status
 
Super Useful Suggestion (I want credit for this awesome suggestion :D ) ;

Bomb Status For EVERYONE WHO İS DEAD or SPECTATING ?

will you do this please ? I want CT's can see if they are DEAD :)

HamletEagle 06-02-2014 12:44

Re: Bomb Status
 
UPDATE TO 0.5

All changes suggested by Backstabnoob are now done. I firstly want to make the actual code "perfect", after this I'm going to add another stuffs.

Adventx 06-04-2014 11:56

Re: Bomb Status
 
good job, it's a genial idea!
Nice, thaks! ;)

Backstabnoob 06-04-2014 12:47

Re: Bomb Status
 
More thoroughly:

You should properly prefix your variables. If you have these as globals: new g_iTeam, BombPlanted, iStatus, hud_type, g_fBombSitesOrigins then it makes your code really confusing. Stick to one style.

PHP Code:

g_iBombSites], Floatg_fBombSitesOrigins][ ], Floatg_fBombOrigins

Why 3? I don't know if there can be more than two bomb sites, but you never work with the first cells anyway. You just put everything into 1 and 2 instead of 0 and 1.

PHP Code:

if ( ! MapHasBombSites )
    return; 

Just pause the plugin if the map doesn't have bombsites.

PHP Code:

new iEntities 
iEntities ] =  engfunc(EngFunc_FindEntityByString, -"classname""func_bomb_target")     
iEntities ] =  engfunc(EngFunc_FindEntityByString,-"classname""info_bomb_target"

First off, this won't even work at all because iEntities[ 1 ] and iEntities[ 2 ] will have the same entity index because you start from -1 in both cases.

Also, this step is completely useless because you do it here anyway:
PHP Code:

if ( IsMapSwapped ) {
    
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" )


PHP Code:

if ( ! Bomb || ! g_iBombSites ] && ! g_iBombSites ]  ) //if we are here,we should have a valid bomb,but let's check again
    
return ; 

Completely remove this and pause the plugin if there are no bombsites as I said earlier.

PHP Code:

public client_putinserver id 
    if ( 
MapHasBombSites set_task 3.0 "ShowHud"id )

public 
client_disconnect id )
    
remove_task id 

Remove this completely. Initialize the ShowHud task at plugin_init and loop through all players in the ShowHud function.

PHP Code:

if ( BombPlanted )  
    
formatex HudMessagesizeof HudMessage ) -"Bomb Planted :%s^nBombSite: %s^nStatus:Planted^nPlanter:%s^nDistante To Bomb: %i",BombPlanted == "Yes" "No",iValue == "A" :"B"szPlanterNamefloatround get_distance_f (PlayerOriginsg_fBombOrigins) / 100 ) )
    
if ( !
BombPlanted ) {
    if ( 
iStatus == )
        
formatex HudMessagesizeof HudMessage ) -"Bomb Planted :%s^nBombSite: No^nStatus:%s ^nCarrier:No^nDistante To Bomb: No",BombPlanted == "Yes" "No",iStatus == "Dropped" "Carried" )
    else
        
formatex HudMessagesizeof HudMessage ) -"Bomb Planted :%s^nBombSite: No^nStatus:%s^nCarrier:%s^nDistante To Bomb:No",BombPlanted == "Yes" "No",iStatus == "Dropped" "Carried" ,szName1)        


Instead of another if( ) just do an else statement, that's what it's for.
Also, you check for iStatus and BombPlanted in the formatex( ) native even though you already know what these are.


PHP Code:

set_task 0.1 "ShowHud" id )
set_hudmessage(0255850.00.1506.05.0

Again, this is wrong. As I said earlier, just do set_task( 1.0, "ShowHud", .flags = "b" ) in plugin_init. 0.1 seconds is AN OVERKILL. Also you probably didn't read what we said earlier, but change the holdtime (5.0) to 1.1.

PHP Code:

id1 EntOwner 

You don't need this, just work with EntOwner directly. Also, why do you have szName1 and szPlanterName? You can just cache both of these into one string.

Backstabnoob 06-04-2014 15:00

Re: Bomb Status
 
Unapproved until you decide to change everything I said. Your arguments don't make sense and I'm not going to reply to each one of them.

Edit: Heck I will.

Quote:

I work with 1 and 2, I don't see any problem here, it's my own choose.
It's not. You don't seem to very well understand how programming and memory initialization works. When you initialize an array like this: new Array[ 3 ], it reserves 3 cells for it. Array[ 0 ], Array[ 1 ], Array[ 2 ]. What you're doing is you initialize an array with 3 cells but then only use two of them, 1 and 2. Instead you can initialize an array with TWO cells instead of THREE and use Array[ 0 ] and Array[ 1 ].

Quote:

It just stop the function, I don't think this is a problem, if I pause it or not.
The problem is that your code will be executed even if it doesn't need to. Pause the plugin as I said.

Quote:

Better read the source, you will understand why I'm checking them.
Read what I said again. You already know that iStatus == 1 because you do if( iStatus == 1 ). But in the formatex native, you do this again:
PHP Code:

iStatus == "Dropped" "Carried" 

Why? It will always be "Dropped", because iStatus is always 1 in your check. It will always be "Carried" in the else statement.

Quote:

HoldTime to 1.1 is not ok, it will cause flikering ( idk if I writted it correctly, but you should understand ).
It won't. 1.0 would cause flickering, 1.1 doesn't.

Quote:

My own choose again, don't affect the performances.
Again, it's not your own "choose", you're initializing a variable when you don't have any reason to, so please change that.



In the end, it just sounds to me like you're lazy and you keep trying to find excuses as to why not to change your plugin. Thereby, as I said, this will remain in the Unapproved section until you change EVERYTHING I said. Or at least until you find a decent argument to back it up that's not "it's my own choose."

ArthHa 06-11-2014 11:44

Re: Bomb Status
 
Well, this plugin adds +100 ping.:D

HamletEagle 06-11-2014 11:44

Re: Bomb Status
 
Ok, done with everything. But 1.1 ( hold time ) cause flickering, you should test before giving this advice again.

Quote:

Originally Posted by ArthHa (Post 2149866)
Well, this plugin adds +100 ping.:D

ArtHa check now, this problem should be solved.

Backstabnoob 06-11-2014 11:56

Re: Bomb Status
 
I tested 1.1, in fact I'm using it right now on my test server and it works without any issues. Like I said, dhud doesn't remove the message if you reshow it, because it doesn't use channels. The messages will be stuck one on another. This doesn't cause issues if the text doesn't change, but if it does it looks stupid, try it out. If 1.1 has issues, you can try 1.2, etc. 3.1 is still too high for no reason.

PHP Code:

switch ( get_pcvar_num g_iTeam ) ) { 

get_players has support for getting the list of players based on a team. You should check the value of the cvar before the for( ) loop and based on it call get_players with different arguments. You can simply use something like this:

PHP Code:

switch( get_pcvar_numg_iTeam )
{
   case 
1get_playersiPlayersiPlayersNum"ce""TERRORIST" )
   case 
2get_playersiPlayersiPlayersNum"ce""CT" )
   default: 
get_playersiPlayersiPlayersNum"c" )


Also cache this value before the loop:
PHP Code:

get_pcvar_num g_iHud_type 

Other than that your code seems fine now, moving back to New Plugin Submissions.

HamletEagle 06-11-2014 12:16

Re: Bomb Status
 
Ok, I know about get_players, but I was too lazy to do this, will be done in next version. For me, 1.1 cause issues,will try with another values.

Thx for moving it back to new plugins submissions and for everything that I learned from you.

HamletEagle 06-13-2014 13:06

Re: Bomb Status
 
UPDATE TO 0.7

Code:

V 0.7:
+ Removed dhudmessages, now only normal hud messages are used.
+ Remove hud type cvar.
+ Optimized show hud function

This are new changes that I made.

ArabicMan 06-13-2014 14:34

Re: Bomb Status
 
Quote:

Originally Posted by HamletEagle (Post 2151130)
UPDATE TO 0.7

Code:

V 0.7:
+ Removed dhudmessages, now only normal hud messages are used.
+ Remove hud type cvar.
+ Optimized show hud function

This are new changes that I made.

I won't use it because it will lag my server and clients too try to do this
Quote:

Originally Posted by ArabicMan (Post 2145379)
I want to control message with cvar like what i said "Message appear permanently or every x sec"


Backstabnoob 06-13-2014 14:39

Re: Bomb Status
 
No it won't lag your server.

HamletEagle 06-13-2014 14:49

Re: Bomb Status
 
Quote:

Originally Posted by ArabicMan (Post 2151163)
I won't use it because it will lag my server and clients too try to do this

Ok, then don't use it. Anyway, I'm thinking to make a cvar for what you want, to make you happy, but THIS WON'T PRODUCE LAG , it's tested...

ArabicMan 06-14-2014 03:26

Re: Bomb Status
 
Quote:

Originally Posted by HamletEagle (Post 2151174)
Ok, then don't use it. Anyway, I'm thinking to make a cvar for what you want, to make you happy, but THIS WON'T PRODUCE LAG , it's tested...

It will be good if you make this cvar also add color cvar to control it all those make your plugin better.

HamletEagle 06-15-2014 08:11

Re: Bomb Status
 
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.

EthicalHacker007 06-15-2014 09:47

Re: Bomb Status
 
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.

HamletEagle 06-15-2014 09:53

Re: Bomb Status
 
Quote:

Originally Posted by EthicalHacker007 (Post 2152064)
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 :)

ArabicMan 06-15-2014 10:59

Re: Bomb Status
 
Quote:

Originally Posted by HamletEagle (Post 2152026)
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?

HamletEagle 06-15-2014 11:09

Re: Bomb Status
 
Quote:

Originally Posted by ArabicMan (Post 2152087)
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.

ArabicMan 06-15-2014 11:12

Re: Bomb Status
 
Now it's better and i can use it GREAT JOB.

EthicalHacker007 06-16-2014 12:39

Re: Bomb Status
 
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

HamletEagle 06-16-2014 12:48

Re: Bomb Status
 
Quote:

Originally Posted by EthicalHacker007 (Post 2152697)
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 :(

EthicalHacker007 06-17-2014 08:30

Re: Bomb Status
 
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

HamletEagle 06-17-2014 09:13

Re: Bomb Status
 
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.


All times are GMT -4. The time now is 16:26.

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