Natives and Methodmaps
I know there is plenty tuts and stuff, but want to ask straight question.
How I can make methodmap with natives? So I could use methodmap in other plugin... Let's say I'm interested in some client related natives, which would change some for that methodmap and executing some functions :) If anyone has clear example of core plugin and plugin who uses those methodmaps natives please share |
Re: Natives and Methodmaps
Create the natives as normal, and then, in the include that the other plugin would use, insert the methodmap.
|
Re: Natives and Methodmaps
Let's say you had a methodmap like this:
Code:
methodmap YourThing { Code:
public APLRes AskPluginLoad2(Handle hPlugin, bool late, char[] error, int err_max) { Code:
// include is implied |
Re: Natives and Methodmaps
Quote:
also a question is it possible to extend my methodmap by parent/children stuff between plugins? |
Re: Natives and Methodmaps
If you mean inheritance type stuff, you can sort of "inherit" from other methodmaps. See https://wiki.alliedmods.net/SourcePa...ax#Inheritance for how that works.
With that said, you shouldn't mistake methodmaps for objects and try to write OOP code. I'd only use methodmaps when extending/implementing Handle types. |
Re: Natives and Methodmaps
I trying to make Native methodmap for client and I get these warnings:
Code:
.... Code:
// C:\zombies\addons\sourcemod\scripting\zombie_mod.sp(1454) : warning 213: tag mismatch Code:
return view_as< ZMPlayer >( GetClientUserId( client ) ); Code:
return view_as< ZMPlayer >(-1); |
Re: Natives and Methodmaps
You need to return the value as an integer in your native function callback.
|
Re: Natives and Methodmaps
Quote:
|
Re: Natives and Methodmaps
You return exactly what you would usually return, except as an integer. If necessary, do a view_as<int> on it to get rid of the tag mismatch warning. You have to return an int for all native implementations. If the actual native has a different return type that will be handled by SM and it'll "cast" it from an int to the correct type.
For example if you have a native like this: PHP Code:
PHP Code:
|
Re: Natives and Methodmaps
well this as constructor works fine thanks
Code:
public int Native_ZMPlayer_Constructor(Handle plugin, int numParams) |
All times are GMT -4. The time now is 03:45. |
Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.