Loading standard Pawn libraries... - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Plugin Development (
https://sampforum.blast.hk/forumdisplay.php?fid=18)
+--- Thread: Loading standard Pawn libraries... (
/showthread.php?tid=167890)
Loading standard Pawn libraries... - Zeex - 14.08.2010
I'm currently trying to make such a plugin that can load standard AMX modules (amxFile, amxTime, amxProcess etc), which come with the Pawn installation package, to be able to use their natives (i.e. without extracting them from source code and making another plugin - why do that if it's already compiled by someone else?).
The idea is that when a script gets loaded, the plugin looks into its library table and determines which modules should be loaded, and then tries to load them one by one from the %AMXLIB% directory. Every module has a special (exported) function called amx_<module_name>Init which then typically calls amx_Register to register natives.
So I've already made almost everything (I hope) but there's one problem - it doesn't work this way. It behaves like it doesn't affect on script's native table (I didn't checked though), and I'm now guessing what's wrong with my code or maybe this method...
Here's the whole code:
http://zeex.pastebin.com/K0pmu4Ew
Any ideas why it doesn't work?
Re: Loading standard Pawn libraries... - Zeex - 14.08.2010
Quote:
Normal plugins call amx_Register in their Load function, which is called before and AMX is loaded.
|
Ehm... did you mean AmxLoad? I think I generally do exactly the same thing as I do when make normal plugin - call amx_Register for each AMX being loaded, however it's not the one which built into SA-MP and thus it may does things in different way...
I checked it on amxProcess, and it behaves like it doesn't register any natives. The Init function is 100% called (tested with my own .dll).
Re: Loading standard Pawn libraries... - Zeex - 16.08.2010
OK today I found that it DOES modify the native table but I still get "Run time error 19: File or function is not found" which means that it for some reason can't find a little native function from my test DLL
Код:
[12:10:21] Server Plugins
[12:10:21] --------------
[12:10:21] Loading plugin: amxlib.dll
[12:10:21] AMXLib plugin by Zeex [Build date: Aug 16 2010]
[12:10:21] Loaded.
[12:10:21] Loaded 1 plugins.
[12:10:21]
[12:10:21] Filter Scripts
[12:10:21] ---------------
[12:10:21] Loaded 0 filter scripts.
[12:10:21] [amxlib] Error: Couldn't load module: samp
[12:10:21] [amxlib] Error: Couldn't load module: Float
[12:10:21] [amxlib] Loaded module: Test
[12:10:21]
----------------------------------------------------------------
[12:10:21] hello 19051696 <--- address isn't zero
[12:10:21] printf 4603616
[12:10:21]
----------------------------------------------------------------
[12:10:21] Script[gamemodes/1.amx]: Run time error 19: "File or function is not found"
[12:10:21] Number of vehicle models: 0
[12:42:54] --- Server Shutting Down.
The script itself:
pawn Код:
#include <a_samp>
#pragma library Test
native hello();
main()
{
printf("%d", hello());
}
Anyway, I've uploaded the project on here:
http://solidfiles.com/d/14d5/ (you need VS2008+ and
Pawn toolkit in order to build it).