Pawn compiler crashes, if/else if statement
#1

Code:
	
new name[24], string[2];

GetPlayerName(playerid, name, sizeof(name));
if(sscanf(name, "{p<_>s[12]s[12]}") != 0)
{
	SendClientMessage(playerid, 0xFFFFFFFF, "* Invalid roleplay username, kicked.");
	DelayedKick(playerid);
}
else if
{
	for(new i = 0; i < 10; i ++)
	{
		format(string, sizeof(string), "%d", i);
		if(strfind(name, string, true) != -1)
		{
			SendClientMessage(playerid, 0xFFFFFFFF, "* Invalid roleplay username, kicked.");
			DelayedKick(playerid);
		}
	}
}
else
{
	//code...
}
Coming back to Pawn, working on a sample script. What that snippet does it to check a connecting user's username, and see if it follows the Firstname_Lastname format. If I compile that script, the compiler crashes after 10 seconds +/-. Not sure what the issue is, any help would be appreciated at this point.
Reply
#2

Code:
format(string, sizeof(string), "%d", i);
You are detecting name, why number comes here in the string? It is telling the script, find the number in the name, if no number found, kick him.

[/hr]
Code:
if(sscanf(name, "{p<_>s[12]s[12]}") != 0)
Try using something else?
Code:
if( sscanf( name, "p<_>s[12]s[12]" ))
Reply
#3

Else if ... what? If what? There should be a condition there.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)