Pawn compiler library stopped working...What's wrong with this code?
#1

I've looked through the following code several times and am seriously unsure of what's wrong with it. The last time I compiled--back before I wrote any of this command--my script was running error-free (did have a few warnings due to some unused variables which I'll be implementing in time, but of course, insignificant to the point of being ignored), now it's apparently broken to the point of the compiler repeatedly stopping immediately after I press "Compile" in Pawno.

Can someone help with the analysis and find what I've done wrong here? I'm so confused. (Note: There are some indenting derps whose onus is on the forum, not myself).

Код:
CMD:help(playerid,params[])
{
	new command[128],suggestions[4][128],temp[128];
	new success = 0;
	new sugcount = 0;
	new tracksug = 1;
	new fm[128] = "Error: Could not find any matches for the specified command. (Entered \"%s\").";
	if(!sscanf(params,"s",command))
	{
	    new commandArray[2][3][128] = {{"/admin","/admin [optional: id] [optional:1/0] (Must enter at least one parameter)","Returns if a player is admin or can be used to give or take admin status."},{"/help","/help /[command]","Returns information about the entered command (must include slash before command)"}};
	    if(command[0] == "/")
	    {
	        new i;
	        for(i = 0; i < sizeof(commandArray); i++)
	        {
				if(command == commandArray[i][0])
				{
				    SuccessMessage(playerid,commandArray[i][1]);
				    SuccessMessage(playerid,commandArray[i][2]);
				    success = 1;
				} else if(tracksug == 1)
				{
                                        strmid(suggestions[sugcount],commandArray[i][0],0,sizeof(command),sizeof(suggestions[sugcount]);
					if(strcmp(command,suggestions[sugcount]))
					{
					    sugcount++;
					    if(sugcount == 4) tracksug = 0;
					} else {
					    suggestions[sugcount] = "";
					}
				} else if(tracksug == 0)
				{
					strmid(temp,commandArray[i][0],0,sizeof(command),sizeof(suggestions[sugcount]);
					if(strcmp(command,temp))
					{
					    sugcount++;
					}
				}
	        }
	        if(i == sizeof(commandArray) && success == 0)
	        {
	            if(sugcount == 0)
	            {
	            	format(fm,sizeof(fm),fm,command);
	            	ErrorMessage(playerid,fm);
	            } else if(sugcount  > 0)
	            {
	                if(tracksug == 1)
	                {
	                    fm = "Error: Found %i similar commands, but no exact match. (Entered \"%s\"):";
	                    new fm2[128];
	                    if(sugcount == 1)
	                    {
	                        fm2 = "%s";
				format(fm2,sizeof(fm2),fm2,suggestions[0]);
	                    } else if(sugcount == 2)
	                    {
	                        fm2 = "%s or %s";
	                        format(fm2,sizeof(fm2),fm2,suggestions[0],suggestions[1],"","");
	                    } else if(sugcount == 3)
	                    {
	                        fm2 = "%s, %s, or %s";
	                        format(fm2,sizeof(fm2),fm2,suggestions[0],suggestions[1],suggestions[2],"");
	                    } else if(sugcount == 4)
	                    {
	                        fm2 = "%s, %s, %s, or %s";
	                        format(fm2,sizeof(fm2),fm2,suggestions[0],suggestions[1],suggestions[2],suggestions[3]);
	                    }
	                	format(fm,sizeof(fm),fm,sugcount,command);
		} else if(tracksug == 0)
		{
			fm = "Error: Found over 4 similar commands (Entered \"%s\"):";
	                new fm2 = "%s, %s, %s, %s, and %i unshown others (use /commands to see all existing commands)";
	                    format(fm,sizeof(fm),fm,command);
                         format(fm2,sizeof(fm2),fm2,suggestions[0],suggestions[1],suggestions[2],suggestions[3],sugcount - 4);
					}
	            }
	        }
	    } else {
	        ErrorMessage(playerid,"USAGE: /help /[command]");
	    }
	} else if(sscanf(params,"s",command)){
	    ErrorMessage(playerid,"USAGE: /help /[command]");
	}
	return 1;
}
Reply
#2

I can't find any unusual things in this code. Try commenting if statement for if statement (including the opening and closing brackets of that statement), and check when it compiles. That way you might find which part of the code is causing the problem. When you find it, check if you see the problem, if not, post the crashing code here. I know, it's kind of a shitty job, but that's the only way as I see it.
For the information of others, the brackets are not the problem here, there are 24 '{' brackets and 24 '}' brackets. I hope you can find the problem.
Reply
#3

Quote:
Originally Posted by Jstylezzz
Посмотреть сообщение
I can't find any unusual things in this code. Try commenting if statement for if statement (including the opening and closing brackets of that statement), and check when it compiles. That way you might find which part of the code is causing the problem. When you find it, check if you see the problem, if not, post the crashing code here. I know, it's kind of a shitty job, but that's the only way as I see it.
For the information of others, the brackets are not the problem here, there are 24 '{' brackets and 24 '}' brackets. I hope you can find the problem.
Perfect. Fixed it Apparently, there was a fatal error going on higher up in the code (I guess I did do something else before the last compile) involving the use of an optional argument (in the val = -1 format, not using ...) in a public function. Sorted that out as well as about 20 other bugs all across the code (including in the help function in places where strcmp should've been used instead of ==). Thanks for the help, repped
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)