SA-MP Forums Archive
Pawn compiler crashes, if/else if statement - 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: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Pawn compiler crashes, if/else if statement (/showthread.php?tid=635693)



Pawn compiler crashes, if/else if statement - Sublime - 12.06.2017

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.


Re: Pawn compiler crashes, if/else if statement - SoFahim - 12.06.2017

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]" ))



Re: Pawn compiler crashes, if/else if statement - Vince - 12.06.2017

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