Loaded AMX viewer
#4

Alright guys, small step for me, giant step for... well, nobody yet.

Armed with newly found plugin development tutorial and implementer's guide example code (with AMX_ERR_EXIT substituted with AMX_ERR_SLEEP), I've devised the following:

PHP Code:
#include "SDK\amx\amx.h"
#include "SDK\plugincommon.h"
typedef void(*logprintf_t)(charformat, ...);
logprintf_t logprintf;
extern void *pAMXFunctions;
int AMXAPI DebugHandler(AMX *amx)
{
    
logprintf("Shh bby it's okay");
    return 
AMX_ERR_SLEEP;
}
cell AMX_NATIVE_CALL HelloWorld(AMXamxcellparams)
{
    
amx_SetDebugHook(amxDebugHandler);
    return 
1;
}
PLUGIN_EXPORT unsigned int PLUGIN_CALL Supports()
{
    return 
SUPPORTS_VERSION SUPPORTS_AMX_NATIVES;
}
PLUGIN_EXPORT bool PLUGIN_CALL Load(void **ppData)
{
    
pAMXFunctions ppData[PLUGIN_DATA_AMX_EXPORTS];
    
logprintf = (logprintf_t)ppData[PLUGIN_DATA_LOGPRINTF];
    
logprintf(" * Test plugin was loaded.");
    return 
true;
}
PLUGIN_EXPORT void PLUGIN_CALL Unload()
{
    
logprintf(" * Test plugin was unloaded.");
}
AMX_NATIVE_INFO PluginNatives[] =
{
    { 
"HelloWorld"HelloWorld },
    { 
0}
};
PLUGIN_EXPORT int PLUGIN_CALL AmxLoad(AMX *amx)
{
    return 
amx_Register(amxPluginNatives, -1);
}
PLUGIN_EXPORT int PLUGIN_CALL AmxUnload(AMX *amx)
{
    return 
AMX_ERR_NONE;

pawn Code:
#include <a_samp>

native HelloWorld();

main() {
    SetTimer("Booper", 1000, 1);
}

forward Booper();
public Booper()
{
    static i = 0;
    printf("Tick %d %d", gettime(), ++i);
    if (i == 3) {
        printf("Executing debug");
        HelloWorld();
    }
}
Results:
Quote:

[00:18:29] Loading plugin: sandbox
[00:18:29] * Test plugin was loaded.
[00:18:29] Loaded.
[00:18:29] Loaded 5 plugins.

[00:18:30]
[00:18:30] Filterscripts
[00:18:30] ---------------
[00:18:30] Loaded 0 filterscripts.

[00:18:30] Number of vehicle models: 0
[00:18:31] Tick 1515453511 1
[00:18:32] Tick 1515453512 2
[00:18:33] Tick 1515453513 3
[00:18:33] Executing debug
[00:18:34] Shh bby it's okay
[00:18:35] Shh bby it's okay
[00:18:36] Shh bby it's okay
[00:18:37] Shh bby it's okay
[00:18:38] Shh bby it's okay
[00:18:40] Shh bby it's okay
[00:18:41] Shh bby it's okay

My conclusions so far:
1. I think I created compounding DebugHooks (though the function is called SetDebugHook, not AddDebugHook, so maybe just overwriting)
2. Timers are still executed? Are they implemented separately from amx_Exec flow? (#e: Oh, SetTimer is a native function, I followed the wrong train of thought)
3. Code inside timer callback however, is not executed! It seems AMX_ERR_SLEEP works correctly

Now I'll try resuming the amx execution. I've been spoiled with high level languages, so writing a timeout in C(++) is a new experience for me (I know I can't use "sleep" in main thread because it will result in false pausing of the execution and the whole point of checking if debug hook can pause exeuction will be moot)
Reply


Messages In This Thread
Loaded AMX viewer - by Misiur - 08.01.2018, 12:30
Re: Loaded AMX viewer - by DRIFT_HUNTER - 08.01.2018, 12:47
Re: Loaded AMX viewer - by maddinat0r - 08.01.2018, 18:49
Re: Loaded AMX viewer - by Misiur - 08.01.2018, 22:36
Re: Loaded AMX viewer - by Misiur - 17.01.2018, 22:24
Re: Loaded AMX viewer - by Crystallize - 18.01.2018, 01:48
Re: Loaded AMX viewer - by [HLF]Southclaw - 18.01.2018, 11:20
Re: Loaded AMX viewer - by Y_Less - 18.01.2018, 15:34

Forum Jump:


Users browsing this thread: 1 Guest(s)