Looping Error
#1

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"
Reply
#2

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

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

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

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?
Reply
#6

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

Alright, thanks!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)