[SOLVED!] Strings as reference parameters...
#1

Hi,

I'm trying to use a string as a reference parameter in a plugin I'm creating.

So far I have this:

Code:
//native Test(string[], size);
static cell AMX_NATIVE_CALL n_Test( AMX* amx, cell* params )
{
	char * string;
	sprintf(string,"test: %d", 1234);
	cell *buf;
	amx_GetAddr(amx, params[1], &buf);
	amx_SetString(buf, string, 0, 0, params[2]);
	return 1;
}
I'm pretty sure It's wrong, because when I try to do this in a gamemode:

pawn Code:
new teststring[16];
Test(teststring,sizeof(teststring));
SendClientMessage(playerid,0xFF000000, teststring);
That code causes the server to crash.

If anyone knows how to get this working, or can tell me what I'm doing wrong, I'd be appreciative of any help.

Thanks in advance,
CodeMatrix

EDIT: It does crash the server.
Reply


Messages In This Thread
[SOLVED!] Strings as reference parameters... - by XPlatform - 23.08.2009, 06:29
Re: Strings as reference parameters... - by XPlatform - 23.08.2009, 11:29
Re: Strings as reference parameters... - by XPlatform - 23.08.2009, 22:40

Forum Jump:


Users browsing this thread: 1 Guest(s)