SA-MP Forums Archive
Call native functions, hook callbacks - 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: Call native functions, hook callbacks (/showthread.php?tid=205179)



Call native functions, hook callbacks - IllidanS46 - 31.12.2010

Hello, can you help me how to call effectively native functions and hook callbacks (OnPlayerConnect) in plugin?


Re: Call native functions, hook callbacks - jaymac407 - 31.12.2010

To hook native functions, just put your plugins function inside the callback you want to hook, e.g.:
Code:
public OnGameModeInit()
{
	return NET_OnGameModeInit();
}
All functions are different, and you'll have to do some godmode reading through AMX and SA-MP SDK.


Re: Call native functions, hook callbacks - IllidanS46 - 31.12.2010

I found a way to call native function:
SetWeather(weather)
Code:
cell* params = (cell*)malloc(8);
params[0] = 4;
params[1] = 5; //weather 5
int idx;
amx_FindNative(amx, "SetWeather", &idx);
cell result;
amx_Callback(amx, idx, &result, params);
free(params);
When I first run it, weather has set to 5, but next time weather has set to 96 (0x60) and never more changed. Does anyone know where the problem is?


Re: Call native functions, hook callbacks - Momo5000 - 01.01.2011

http://en.wikipedia.org/wiki/Hooking

This will help you for sure. :]


Re: Call native functions, hook callbacks - IllidanS46 - 02.01.2011

Ok, about hooking I know enough, but I still don't know how to correctly call native functions.


Re: Call native functions - IllidanS46 - 27.02.2011

Quote:
Originally Posted by IllidanS4
View Post
Ok, about hooking I know enough, but I still don't know how to correctly call native functions.
Please help!