Raised This Month: $51 Target: $400
 12% 

Understanding Natives?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Luke Penny
Senior Member
Join Date: Jan 2010
Location: Canada
Old 09-18-2010 , 18:18   Understanding Natives?
Reply With Quote #1

I've read the wiki page on Natives over and over but I can't quite figure out how to use them.

Say in Plugin 1 I have this:
Code:
public APLRes:AskPluginLoad2(Handle:myself, bool:late, String:error[], err_max)
{
    CreateNative("GetAmount", N_GetAmount);
}

native Getamount();
public N_GetAmount(Handle:plugin, numParams)
{
    return amount;
}
I'm not entirely sure if I am doing that correctly, if someone could verify that. It compiles fine, however.

Then, in Plugin 2 I try to use it somewhere, but it of course doesn't compile because it has no idea of what's going on in plugin 1 (Undefined symbol). I think I need to put something in an include file but I have no idea what, if anyone could help it would be greatly appreciated!
__________________

Last edited by Luke Penny; 09-18-2010 at 18:23.
Luke Penny is offline
Fyren
FyrenFyrenFyrenFyrenFyren FyrenFyrenFyrenFyrenFyren FyrenFyrenFyrenFyrenFyren FyrenFyrenFyrenFyrenFyren
Join Date: Feb 2106
Old 09-18-2010 , 20:32   Re: Understanding Natives?
Reply With Quote #2

Look at the documentation on the wiki for natives in the scripting/SourcePawn section (not in the general SM development section, that's for C++).
Fyren is offline
Afronanny
Veteran Member
Join Date: Aug 2009
Old 09-18-2010 , 22:25   Re: Understanding Natives?
Reply With Quote #3

You need to either use an include, or put this line in plugin2:
PHP Code:
native MyNative(); 
Here's how the files should look if you're using an include:

Plugin1:
PHP Code:
public APLRes:AskPluginLoad2(Handle:myselfbool:lateString:errorerr_max)
{
    
CreateNative("MyNative"Native_MyNative);
    return 
APLRes_Success;
}

public 
Native_MyNative(Handle:pluginnumParams)
{
    return 
1;

mynative.inc:
PHP Code:
native MyNative(); 
Plugin2:
PHP Code:
#include <mynative>
public SomeFunction()
{
   return 
MyNative();

If you want to skip using the include, Plugin2 should look a bit like this:
PHP Code:
native MyNative();
public 
SomeFunction()
{
    return 
MyNative();

Afronanny is offline
Luke Penny
Senior Member
Join Date: Jan 2010
Location: Canada
Old 09-19-2010 , 03:16   Re: Understanding Natives?
Reply With Quote #4

Thanks, I finally understand it! Got a little confused about what to do in the second plugin.
Luke Penny is offline
Reply



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 18:03.


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