About calling natives from C
#8

A long time ago, I did this by Assembly and pointers, the pointers' way you already know, and here are the Assembly way with parameters calling too:

Код:
DWORD function = 0xEXAMPLE;
cell *params = (cell *)malloc(sizeof(cell) * FUNCTION_PARAM_COUNT + 1);
*params = FUNCTION_PARAM_COUNT * 4; //params[0] is "paramscount * 4"
cell retval;
//example calling the firat parameter as 5:
*(++params) = 5;
//etc

__asm
{
	PUSH params
	PUSH 0 //"amx" can be 0, or, if you like, use gamemode's amx, whatever...
	CALL function
	MOV retval, EAX
}
free(params);
logprintf("Return value: %d", retval);
Quote:
Originally Posted by MaVe - leeturl.de
Thanks, ******, but could you explain me why it worked perfectly with 1 parameter for IsPlayerConnected?

EDIT: I think I got that now, perhaps SA-MP's IsPlayerConnected native does not use pAMX which gets *playerid*, and since I only tried it alone (ID 0) it also worked with that.
passing (AMX*, cell*) does work fine however, thanks
Yes, it worked because you were ID 0, and parameters were invalid, so it was 0 too.
Reply


Messages In This Thread
About calling natives from C - by Streetplaya - 01.12.2009, 17:02
Re: About calling natives from C - by Google63 - 01.12.2009, 17:29
Re: About calling natives from C - by Streetplaya - 01.12.2009, 17:35
Re: About calling natives from C - by Google63 - 01.12.2009, 17:46
Re: About calling natives from C - by Streetplaya - 01.12.2009, 18:11
Re: About calling natives from C - by Google63 - 01.12.2009, 18:39
Re: About calling natives from C - by Streetplaya - 02.12.2009, 12:18
Re: About calling natives from C - by Toribio - 02.12.2009, 16:56
Re: About calling natives from C - by Incognito - 02.12.2009, 17:31
Re: About calling natives from C - by Streetplaya - 02.12.2009, 17:42

Forum Jump:


Users browsing this thread: 2 Guest(s)