SA-MP Forums Archive
String problems with plugin - 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: String problems with plugin (/showthread.php?tid=288578)



String problems with plugin - iPLEOMAX - 08.10.2011

(It's a help topic)

So, I'm at the last part of my plugin but I'm facing some troubles retrieving strings.

I have this in my script:

C++
Код:
char *StoredString[10];

//PAWN Native: SetString(slotid, string[]);
static cell AMX_NATIVE_CALL SetString( AMX* amx, cell* params )
{
	int slotid = params[1];
	char *inputstring;

	amx_StrParam(amx, params[2], inputstring);
	StoredString[slotid] = inputstring;
	
	return 1;
}

//PAWN Native: GetString(slotid, returnstring[]);
static cell AMX_NATIVE_CALL GetString( AMX* amx, cell* params )
{
	int slotid = params[1];

	cell* return_str;
	amx_GetAddr(amx, params[2], &return_str);
	amx_SetString ( tdstr, StoredString[slotid], 0, 0, 128);
	
	return 1;
}
But sometimes i get this returned: "¶ШW\МММММММММММйИ™\4ъ]ьџ\ђ@"

What am I doing wrong here? Should i convert it? :/

Don't go hard on me, I'm not an experienced c++ scripter.

EDIT: Solved with some alternative methods.


Re: String problems with plugin - iggy1 - 08.10.2011

Код:
static cell AMX_NATIVE_CALL GetString( AMX* amx, cell* params )
{
	int slotid = params[1];

	cell* return_str;
	amx_GetAddr(amx, params[2], &return_str);
	amx_SetString ( return_str, StoredString[slotid], 0, 0, StoredString[slotid].size());//pass the address fetched by amx_GetAddr
	
	return 1;
}



Re: String problems with plugin - Terminator3 - 08.10.2011

Код:
char *StoredString[10];
Код:
StoredString[slotid] = inputstring;
why you have this * ?


Re: String problems with plugin - Gamer_Z - 08.10.2011

I recommend you to look in the Gvar Plugin source, or my INI plugin (which is a very simple plugin) >> https://sampforum.blast.hk/showthread.php?tid=220743