Skip to content

kustom specifier and space #7

@kryosaurr

Description

@kryosaurr

Hello, i have a sscanf custom specifiers to check if gang name is exists.
Here is my code:

SSCANF:gang(string[])
{
	printf("SSCANF:gang string is \"%s\"", string);
	new ret;
	if ('0' <= string[0] <= '9')
	{
		ret = strval(string);
		if(Iter_Contains(Gangs, ret))
			return ret;
	}

	foreach(new i : Gangs)
	{
		if(!strcmp(g_Gang[i][gname], string, true))
			return i;
	}
	return -1;
}

The problem is, it doesn't work while i'm trying to find a gang that have spaces in it.
I've debugged that code by printing "string" variable, and i found out that the string is getting cut off at space.

new testname[12] = "Gang name", id;
sscanf(testname, "k<gang>", id); // Prints SSCANF:gang string is "Gang"
testname = "Gang_name";
sscanf(testname, "k<gang>", id); // Prints SSCANF:gang string is "Gang_name"

I also tested it with default weapon kustom specifier,

sscanf("Brass Knuckles", "k<weapon>", id); // prints "Brass", id = -1
sscanf("Knife", "k<weapon>", id); // Works fine

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions