SA-MP Forums Archive
command returns 0 once again - 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: command returns 0 once again (/showthread.php?tid=607213)



command returns 0 once again - TheSimpleGuy - 16.05.2016

Harro zer ma ferrow SAMP-mates this command returns 0 or "Unknown command" to me. Is there any error?
Код:
GetPlayerRank(playerid)
{
	new string[128];
	for(new i = 0; i < sizeof(rInfo[]); i++)
	{
	    if(GetPlayerScore(playerid) >= rInfo[i][ScoreMin] && GetPlayerScore(playerid) < rInfo[i][ScoreMax])
	    {
	        format(string, sizeof(string), rInfo[i][Name]);
	        return string;
		}
	}
	return string;
}
CMD:ranks(playerid, params[])
{
	new string[1000];
	for(new i = 0; i < sizeof(rInfo[]); i++)
	{
 		format(string, sizeof(string), "%s (%d - %d)\n", GetPlayerRank(playerid), rInfo[i][ScoreMin], rInfo[i][ScoreMax]);
	}
	ShowPlayerDialog(playerid, d_rank, DIALOG_STYLE_MSGBOX, "Ranks", string, "OK", "");
	return 1;
}



Re: command returns 0 once again - Konstantinos - 16.05.2016

Change sizeof(rInfo[]) to sizeof(rInfo). The first one would be valid only if you have a 2D, 3D array and wanted to get the size of the second dimension. Note that it would not work with enumerators.


Re: command returns 0 once again - TheSimpleGuy - 16.05.2016

Thank you