SA-MP Forums Archive
Why Do we Use Loops? - 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 Do we Use Loops? (/showthread.php?tid=558257)



Why Do we Use Loops? - TheRaGeLord - 16.01.2015

Hello There, My Question is Why Do we Use Loops In a Code? For Example This Code:
pawn Код:
stock ShowInventory(playerid)
{
    new iteminv[20];//20 item 0->19
    for(new i = 0; i < 20;i++)// Get all form 0 to 19
    {
    iteminv[i] = InvInfo[playerid][iSlot][i];// Check item in slot
    if(InvInfo[playerid][iSlot][i] == 0) // if slot i no have item . it will return model '!'
    {
    iteminv[i] = 1239;// 1239 is model '!'
    }
   
    }
    ShowModelSelectionMenuEx(playerid, iteminv,20, "Inventory",INVENTORY_MENU, 0.0, 0.0,0.0);//mSelection
    return 1;
}
So, If now you must have read the Above Code.. So Some Explanation please?
Well... I'm Confused In This thing
pawn Код:
{
    iteminv[i] = InvInfo[playerid][iSlot][i];// Check item in slot
    if(InvInfo[playerid][iSlot][i] == 0) // if slot i no have item . it will return model '!'
    {
Here Why Do we Have put [i] After [iSlot]..
These are My Questions...



Re: Why Do we Use Loops? - TheRaGeLord - 16.01.2015

Well Thanx ****** i Now Understood That Why Do We Use Loop.. But Why We Had Used [i] After [iSlot]
pawn Код:
{
    iteminv[i] = InvInfo[playerid][iSlot][i];// Check item in slot
    if(InvInfo[playerid][iSlot][i] == 0) // if slot i no have item . it will return model '!'
    {



Re: Why Do we Use Loops? - TheRaGeLord - 17.01.2015

Okay Understood Thanx