Multiple loops to create grid?
#1

(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;
    }
Reply
#2

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.
Reply
#3

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
Reply
#4

Well if those loops were nested.

Around 24975000 loops. (250 * 20 * 4995)
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)