Error: Same codes in different sections.
#1

They are in different sections but it says already defined. What is wrong with it?
Code:
(6577) : error 021: symbol already defined: "i"
pawn Code:
StartDeathmatch()
{
    if(gamemap == 0) //aim_headshot
    {
        Load_aim_headshot(); //Load map
        for(new i=0;i<MAX_PLAYERS;i++)
        {
            InGame[i] = deathmatch;
            SetPlayerInterior(i,0);
            SetPlayerVirtualWorld(i,0);
            new Float:RandomAimSpawns[][] =
            {
                {-2472.0415,1828.5179,14.1092},
                {-2440.8843,1678.2205,14.1086}
            };
            new Random = random(sizeof(RandomAimSpawns));
            SetPlayerPos(i, RandomAimSpawns[Random][0], RandomAimSpawns[Random][1], RandomAimSpawns[Random][2]);
        }
    }
    if(gamemap == 1) //cargoship
    {
        Load_cargoship(); //Load map
        for(new i=0;i<MAX_PLAYERS;i++) // 6577
        {
            InGame[i] = deathmatch;
            SetPlayerInterior(i,0);
            SetPlayerVirtualWorld(i,0);
            new Float:RandomCargoSpawns[][] =
            {
                {763.9101,-3307.6133,26.0656,86.8335},
                {718.1553,-3315.2761,19.9088,357.3447},
                {592.6706,-3305.8057,38.8441,265.7879}
            };
            new Random = random(sizeof(RandomCargoSpawns));
            SetPlayerPos(i, RandomCargoSpawns[Random][0], RandomCargoSpawns[Random][1], RandomCargoSpawns[Random][2]);
        }
    }
}
Reply
#2

I don't think this is 100% true, but you might have to add this at the end of the loop.

pawn Code:
break;
Reply
#3

Quote:
Originally Posted by RealCop228
View Post
I don't think this is 100% true, but you might have to add this at the end of the loop.

pawn Code:
break;
No, break gives same error. Also I didn't understand what kind of error is this. Everything is so clear.
Reply
#4

I believe using else if on the second statement may fix this.
Reply
#5

I used else if as well in the first try but gave same error.
Reply
#6

Try looking above this code. I'm thinking there's a missing bracket or something.
Reply
#7

I have checked above of this but nothing there. I moved this StartDeathmatch in different parts of gamemode, also used in a command but still same error so I think the problem is in it.
Reply
#8

IIRC missing brackets cause 26 errors (max errors the pawn compiler will show before it says 'fuck it' and kills itself).

The error is pretty obvious; the variable 'i' is already defined/declared before it's use there. Do you have a global variable called 'i'? (VERY bad idea.)

Not sure about the brackets thing, check it out.

Try commenting out the entire function (everything inside, not the actual function itself) like so:

pawn Code:
stock Function(blah)
{
/*
your code is here
*/

}
Reply
#9

I haven't a global variable called "i". This problem is not occur in StartDeatmatch only. Also in OnPlayerSpawn in this:

pawn Code:
if(InGame[playerid] == deathmatch)
    {
        if(gamemap == 0) //aim_headshot
        {
            SetPlayerInterior(playerid,0);
            SetPlayerVirtualWorld(playerid,0);
            new Float:RandomSpawns[][] =
            {
                {-2472.0415,1828.5179,14.1092},
                {-2440.8843,1678.2205,14.1086}
            };
            new Random = random(sizeof(RandomSpawns));
            SetPlayerPos(playerid, RandomSpawns[Random][0], RandomSpawns[Random][1], RandomSpawns[Random][2]);
        }
        if(gamemap == 1) //cargoship
        {
            SetPlayerVirtualWorld(playerid,0);
            new Float:RandomSpawns[][] = //3247 but different statement -.-
            {
                {763.9101,-3307.6133,26.0656,86.8335},
                {592.6706,-3305.8057,38.8441,265.7879}
            };
            new Random = random(sizeof(RandomSpawns));
            SetPlayerPos(playerid, RandomSpawns[Random][0], RandomSpawns[Random][1], RandomSpawns[Random][2]);
        }
    }
Code:
(3247) : error 021: symbol already defined: "RandomSpawns"
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)