Multiple loops to create grid? - 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)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Multiple loops to create grid? (
/showthread.php?tid=69087)
Multiple loops to create grid? -
javind0 - 15.03.2009
(Ignore the GF referances, NOTHING to do with it)
So I was wondering if this was possible:
I made a command that resets all 'house cars' to one spot and that works but what if I want them to automatically go into a grid? Heres what I have so far but it doesn't work - just completes the first one over and over again non-stop.
pawn Код:
if(strcmp(cmd, "/rhc", true) == 0 || strcmp(cmd, "/resethousecars", true) == 0)
{
if(IsPlayerConnected(playerid))
{
new Float:myx;
new Float:myy;
new Float:myz;
new Float:mya;
GetPlayerPos(playerid, myx, myy, myz);
GetPlayerFacingAngle(playerid, mya);
if(PlayerInfo[playerid][pAdmin] >= 1337)
for (new i=1;i<=250;i++)
for (new x=5;x<=25;x++)
for (new y=5;x<=5000;y++)
{
CribInfo[i][hCarLocX] = myx+x;
CribInfo[i][hCarLocY] = myy+y;
CribInfo[i][hCarLocZ] = myz;
CribInfo[i][hCarLocA] = mya;
SendClientMessage(playerid, COLOR_GREEN, "Start house car reset...");
SendClientMessage(playerid, COLOR_GREEN, "-------------------------");
format(string, sizeof(string), "Car %d reset to %d %d %d facing %d degrees.", i, myx, myy, myz, mya);
SendClientMessage(playerid, COLOR_GREEN, string);
print(string);
SendClientMessage(playerid, COLOR_GREEN, "-------------------------");
SendClientMessage(playerid, COLOR_GREEN, "House car reset complete!");
OnPropUpdate();
SendClientMessageToAll(COLOR_GREEN, "An admin reset all house car positions. See forum.");
}
else
{
SendClientMessage(playerid, 0xFF000000, "You are not authorized to use that command!");
}
}
return 1;
}
Re: Multiple loops to create grid? -
Weirdosport - 15.03.2009
I can tell you now, this bit won't work:
pawn Код:
for (new i=1;i<=250;i++)
for (new x=5;x<=25;x++)
for (new y=5;x<=5000;y++)
Perhaps if they were nested, but that would make involve an INSANE number of loops.
Re: Multiple loops to create grid? -
javind0 - 15.03.2009
Quote:
Originally Posted by Weirdosport
I can tell you now, this bit won't work:
pawn Код:
for (new i=1;i<=250;i++) for (new x=5;x<=25;x++) for (new y=5;x<=5000;y++)
Perhaps if they were nested, but that would make involve an INSANE number of loops.
|
How many? O:
I was thinking maybe a loop per row? Then each row has a new row1 = i*5 or something? :V
Re: Multiple loops to create grid? -
Weirdosport - 15.03.2009
Well if those loops were nested.
Around 24975000 loops. (250 * 20 * 4995)