Such approach is a performance loss or is it irrelevant? [solved]
2 Attachment(s)
Hi everybody, I just develop a Golden Weapons which "enable" to buy fictitiously 3 Golden Weapons with higher damage.
And there is this 'Ham_TakeDamage' forward and 'CurWeapon' event, which I don't understand well the impact of it at server's performace: PHP Code:
PHP Code:
PHP Code:
PHP Code:
PHP Code:
Such thing higher the server client's ping? How can I measure my server 'ping' before and after active this plugin? I was coping & rewriting from two others plugins who does the same thing, because: 1) the first one crashes my server and i could not understand why, when reading its code, which one I did not like because uses big stuff to make damage. 2) the second one is unapproved but don't uses the big stuff at the first one. Silver Weapons (the first one) Golden Ak (banned author) High performance is what I am trying to archive. By now I am reading Optimizing Plugins (AMX Mod X Scripting). Here is attached the plugin. It's fully working, but it does not have its low priority requisites, like customizable server variables. |
Re: Such approach is a performance loss or is it irrelevant
Run it and see what happens. The code that you've shown is relatively small compared to many plugins that use these hooks. However, get_user_weapon() will not always get the weapon with which the damage was caused. For example, if when someone is injured by a grenade, the attacker might not be holding a grenade.
|
Re: Such approach is a performance loss or is it irrelevant
Quote:
Hence, are these steps light weight or heavy weight? For now, I am keep follow what you said.
|
Re: Such approach is a performance loss or is it irrelevant
We can't answer, a plugin alone won't usually cause any clear difference(of course, if not using, for example, per frame forwards badly with crap code).
What you can do is to remove CurWeapon event and also weapPickupEvent, and use Ham_Item_Deploy. Even with CurWeapon, you don't need the weapPickupEvent, but Item_Deploy is better than CurWeapon, it's called only at the moment when you need to show the model again. Ham_TakeDamage is using game default function(for players it should be CBasePlayer::TakeDamage), and it's okay to use it too. Generally, if it's ok for the game it should be ok for you too. For example, instead of: PHP Code:
Edit: About your last post, it's bullshit, don't try to micro optimize, why you are afraid of few checks ? |
Re: Such approach is a performance loss or is it irrelevant
Quote:
Quote:
For example, if there is something that is executed at server side depending about the 'ping', and it could be implemented at another way where it is computed at client side, hence don't increasing the client't ping, would be a good trade if its improvement where good. Like the Ham_TakeDamage, which is using the game default function. I am using it, instead of the original's SilverWeapon stranger techniques, which of course is more powerful because affects the cs built-in bots, but it is of course, a sacrifice that is a good trade for server's/client's performance. |
Re: Such approach is a performance loss or is it irrelevant
Quote:
If it was a operation that happens all the time, every second I would became worried about that, if it is not efficiently micro optimized. Unless it uses CPU time a lot, which I have. But it it used network bandwidth a lot, which I not have, I would became worried. |
Re: Such approach is a performance loss or is it irrelevant?
You did not understand me, micro optimizations give you nothing, you don't get rid of lag with them or whatever you are thinking.
About the Damage thing, I think you are confused a bit. It's not more powerfull or whatever. Look at it's description: Quote:
Quote:
PHP Code:
Your title ask if it is irrelevant or not, you got your answer, but you still act like you know already. If so, why asking ? Now, more about your code: 1.In a Ham forward you should use HAM_ return constants + this function is not mean to return booleans, but integers. 2.Do not hardcode a string array size, you have charsmax() for retrieving it. It helps on readability. 3.default: return PLUGIN_HANDLED you can remove this, but not like it matters much. 4.Something you should care about is the use of FM_CmdStart, which is called per frame, and if you have alternatives you should avoid it. I think that now you can hook WeaponIdle with ham, disable it right after hooking, enable it on deploy and disable on holster. It should work, test and see. 5.For Fakemeta forwards you should return FMRES_* constants, not PLUGIN_. |
Re: Such approach is a performance loss or is it irrelevant?
Thank you again for your patience.
Quote:
Quote:
Quote:
Quote:
|
Re: Such approach is a performance loss or is it irrelevant?
If you want to optimize your plugin, before trying micro-compiler optimization and such, you should first learn to use the proper functions/forwards for your needs. Learning what implies the use of such natives/forwards. You need more behind-in-scene knowledge about AMXX/Game/Engine. It's about understanding the flow of events to insert your code at the right place. It requires you read HLDSK, AMXX code, and such. You need to care first about the logic of your code.
For example, changing weapon model, you're using WeapPickup, which is an horrible and unreliable way. When you think about it, just because you pick up a weapon doesn't mean you will currently holding it right away, it depends of various factors (weapon weight, client cvar, CanDeploy/CanHolster virtual function, etc). This is not guarantee you will get the weapon nor that you will switch to it. Also this message happens before you actually gets the weapon. This doesn't seem a right place to set model. This is game knowledge. You would want an event which is called when you deploy your weapon. If you look at HLSDK and how weapon is made, you see that model is set when Deploy() is called. Incidentally it happens Ham module can hooks virtual functions. This is AMXX knowledge. Then you should do the same for your plugin. You will now set model at the right time and when it's necessary. |
Re: Such approach is a performance loss or is it irrelevant?
Thank you, hence that plugin is not finished yet. I still need understand it flow throw AMXX and HL and use the proper functions right instead of this bad codding senseless. You already give me a big start where must I go to.
Haha, You said that Pawn is a simplified language, and I agree but, to program good code in Pawn instead of senseless code, you need much more then Pawn, you need know well the scenario behind it, to not end up bad codding like me, that obliviously need to study more not about Pawn essentially but its used environment AMXX and GoldSrc. Not just because things compiles and works (apparently), does not mean that is everything alright. May be one bad codded plugin working can be ok, but can you imagine 50 bad plugins running at the same time? May be still ok, but may be not. May be neither one bad coded is ok. |
| All times are GMT -4. The time now is 22:16. |
Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.