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

AmmoPickUp / New-Round Money


Post New Thread Reply   
 
Thread Tools Display Modes
Plugin Info:     Modification:   Counter-Strike        Category:   Event Related       
MPNumB
Veteran Member
Join Date: Feb 2007
Location: Lithuania
Old 10-09-2010 , 00:42   AmmoPickUp / New-Round Money
Reply With Quote #1

Description:
This plugin hooks and blocks original AmmoPickup and Money messages, later sending them only once. This process makes information send from server to client smaller, saving internet speed. Also that may lower "Reliable channel overflowed" error. However it's not everything what this plugin does. For example if fixes a glitch of non-updated-to-hud Money message when ResetHUD is called. Also this plugin has a feature of showing your money difference at new round.


Requires:
FakeMeta
HamSandWich
Cstrike (optional)


Additional info:
Tested in Counter-Strike 1.6 with amxmodx 1.8.1. You can use cstrike module instead of to fakemeta converted function(s), by changing plugin config. "_cstrike" version of the plugin is the same as first one, except that it needs cstrike module to work properly.


Notes:
- This plugin sends Money and AmmoPickup messages 1 server-frame later than originally written ones would.
- For coders: I am using
Code:
message_begin(MSG_ONE_UNRELIABLE, ...);
write_long(...);
write_byte(...);
message_end();
instead of
Code:
emessage_begin(MSG_ONE, ...);
ewrite_long(...);
ewrite_byte(...);
emessage_end();
not just to lower the "overflowed" error, but also cause in second case scenario message doesn't reach the client for reasons unknown.


Warnings:
- Use only one of the plugins you find below, or configurate one the way you like.
- If you are using other plugins what need hooking of Money event in order to work properly, you may have to choose between two plugins for which one to use.
- If you are using other plugins what need hooking of AmmoPickup event in order to work properly, you may have to choose between two plugins for which one to use.


Change-Log:

* 1.3
- Fixed: Reworked 1.1 version update.

* 1.2
- Changed: Less CPU usage.

* 1.1
- Fixed: Showing 0$ at hlds after ResetHUD.

* 1.0
- First release.
Attached Thumbnails
Click image for larger version

Name:	new_round.JPG
Views:	356
Size:	5.7 KB
ID:	74965   Click image for larger version

Name:	bullets_buy.JPG
Views:	365
Size:	9.5 KB
ID:	74966   Click image for larger version

Name:	autobuy.JPG
Views:	339
Size:	9.9 KB
ID:	74967  
Attached Files
File Type: sma Get Plugin or Get Source (AmmoPickup_NewRoundMoney.sma - 746 views - 8.6 KB)
File Type: sma Get Plugin or Get Source (AmmoPickup_NewRoundMoney_cstrike.sma - 761 views - 8.6 KB)
__________________
Skill and no annoying bugs with fixed balance issues is my goal!
My approved plugins what don't show up in Approved List:
* Bomb/Death/CSS Radar
* HotVision
___
Need help? Please check this documentation first.

Last edited by MPNumB; 10-11-2010 at 06:25.
MPNumB is offline
Send a message via Skype™ to MPNumB
MPNumB
Veteran Member
Join Date: Feb 2007
Location: Lithuania
Old 10-09-2010 , 03:27   Re: AmmoPickUp / New-Round Money
Reply With Quote #2

Updated to 1.1
Fixed: Showing 0$ at hlds after ResetHUD.
__________________
Skill and no annoying bugs with fixed balance issues is my goal!
My approved plugins what don't show up in Approved List:
* Bomb/Death/CSS Radar
* HotVision
___
Need help? Please check this documentation first.
MPNumB is offline
Send a message via Skype™ to MPNumB
xPaw
Retired AMX Mod X Moderator
Join Date: Jul 2008
Old 10-09-2010 , 04:45   Re: AmmoPickUp / New-Round Money
Reply With Quote #3

Cool, good job.


Code:
iPlrId<1 || iPlrId>g_iMaxPlayers || !is_user_alive(iPlrId)
wtflol
__________________
xPaw is offline
MPNumB
Veteran Member
Join Date: Feb 2007
Location: Lithuania
Old 10-09-2010 , 05:15   Re: AmmoPickUp / New-Round Money
Reply With Quote #4

Hmm... Ya, this is a useless check of iPlrId, but yet someday when someone will find a way to boost maxplayers limit with Orpheu, you will thank me for clamping maxplayers and making this check.

// EDIT:

Or you'r right...

Updated to 1.2
Changed: Less CPU usage.

PHP Code:
 
 
if( iMsgType!=MSG_ONE || iPlrId<|| iPlrId>g_iMaxPlayers )
  return 
PLUGIN_CONTINUE;
 
 if( !
g_bAlive[iPlrId] )
  return 
PLUGIN_CONTINUE
Mwhahahaha...
__________________
Skill and no annoying bugs with fixed balance issues is my goal!
My approved plugins what don't show up in Approved List:
* Bomb/Death/CSS Radar
* HotVision
___
Need help? Please check this documentation first.

Last edited by MPNumB; 10-09-2010 at 06:13.
MPNumB is offline
Send a message via Skype™ to MPNumB
xPaw
Retired AMX Mod X Moderator
Join Date: Jul 2008
Old 10-09-2010 , 06:31   Re: AmmoPickUp / New-Round Money
Reply With Quote #5

But.. you don't really need to check iPlrId for maxplayers range, engine can't send it for non-players afaik..
__________________
xPaw is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 10-09-2010 , 07:22   Re: AmmoPickUp / New-Round Money
Reply With Quote #6

I think it's kinda useless for severals reasons.

- The main is what you do is an extremely trivial optimization, because the engine sends an enormous amount of messages by second (you can't hook with Amxx, but with Orpheu you can) so these messages are like a drop in the ocean. A lot of code just for that, really not worth.
- Next, about the MSG_ONE_UNRELIABLE, unless there is a good reason, I think it should be kept in a reliable stream. I mean, if the server crashes because of that, it means there are a problems with the installed plugins, it should never happen. Anyway, I would simply patch the memory to change MSG_ONE to MSG_ONE_UNRELIABLE, it would be far more efficient.
- Same for the feature to show the difference, I would hook the internal CS function which sends the message only on new round, and changing the param on-the-fly. More efficient and neat.

Don't kill me, just my thoughts.

But I would like to see a plugin which really can tune the informations sent to the clients instead of plugin focused only on one or two small and not used often messages.

Quote:
[...]to boost maxplayers limit[...]
Already discussed somewhere and that's not possible (not the orpheu fault). Technical limit.
__________________
Arkshine is offline
AMIN KRU
BANNED
Join Date: Aug 2010
Old 10-09-2010 , 07:27   Re: AmmoPickUp / New-Round Money
Reply With Quote #7

gj numB
AMIN KRU is offline
MPNumB
Veteran Member
Join Date: Feb 2007
Location: Lithuania
Old 10-09-2010 , 16:53   Re: AmmoPickUp / New-Round Money
Reply With Quote #8

Quote:
Originally Posted by Arkshine View Post
I think it's kinda useless for severals reasons.

- The main is what you do is an extremely trivial optimization, because the engine sends an enormous amount of messages by second (you can't hook with Amxx, but with Orpheu you can) so these messages are like a drop in the ocean. A lot of code just for that, really not worth.
- Next, about the MSG_ONE_UNRELIABLE, unless there is a good reason, I think it should be kept in a reliable stream. I mean, if the server crashes because of that, it means there are a problems with the installed plugins, it should never happen. Anyway, I would simply patch the memory to change MSG_ONE to MSG_ONE_UNRELIABLE, it would be far more efficient.
- Same for the feature to show the difference, I would hook the internal CS function which sends the message only on new round, and changing the param on-the-fly. More efficient and neat.

Don't kill me, just my thoughts.

But I would like to see a plugin which really can tune the informations sent to the clients instead of plugin focused only on one or two small and not used often messages.


Already discussed somewhere and that's not possible (not the orpheu fault). Technical limit.
- I am trying to avoid Orpheu anyway. Am planing to make a simple plugin with that module though, but just to learn it a bit and find out how powerful it is.
- I was told some years ago that MSG_ONE_UNRELIABLE is better than MSG_ONE, cause there is less possibility of server crash. Also in my current case scenario if I use MSG_ONE - events do reach the client, but have no effect.
- Are you aware what would happen using your way? First of all message would have no effect on client, secondly it it would be not money difference between old money, but money difference from 0, cause ResetHUD changes hud money ammount to 0, and after that only 1 message with current money, without an animation is sent. Also editing original money message results that money event has no effect on the client. Trust me - I spend much time on this plugin researching how money system works and what problems it has - it's not just send updated money with animation - if it would be that simple, don't you think I'd use it?

Well, I don't know, but during my times I did expirience overflow errors during and new round, and respawning, and buying.

Quote:
Originally Posted by xPaw View Post
But.. you don't really need to check iPlrId for maxplayers range, engine can't send it for non-players afaik..
Didn't we once had a discussion, how much we <3 valve? If even when AddToFullPach is called and iHost can be 0, don't you think that this one can have the same problem or be directly related to that?

// edit:

And the plugin idea what I had for Orpheu fail. =P
__________________
Skill and no annoying bugs with fixed balance issues is my goal!
My approved plugins what don't show up in Approved List:
* Bomb/Death/CSS Radar
* HotVision
___
Need help? Please check this documentation first.

Last edited by MPNumB; 10-09-2010 at 18:09.
MPNumB is offline
Send a message via Skype™ to MPNumB
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 10-09-2010 , 18:56   Re: AmmoPickUp / New-Round Money
Reply With Quote #9

For sure using MSG_ONE_UNRELIABLE you will get less crash since the data is put in an unreliable stream. So, instead of having a crash, the client is disconnected. My point was if it crashes on such messages, it means your installed plugins are badly written and that's not the engine fault. It's a good opportunity to code/think intelligently when you use messages. Anyway, if you do that, why not to do it for all the messages ?

About 3/, well yes, I did not think really, it was just an "orpheu-reflex". :p But I don't understand well what you say :
message would have no effect on client ; why ?

I've looked into the binary to trace Money to understand better, here my result :

Code:
You entered in the game. You got $sv_startmoney. (flag 0)
    -> from CBasePlayer::JoiningThink()
   
You joined a team. 
    * if Spectator, you got $0. (flag 0) 
        -> from HandleMenu_ChooseTeam()
        
    * if T/CT and you spawned, You got $sv_startmoney. (flag 0) 
        -> from CBasePlayer::UpdateClientData()
        
Round started.
    * you got the round money. (flag 1)
        -> from CHalfLifeMultiplay::RestartRound()
        
    * you spawn.(flag 0). 
        -> from CBasePlayer::UpdateClientData()
       
You bought something/objectives reward/killed/etc. (flag 1)
    -> from CBasePlayer::AddAccount()
    
You restarted the game. 
    * Offset reseted, you got $0. (flag 0)
        -> from CBasePlayer::Reset()
        
    * Offset set considering cvars, you got $mp_startmoney. (flag 1)
        -> from CBasePlayer::Reset()
I understand well now why you don't see the change when you spawn, because a second message is sent with 0 as flag. I still don't get what you are talking about "editing original money message results that money event has no effect on the client".

I'm sure you could do it in a more neat way. ;)
__________________
Arkshine is offline
MPNumB
Veteran Member
Join Date: Feb 2007
Location: Lithuania
Old 10-10-2010 , 07:03   Re: AmmoPickUp / New-Round Money
Reply With Quote #10

Well, take a look in the code. You will see that I have to check for hlds and do differently for it. If I wouldn't do so - money would be 0 after "fullupdate" command at hlds condition. Also you will see that if MSG_ONE_UNRELIABLE is changed to MSG_ONE - money ammount wont be updated on client's hud. It's some hlengine glitch - I don't know - credits to valve.

And even if at respawn flag would be 1, it would be wrong. Let me explain, how step by step it originally works. For example you had 800, now c4 exploded, you win, you should have 4300 (+3500) when you respawn. So let's begin:
1. New round - it updates money with animation at your PreThink. However message isn't send to client - this change uses pdata from AddToFullPack (client-side).
2. Now you respawn.
3. Respawn = ResetHUD = money in hud 0.
4. Server sends Money message with flag 0.

So in conclusion, you can see that if in #4 flag would be 0, the difference will always be from 0 to newmoney, and not from oldmoney to newmoney.
__________________
Skill and no annoying bugs with fixed balance issues is my goal!
My approved plugins what don't show up in Approved List:
* Bomb/Death/CSS Radar
* HotVision
___
Need help? Please check this documentation first.
MPNumB is offline
Send a message via Skype™ to MPNumB
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 19:55.


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