SA-MP Forums Archive
Should return a value but already returns 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: Should return a value but already returns a value?! (/showthread.php?tid=638619)



Should return a value but already returns a value?! - grymtn - 03.08.2017

Hello guys its me again and im really confused. I know this is not actually a problem but heres my code.

it tells me that cmd_setrentable should return a value. Anyone has any idea ?

Код:
CMD:setrentable(playerid,params[])
{
    new playName[MAX_PLAYER_NAME]; 
    GetPlayerName(playerid, playName, MAX_PLAYER_NAME);
    for(new i = 0; i < MHOUSE; i++) 
        if(!strcmp(hInfo[i][howner], playName, false)) 
        {
            if(hInfo[i][rentable] == false)
			{
			    hInfo[i][rentable] = true;
			    SCM(playerid,COLOR_GREY,"You should now set rent price by /setrentprice");
			    savehouse(i);
			    return 1;
			}
            if(hInfo[i][rentable] == true)
			{
			    hInfo[i][rentable] = false;
			    SCM(playerid,COLOR_GREY,"House is now not rentable.");
			    savehouse(i);
			    return 1;
			}
        }
	}
	return 1;
}



Re: Should return a value but already returns a value?! - Vince - 03.08.2017

Indent properly. Your return is actually outside your function. Frankly I don't understand how this doesn't crash the compiler.


Re: Should return a value but already returns a value?! - grymtn - 03.08.2017

yes i have syntax count wrong why tho
Код:
CMD:setrentable(playerid,params[])
{ //open1
    new playName[MAX_PLAYER_NAME]; 
    GetPlayerName(playerid, playName, MAX_PLAYER_NAME);
    for(new i = 0; i < MHOUSE; i++) 
        if(!strcmp(hInfo[i][howner], playName, false)) 
        {//open2
            if(hInfo[i][rentable] == false)
			{//open3
			    hInfo[i][rentable] = true;
			    SCM(playerid,COLOR_GREY,"You should now set rent price by /setrentprice");
			    savehouse(i);
			    return 1;
			}//close3
            if(hInfo[i][rentable] == true)
			{//open4
			    hInfo[i][rentable] = false;
			    SCM(playerid,COLOR_GREY,"House is now not rentable.");
			    savehouse(i);
			    return 1;
			}//close4
        }//close2
}//close1
	return 1;
}//??
found it

Код:
CMD:setrentable(playerid,params[])
{ //open1
    new playName[MAX_PLAYER_NAME]; 
    GetPlayerName(playerid, playName, MAX_PLAYER_NAME);
    for(new i = 0; i < MHOUSE; i++) 
{//foropen THIS WAS MISSING
        if(!strcmp(hInfo[i][howner], playName, false)) 
        {//open2
            if(hInfo[i][rentable] == false)
			{//open3
			    hInfo[i][rentable] = true;
			    SCM(playerid,COLOR_GREY,"You should now set rent price by /setrentprice");
			    savehouse(i);
			    return 1;
			}//close3
            if(hInfo[i][rentable] == true)
			{//open4
			    hInfo[i][rentable] = false;
			    SCM(playerid,COLOR_GREY,"House is now not rentable.");
			    savehouse(i);
			    return 1;
			}//close4
        }//close2
}//forclose
	return 1;
}//close1