SA-MP Forums Archive
Problem Symbol Already Defined - 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: Problem Symbol Already Defined (/showthread.php?tid=392454)



Problem Symbol Already Defined - shaPP - 14.11.2012

I have an swith with different 'cases'. I defined some variables under one case and if i define same variables under another case it say 'symbol already defined' for some of theese variables.

Код:
new string[128], banned, resultline[512], BanTime, Name[24], BanIP[24];
			new BanBy[24], BanReason[24], BanDate[24], BanExpire[24], BanCode[24], time[6][24];
			new y,m,d,y2,m2,d2;
			new h,mi,s,h2,mi2,s2;
I get error for:

Код:
new string[128], banned, resultline[512], BanTime, Name[24], BanIP[24];
			new BanBy[24], BanReason[24], BanDate[24], BanExpire[24], BanCode[24], time[6][24];
Because theese variables are defined under another case but i don't get any error for:

Код:
new y,m,d,y2,m2,d2;
			new h,mi,s,h2,mi2,s2;
Can someone explain me why?


Re: Problem Symbol Already Defined - Konstantinos - 14.11.2012

If you're using them above, there's no need to define them again. Just delete the variables it gives the symbol already defined.


Re: Problem Symbol Already Defined - shaPP - 14.11.2012

That i did for:

Код:
new string[128], banned, resultline[512], BanTime, Name[24], BanIP[24];
			new BanBy[24], BanReason[24], BanDate[24], BanExpire[24], BanCode[24], time[6][24];
But not for:

Код:
new y,m,d,y2,m2,d2;
			new h,mi,s,h2,mi2,s2;
y, m, d, y2, m2.... still be defined above and i don't get any error with symbol already defined and can't understand why i don't get error for all variables that are already defined ...


Re: Problem Symbol Already Defined - Konstantinos - 14.11.2012

Maybe because the first variables are a lot. If you delete them, you may got the rest of the errors. This is something compiler does frequently. Anyway, define them at the start and delete the rest, it is no need.


Re: Problem Symbol Already Defined - shaPP - 14.11.2012

I did it too but if i delete theese:
Код:
new y,m,d,y2,m2,d2;
new h,mi,s,h2,mi2,s2;
From the 2nd 'case' it say that theese symbols aren't defined, but theese are in first case.


Re: Problem Symbol Already Defined - Konstantinos - 14.11.2012

pawn Код:
// This is the start.
{
    new
        x
    ;
    // define the rest here, it is just an example
    switch( x )
    {
        case 0: // Do something
        case 1: // Do something else
    }
    // Rest of code



Re: Problem Symbol Already Defined - shaPP - 14.11.2012

Yea that is how i did it finally but I was thinking why if i have two variable defined in two difference case i get error for symbol already defined for only one variable ...
Ex:
Код:
switch( x )
{
         case 0:
         {
                  new x, y;
         }
         case 1:
         {
                  new x, y:
         }
}
And got error only for Y in 2nd case. That's how was my problem, fixed it moving definition of variables before switch but i didn't understant why i got this error :d