SA-MP Forums Archive
Looping Error - 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: Looping Error (/showthread.php?tid=553364)



Looping Error - LivingLikeYouDo - 29.12.2014

I am getting this strange error while looping through player textdraws;
pawn Код:
for(new weapon = 0, weapon < 30, weapon++) //Error lines
    {
        PlayerTextDrawShow(playerid, TDEditor_PTD[playerid][weapon]);
    }
Код:
G:\San Andreas Multiplayer\Other works\filterscripts\WeaponShopTextBased.pwn(863) : error 021: symbol already defined: "weapon"
G:\San Andreas Multiplayer\Other works\filterscripts\WeaponShopTextBased.pwn(863) : warning 204: symbol is assigned a value that is never used: "weapon"



Re: Looping Error - AndySedeyn - 29.12.2014

That means you already have a variable defined as 'weapon'.


Re: Looping Error - LivingLikeYouDo - 29.12.2014

Quote:
Originally Posted by Bible
Посмотреть сообщение
That means you already have a variable defined as 'weapon'.
*negative nod*
I only have player textdraws made on OnPlayerConnect and this command.


Re: Looping Error - AndySedeyn - 29.12.2014

Oh, my bad.
I took a further look at your code and I noticed the mistake.

Replace the commas with semicolons.
You are basically redefining the same variable over and over again on the same line.

May I also refer you to the SA:MP wiki to show you when to use commas in a loop:
https://sampwiki.blast.hk/wiki/Keywords:Statements#for


Re: Looping Error - LivingLikeYouDo - 29.12.2014

Quote:
Originally Posted by Bible
Посмотреть сообщение
Oh, my bad.
I took a further look at your code and I noticed the mistake.

Replace the commas with semicolons.
You are basically redefining the same variable over and over again on the same line.
*facepalms*
Dang it, thanks. I don't know why I was such a nub to forget that (looks like this sums up my past reasons to end my projects because of a loop error, lol)

+1

PS: If i use this loop, will it only show the first 30 textdraws out of 69?


Re: Looping Error - AndySedeyn - 29.12.2014

Quote:
Originally Posted by LivingLikeYouDo
Посмотреть сообщение
PS: If i use this loop, will it only show the first 30 textdraws out of 69?
Of course, you are limiting the loop:
Код:
w < 30
It will show the first 29 textdraws.


Re: Looping Error - LivingLikeYouDo - 29.12.2014

Alright, thanks!