AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Code Snippets/Tutorials (https://forums.alliedmods.net/forumdisplay.php?f=83)
-   -   [TUT] Modules and efficient scripting (https://forums.alliedmods.net/showthread.php?t=88792)

ot_207 09-01-2009 02:44

Re: [TUT] Modules and efficient scripting
 
Quote:

Originally Posted by Bad_Bud (Post 919583)
I thought the concept behind the fakemeta high was that the engine module eats up CPU time when it's doing nothing, whereas fakemeta does not. I haven't seen anyone do a profile with fakemeta running for long periods of time with the engine module disabled, versus engine running for long periods of time. In most profiles, I see the fakemeta being compared with the engine in the same plugin, which guarantees that the engine module is still running -- defeating the purpose of a comparison between engine and "pure fakemeta"; we've taken away the most preached aspect of the comparison: engine module uses CPU when it is not being used.

I'm not taking sides, because I'm not advanced enough of a scripter to really care, but I think these tests are less intuitive than they appear, and that if we are going to state things as solid facts with profiles, fair tests should be run.

The difference of that the engine uses cpu always instead of fakemeta that it does not. Can be explained with a simple and plain example.

In fakemeta if you need the prethink forward you will register it.
Whereas in engine you place it as a function client_PreThink(id).
The difference is that fakemeta if it does not have any forwards to call (no plugins have this forward registered) it does not bother to get the forward from the engine and call the plugins.
Where as engine sends the function call to all the plugins (it doesn't care if the plugins have the forward or nor).
That is the difference.
I think that the "fakemeta high" problem started from the things that people misunderstood, they thought that fakemeta will use cpu when it is asked to, that is what was making fakemeta > engine not the power of the module itself. Both modules are great, and work flawlessly, using one of them is good but using both of them will make it all more efficient.

And this tutorial advices you to use less module communications because these are the problems when we talk about CPU usage (efficiency).

Bad_Bud 09-01-2009 03:16

Re: [TUT] Modules and efficient scripting
 
So it was not true at all?

One oddity though... it doesn't match up with the funcwiki, but I have engine disabled, but client_PreThink still works.

Alka 09-01-2009 03:33

Re: [TUT] Modules and efficient scripting
 
Because in this new version of AMXX, if a plugin require an module and it's not enabled will be enabled automaticly.

ot_207 09-01-2009 03:42

Re: [TUT] Modules and efficient scripting
 
Quote:

Originally Posted by Bad_Bud (Post 919749)
So it was not true at all?

One oddity though... it doesn't match up with the funcwiki, but I have engine disabled, but client_PreThink still works.

I did not say it was not true, I said that people misunderstood what the module developers have said. This tutorial is meant to point you into the right direction.

Quote:

Originally Posted by Alka (Post 919754)
Because in this new version of AMXX, if a plugin require an module and it's not enabled will be enabled automaticly.

That is true!

Bad_Bud 09-01-2009 03:56

Re: [TUT] Modules and efficient scripting
 
No, I mean, my plugin is written entirely in ham and fakemeta except for that function. I don't even #include engine. I would think that another include is secretly including engine, but I've tried calling some engine functions just to see, and I get errors... just not on client_PreThink().

PHP Code:

#pragma dynamic 32768

#include <amxmodx>
#include <amxmisc>
#include <fakemeta>
#include <hamsandwich>
#include <sqlx>
#include <ava_ts> 


ot_207 09-01-2009 03:59

Re: [TUT] Modules and efficient scripting
 
Quote:

Originally Posted by Bad_Bud (Post 919762)
No, I mean, my plugin is written entirely in ham and fakemeta except for that function. I don't even #include engine. I would think that another include is secretly including engine, but I've tried calling some engine functions just to see, and I get errors... just not on client_PreThink().

PHP Code:

#pragma dynamic 32768

#include <amxmodx>
#include <amxmisc>
#include <fakemeta>
#include <hamsandwich>
#include <sqlx>
#include <ava_ts> 


Engine doesn't know you have the client_PreThink function in your plugin, even if you include engine. The module will call the function even if it is not included :).

Bad_Bud 09-01-2009 04:02

Re: [TUT] Modules and efficient scripting
 
It shouldn't be able to compile... er...

I think I understand what you're saying now... and I think that's kind of dumb if it's true, lol.

Though I would think it would say something like the function is not used in the compiler output, but it doesn't, it recognizes what it's for.

PHP Code:

#include <amxmodx>

#define PLUGIN "New Plug-In"
#define VERSION "1.0"
#define AUTHOR "author"


public plugin_init()
{
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
// Add your code here...
}

public 
client_PreThink(id)
{
    


Doesn't even gripe.

Heh, but that was it. I removed the engine.dll and it stopped prethinking. I suppose with sneaky functions like that, us who think we have removed engine from our plugins may have not. ;(

Emp` 09-01-2009 12:18

Re: [TUT] Modules and efficient scripting
 
Quote:

Originally Posted by Bad_Bud (Post 919764)
Though I would think it would say something like the function is not used in the compiler output, but it doesn't, it recognizes what it's for.

Because you declare it as a public function.

ot_207 09-01-2009 12:19

Re: [TUT] Modules and efficient scripting
 
Quote:

Originally Posted by Emp` (Post 920047)
Because you declare it as a public function.

Good to know that, haven't thought of it :).

ConnorMcLeod 09-01-2009 12:35

Re: [TUT] Modules and efficient scripting
 
Engine module won't be auto-loaded by a public function (forward).


All times are GMT -4. The time now is 03:34.

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