Raised This Month: $ Target: $400
 0% 

[Tutorial] Communicating data across plugins (or how to use natives in general)


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
WildCard65
Veteran Member
Join Date: Aug 2013
Location: Canada
Old 06-03-2016 , 14:11   Re: [Tutorial] Communicating data across plugins (or how to use natives in general)
Reply With Quote #1

Quote:
Originally Posted by Vergil333 View Post
Sooooooooooooooo... What is happening here?
1) setAnInt(50) from second plugin is actually a function. Function from first plugin called native_setAnInt.
2) it pass the value 50 via uselessnatives.inc
3) uselessnatives.inc communicate with CreateNative("setAnInt", native_setAnInt) from first plugin
4) and by this magic, 50 is set in native_setAnInt function in first plugin. This function than changes value of anInt = 50.

That's setAnInt. Passing data from second plugin to the first plugin.
After it is set (passed) it is called by a function getAnInt. And there is no need for magic? It is just called like this? Directly?

I need to pass an array from first plugin to second. Only one-way. What do I need???
Here is what actually happens:
A) CreateNative tells SourceMod to bind setAnInt native to plugin function native_setAnInt through FakeNatives.
B) 2nd Plugin calls setAnInt and pushes 50 to param stack.
C) Sourcepawn lookups the native binding of setAnInt, discovers it as a fake native and calls the fake native router associated with the native.
D) SourceMod sets up internal variables related to the fake native it's currently executing (in this case, setAnInt).
E) SourceMod calls the bound plugin function.
F) First plugin does logic for native and returns 0 (because SP compiler code injection).
G) SourceMod re-returns 0 back to SP.
H) SP re-returns 0 back to the 2nd plugin.
I) Second plugin discards the returned value after current function is done executing.

Last edited by WildCard65; 06-03-2016 at 14:12.
WildCard65 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:55.


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