Raised This Month: $32 Target: $400
 8% 

About calling native from extensions


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
kiceqs
Junior Member
Join Date: Jun 2015
Old 12-27-2021 , 02:58   About calling native from extensions
Reply With Quote #1

The reason why is that there are a lot of useful functions already come with sourcemod.

I am writing a plugin will do a lot of work every frame and use quite a lot of memory, so it might be worth trying to write a extensions instead.

However, it quite hard to interact with game itself without native access, for example, like functions in cstrike.inc and sdktools_*.inc.
I know there are interfaces could achieve the same things, but it require more or less copy the whole extension's source code and if the extension got an update recompile is required.

Beside that, calling native purely from extension is quite difficult or nearly impossible.

Currently my thought is to write a proxy plugin and some extension natives for the proxy plugin to register itself to the extension; then calling the plugin functions to call the desired natives.

The other way is to still write a plugin, after getting required data and pass to extension. In my opinion, compare to writing a proxy plugin, like splitting between 50:50 to 1:99.

Is it a better way to solve this problem?
kiceqs is offline
asherkin
SourceMod Developer
Join Date: Aug 2009
Location: OnGameFrame()
Old 01-05-2022 , 07:30   Re: About calling native from extensions
Reply With Quote #2

Quote:
I am writing a plugin will do a lot of work every frame and use quite a lot of memory, so it might be worth trying to write a extensions instead.
This is probably a false assumption, SourcePawn is extremely efficient especially if you're just doing calculations / logic on the plugin side (there is a small performance penalty to calling natives). It is very rare for plugins to even be measurable against all the work the game server does every frame, and there is absolutely no benefit to consuming memory on the C++ side rather than the SP side.

Quote:
The other way is to still write a plugin, after getting required data and pass to extension.
This is what the extension API is explicitly pushing you towards - and is why it doesn't have any interfaces for invoking SM natives or much in the way of game APIs. Extensions should be small, reusable components that provide functionality that plugins can't do natively - and they have less and less relevance in the era of things like DHooks.
__________________
asherkin is offline
Reply


Thread Tools
Display Modes

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 21:39.


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