Call native functions, hook callbacks
#1

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

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.
Reply
#3

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?
Reply
#4

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

This will help you for sure. :]
Reply
#5

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

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!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)