Why does this only show the most recent created house? - 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: Why does this only show the most recent created house? (
/showthread.php?tid=509442)
Why does this only show the most recent created house? -
AphexCCFC - 26.04.2014
pawn Код:
CMD:houses(playerid, params[])
{
new string[500];
if(!IsPlayerLoggedIn(playerid))
{
SendClientMessage(playerid, COLOR_RED, "Error"White": You are restricted from using commands until you log in.");
return 1;
}
if(PlayerInfo[playerid][pAdminLevel] < 1)
{
SendClientMessage(playerid, COLOR_RED, "Error"White": You do not have the authority to use this command.");
return 1;
}
if(!AdminDuty[playerid])
{
SendClientMessage(playerid, COLOR_RED, "Error"White": You are not on duty as an Administrator (/aduty).");
return 1;
}
for(new i = 0; i < MAX_HOUSES; i++)
{
if(HouseInfo[i][hHouseID] == i)
{
format(string, sizeof(string), "ID: %d - Address: %s - Owner: %s", HouseInfo[i][hHouseID], HouseInfo[i][hAddress], HouseInfo[i][hOwner]);
ShowPlayerDialog(playerid, DIALOG_HOUSES, DIALOG_STYLE_LIST, ""Lightblue"House List", string, "", "Cancel");
}
else
{
SendClientMessage(playerid, COLOR_RED, "Error"White": There are no houses created.");
return 1;
}
}
return 1;
}
Hello. When I type /houses it only shows the most recent created house but I need it to show all created houses as a list.
Re: Why does this only show the most recent created house? -
Nathan_Taylor - 26.04.2014
What is MAX_HOUSES set to?
Re: Why does this only show the most recent created house? -
Vince - 26.04.2014
NEVER return inside a loop unless you explicitly want to break it. You can't possibly know how many houses are created until you've gone through the entire loop.