SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Plugin Development

Reply
 
Thread Tools Display Modes
Old 31/12/2010, 04:15 PM   #1
IllidanS46
Banned
 
Join Date: Sep 2009
Posts: 37
Reputation: 14
Question Call native functions, hook callbacks

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

Last edited by IllidanS46; 31/12/2010 at 06:06 PM.
IllidanS46 is offline   Reply With Quote
Old 31/12/2010, 06:43 PM   #2
jaymac407
Little Clucker
 
Join Date: Jun 2009
Posts: 19
Reputation: 0
Default Re: Call native functions, hook callbacks

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.
jaymac407 is offline   Reply With Quote
Old 31/12/2010, 08:31 PM   #3
IllidanS46
Banned
 
Join Date: Sep 2009
Posts: 37
Reputation: 14
Default Re: Call native functions, hook callbacks

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?

Last edited by IllidanS46; 01/01/2011 at 11:51 AM.
IllidanS46 is offline   Reply With Quote
Old 01/01/2011, 11:33 AM   #4
Momo5000
Little Clucker
 
Join Date: Aug 2009
Posts: 43
Reputation: 0
Default Re: Call native functions, hook callbacks

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

This will help you for sure. :]
__________________
Code:
*red+u ?a???? v says:
 teach me
 how u fuck so nice girls?
 Nejc says:
 You need a chocolate penis that ejucates money
Momo5000 is offline   Reply With Quote
Old 02/01/2011, 11:15 AM   #5
IllidanS46
Banned
 
Join Date: Sep 2009
Posts: 37
Reputation: 14
Default Re: Call native functions, hook callbacks

Ok, about hooking I know enough, but I still don't know how to correctly call native functions.
IllidanS46 is offline   Reply With Quote
Old 27/02/2011, 03:40 PM   #6
IllidanS46
Banned
 
Join Date: Sep 2009
Posts: 37
Reputation: 14
Default Re: Call native functions

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!
IllidanS46 is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[Include] [INC]Area functions and callbacks. Backwardsman97 Includes 8 04/11/2011 07:09 AM
[Tutorial] How to hook FUNCTIONS (not callbacks) Luka P. Tutorials 17 13/06/2011 05:35 PM
Useful Functions and Callbacks Re-release Larcius Filterscripts 12 24/06/2010 03:34 PM
ReDefining native functions Calix Help Archive 2 16/09/2009 09:43 PM


All times are GMT. The time now is 11:34 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.