Custom is_user_alive library/module/plugin
Hello!
An interesting question came to my mind, by at the first, I think need some information: Some plugins use a PlayerPrethink hook (with engine or fakemeta), where is not recommended use some function - example is_user_alive -, because of cause lag with lot of engine call. (AMXMODX->METAMOD->ENGINE->METAMOD->AMXMODX). I search it at this forum, and found some example to resolve this problem: The optimalized way is to store in array the players alive status, and set or get it only when need. I know that a long time ago, but let's see it again. So, the problematic, and not optimalized code (bad): PHP Code:
And an example - i think - optimalized "bone-code", for these plugins: PHP Code:
The question: Suppose that there are a lot of plugins (example 10#), which are use prethink with chechking player alive (and do something is true). If I make a plugin, which is effecting the bone-code, and implement a get native method what is return is user alive, then these plugins more efficiency? Example (Bone implementation): PHP Code:
PHP Code:
What do you think about this? Useful? Unnecessary? |
Re: Custom is_user_alive library/module/plugin
Useless shit.
Better to use the build-in native |
Re: Custom is_user_alive library/module/plugin
Not error proof. Using the native does not cause any issue and is error proof.
|
Re: Custom is_user_alive library/module/plugin
I do not quite understand this. Can you explain?
|
Re: Custom is_user_alive library/module/plugin
Quote:
|
Re: Custom is_user_alive library/module/plugin
Replacing a native with a dynamic native won't do you any good.
|
Re: Custom is_user_alive library/module/plugin
Okey, yes, but suppose that there is no error in this module plan. Faster than I use always is_user_alive native?
I found the post about it - included is_user_bot function - by MeRcyLeZZ: http://forums.alliedmods.net/showpos...91&postcount=1 So, stay optimized if I replace another custom native function? I think must be |
Re: Custom is_user_alive library/module/plugin
Quote:
Your dynamic native creates a new native, it then contacts the module, the module contacts the other plugin to get the value, and then that value goes back to your plugin. It's not faster. In fact, it should be slower. If you need a slight performance boost in your plugins, you'll have to create new variables in each one of them as opposed to using just one plugin as an API. You should only do that in big plugins that use very often-called forwards, though. |
Re: Custom is_user_alive library/module/plugin
The native is fast as hell and there is really no downside to using it. The only REALLY FUCKING SMALL improvement would be to cache the is_user_alive value, but that can cause issues and other headaches later.
|
Re: Custom is_user_alive library/module/plugin
cache alive status inside a plugin is not a good idea. As Yami said, it is not error proof, some plugins/maps can kill players without triggering things that are caught by your plugin.
Doing this in a extra plugin in order to provide a dynamic native is even worth, because you gonna add some calls between plugins and amxx. Also, is_user_alive doesn't triggering communication between amxx and metamod. About prethink, better to use engine module forward client_PreThink, unless you want to post hook it or unless you don't want to hook it all the time. |
| All times are GMT -4. The time now is 10:11. |
Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.