String problems with plugin
#1

(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.
Reply
#2

Код:
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;
}
Reply
#3

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

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
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)