SA-MP Forums Archive
Function should return a value?! - 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: Function should return a value?! (/showthread.php?tid=584253)



Function should return a value?! - AndOneMoreTime - 03.08.2015

Wassup community,

today i have a little bit of a bad problem, so lets say what it is:

Код:
warning 209: function "fdeleteline" should return a value
But, i am returning the value via the return 1;

Here is the snippet of the code:

Код:
stock fdeleteline(filename[], line[])
{
if(fexist(filename)){
new temp[256];
new File:fhandle = fopen(filename,io_read);
fread(fhandle,temp,sizeof(temp),false);
if(strfind(temp,line,true)==-1){return 0;}
else{
fclose(fhandle);
fremove(filename);
for(new i=0;i<strlen(temp);i++){
new templine[256];
strmid(templine,temp,i,i+strlen(line));
if(strcmp(templine,line,true)){
strdel(temp,i,i+strlen(line));
fcreate(filename);
fhandle = fopen(filename,io_write);
fwrite(fhandle,temp);
fclose(fhandle);
return 1;
}
}
}
}
}



Re: Function should return a value?! - Zonoya - 03.08.2015

That IS a bit odd, I put it into my compiler, putting in proper indents, so it looked like this:

Код:
stock fdeleteline(filename[], line[])
{
    if(fexist(filename)){
        new temp[256];
	new File:fhandle = fopen(filename,io_read);
	fread(fhandle,temp,sizeof(temp),false);
	if(strfind(temp,line,true)==-1){return 0;}
	else{
	    fclose(fhandle);
	    fremove(filename);
	    for(new i=0;i<strlen(temp);i++){
	        new templine[256];
		strmid(templine,temp,i,i+strlen(line));
		if(strcmp(templine,line,true)){
		    strdel(temp,i,i+strlen(line));
		    fcreate(filename);
		    fhandle = fopen(filename,io_write);
		    fwrite(fhandle,temp);
		    fclose(fhandle);
		    return 1;
		}
	    }
	}
    }
}
And it compiled without any errors for me. Try that indented version, and see what happens, perhaps?


Re: Function should return a value?! - AndOneMoreTime - 03.08.2015

Already fixed, just added return above the last bracket.