Use publics inside a plugin
#1

Hello,

Ok, I tried a couple of things to make this working.
But it didnt work out.

So I found out I didn't ask the right question, so once again.

How can I juse Natives (such as GetPlayerPos) inside my DLL?

I tried things like:
amx_FindNative to get the address.
and this to 'compare'.

Hope someone can help me out.

Outdated post
Code:
Hey,

I guess the title includes my whole question, but still

Is there a way to use the public functions from pawno inside my plugin(visual studio)
I think it should be something with AMX_getpublic, or find public.. but neither worked on my way..

Does anyone at all know if its possible and how it is possible?

Thanks!
Reply
#2

pawn Code:
if (amx_FindPublic(amx, "OnGayParty", &idx) == AMX_ERR_NONE)
Reply
#3

https://sampforum.blast.hk/showthread.php?tid=261570
Reply
#4

Thanks you all!
Reply
#5

Quote:
Originally Posted by 0x5A656578
View Post
You beat me to it!
Reply
#6

Ok, I tried a couple of things to make this working.
But it didnt work out.

So I found out I didn't ask the right question, so once again.

How can I juse Natives (such as GetPlayerPos) inside my DLL?

I tried things like:
amx_FindNative to get the address.
and this to 'compare'.

Hope someone can help me out.
Reply
#7

Quote:
Originally Posted by me-borno
View Post
Ok, I tried a couple of things to make this working.
But it didnt work out.

So I found out I didn't ask the right question, so once again.

How can I juse Natives (such as GetPlayerPos) inside my DLL?

I tried things like:
amx_FindNative to get the address.
and this to 'compare'.

Hope someone can help me out.
Check out the invoke script incognito made for his streamer plugin. To get it setup (without dependencies) you need to change all of his unordered_maps into regular STL maps, allocate memory for the "invoke" pointer (do this upon load), push_back the amx_list on amxload, and delete the AMX instance from the amx_list when AmxUnload is called.

Thats how you correctly set it up. To get it working you have to call the memeber function getAddresses (i suggest on GM load), and you have to add your own natives (it currently only contains object related natives). You add the native's names to the list of names in invoke.h, and you fill the Native structure for it right below that (try to follow the pattern of the ones already there if you dont know what your doing). Once thats done, simply add a call to the native function in a public PAWN function (one thats not for use...this function should contain a call for every function you add to invoke... the functions have to be used in a public in order to get their addresses.).

Edit:

Im gonna upload my current one, it has more natives (converted them from peters' old PawnCommand), and uses it uses standard maps. You still have to set it up for yourself though (gotta allocate memory, push the amx_list back, and delete an item from amx_list when AmxUnload is called).

Here' the PAWN function containing all the defined natives (You'd want to add this in an include. I personally have it in my PAWN GM, as my real GM is a plugin):

http://pastebin.com/7d9yzwPg

Here's the invoke script by incognito:

http://www.sendspace.com/file/uuwpx1



Note: Make sure every time you add a native (i do it on an as needed basis) you add it to that PAWN function, or you'll get a run-time error.
Reply
#8

Quote:
Originally Posted by Kyosaur
View Post
Check out the invoke script incognito made for his streamer plugin. To get it setup (without dependencies) you need to change all of his unordered_maps into regular STL maps, allocated memory for the "invoke" pointer (do this upon load), push_back the amx_list on amxload, and delete the AMX instance from the amx_list when AmxUnload is called.

Thats how you correctly set it up. To get it working you have to call the memeber function getAddresses (i suggest on GM load), and you have to add your own natives (it currently only contains object related natives). You add the native's names to the list of names in invoke.h, and you fill the Native structure for it right below that (try to follow the pattern of the ones already there if you dont know what your doing). Once thats done, simply add a call to the native function in a public PAWN function (one thats not for use...this function should contain a call for every function you add to invoke... the functions have to be used in a public in order to get their addresses.).
Thanks! This should defenatly help!
Reply
#9

Quote:
Originally Posted by me-borno
View Post
Thanks! This should defenatly help!
No problem, thank incognito though since he made it lol (i only edited bits). Make sure you see my post again, i edited it (sorry if some parts arent clear, im kind of rushed. Feel free to PM me for help).
Reply
#10

Take a look at this, with that you don't have to run an additional .amx with all natives you are going to call
Reply
#11

Quote:
Originally Posted by 0x5A656578
Посмотреть сообщение
Take a look at this, with that you don't have to run an additional .amx with all natives you are going to call
Its not really an additional .amx file. You'd generally have your invoke function inside of your plugins include.


I'll actually check that out though (later when i have more time), looks pretty interesting.
Reply
#12

Lol, Thanks to you all!
This might even work out after all :P

(a friend of mine came with the idea to put the whole server inside a DLL... lol.. (I wont do it either :P))
Reply
#13

I still find invoke to be the cleaner method. It seems like hell of a lot less effort and its working with every type of parameter (int, float, string, reference, and what i hate to call a "reference string" (GetPlayerName)). All it asks for is that these functions are used somewhere in the script.

There are bits that im not able to understand when it comes to zeex's script i'll admit (Im not the best in C++), but its pretty interesting.

Quote:
Originally Posted by me-borno
Посмотреть сообщение
Lol, Thanks to you all!
This might even work out after all :P

(a friend of mine came with the idea to put the whole server inside a DLL... lol.. (I wont do it either :P))
My entire GM is in a plugin. There are definitely some pros and cons to having this. The main benefit is that you have a TON of things available to you that arent available in PAWN, the cons are of course a reduction in speed due to communication with PAWN (i find this generally evens out though, so its not that big of a deal).

I say if your comfortable in c++, and think you can handle it, give it a shot :P.
Reply
#14

Quote:
Originally Posted by Kyosaur
Посмотреть сообщение
My entire GM is in a plugin. There are definitely some pros and cons to having this. The main benefit is that you have a TON of things available to you that arent available in PAWN, the cons are of course a reduction in speed due to communication with PAWN (i find this generally evens out though, so its not that big of a deal).

I say if your comfortable in c++, and think you can handle it, give it a shot :P.
Lol, nope. Im not that good in C++ xD
I just give the C++ plugin thingy a shot :P altough I learnt some basic things in OpenGL programming :P
Reply
#15

Since I'm too lazy to make a new topic I'm just saying it here:

I've finished the work on a new C++ wrapper, all 0.3c natives and callbacks are supported, for more info look at the readme here (the code is there as well):

https://github.com/Zeex/samp-gamemode-sdk

Though I must warn you that it's not well tested yet (at least works for HelloWorld) and I haven't compile it on Linux...
Reply
#16

Quote:
Originally Posted by ******
Посмотреть сообщение
Nicely done! Have you tested functions like GetPlayerName?
Thanks! I only tested GetPlayerName, looks like it's working
Reply
#17

Quote:
Originally Posted by 0x5A656578
Посмотреть сообщение
Since I'm too lazy to make a new topic I'm just saying it here:

I've finished the work on a new C++ wrapper, all 0.3c natives and callbacks are supported, for more info look at the readme here (the code is there as well):

https://github.com/Zeex/samp-gamemode-sdk

Though I must warn you that it's not well tested yet (at least works for HelloWorld) and I haven't compile it on Linux...
I think you should give this better exposure. You've clearly put a lot of work into it!

If I have some time, I may try seeing how well it performs in some of my own projects.

Edit: It would probably be a good idea to check if the compiler can support some of the C++0x features you're using (e.g., unordered_map and auto).
Reply
#18

Quote:
Originally Posted by Kyosaur
View Post
http://pastebin.com/7d9yzwPg

Here's the invoke script by incognito:

http://www.sendspace.com/file/uuwpx1

Note: Make sure every time you add a native (i do it on an as needed basis) you add it to that PAWN function, or you'll get a run-time error.
Just for the completeness,
pawn Code:
new Float:x, Float:y, Float:z;
GetVehicleVelocity(0, x, y, z);
is missing in your include file. Took me while to figure out whats the problem, as it still didnt load all natives. Maybe you could add that to evade future confusions for others.
Reply
#19

Quote:
Originally Posted by Mauzen
Посмотреть сообщение
Just for the completeness,
pawn Код:
new Float:x, Float:y, Float:z;
GetVehicleVelocity(0, x, y, z);
is missing in your include file. Took me while to figure out whats the problem, as it still didnt load all natives. Maybe you could add that to evade future confusions for others.
Yeah, there are some missing natives in it. You'll have to add the missing ones yourself (its pretty simple, but if anyone gets stuck PM me) i tend to add them on an as needed basis.
Reply


Forum Jump:


Users browsing this thread: 6 Guest(s)