SA-MP Forums Archive
Little help. - 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: Little help. (/showthread.php?tid=513048)



Little help. - Sanady - 14.05.2014

Hello everybody. I spotted new bug. But I don`t see any problem. This codes are for ordering one zone for spawn random zone.
pawn Код:
printf("0");
    for(new i = 1; i < 5; i++)
    {
        new RandomZone;
        printf("1");
        GenerateRandomZone:
        printf("2");
        RandomZone = random(sizeof(GangZones));
        printf("3");

        if(GangZones[RandomZone][OwnerTeam] != 0)
            goto GenerateRandomZone;
        printf("4");
        GangZones[RandomZone][OwnerTeam] = i;
        printf("5");
    }
Debug stucks at number 2.. please help me.


Re: Little help. - Sanady - 14.05.2014

Anyone? Sorry for double posting but it`s urgent


Re: Little help. - RajatPawar - 14.05.2014

First of all, avoid using 'goto.' (probably a recursive func) (AFAIK, that's what is USUALLY suggested)

Secondly, I have no idea what you're trying to do (If GangZones array is reset, I guess the first time you run this code, it will never be satisfied, right?)

Can you explain more? (where you set it, etc)


Re: Little help. - Sanady - 14.05.2014

Quote:
Originally Posted by RajatPawar
Посмотреть сообщение
First of all, avoid using 'goto.' (probably a recursive func) (AFAIK, that's what is USUALLY suggested)

Secondly, I have no idea what you're trying to do (If GangZones array is reset, I guess the first time you run this code, it will never be satisfied, right?)

Can you explain more?
Look code says. It`s taking random zone from array. In that array are coordinates of spawn,zone cordinates,then code is checking if team don`t have zone then it will generate zone automaticly and gave it to team. And bug is on point 2 that means on generating random zone.


Re: Little help. - RajatPawar - 14.05.2014

That's not helpful, I know what it does, I asked what you wanted it to do, and where you set 'OwnerTeam', etc. Why don't you add prints as to what "GangZones[RandomZone][OwnerTeam]" is, below where you use goto, it will kind of really help you resolve the issue.

pawn Код:
printf("Condition check: GangZones[%d][OwnerTeam]: Checking if (%d != 0)", RandomZone, GangZones[RandomZone][OwnerTeam]);



Re: Little help. - Sanady - 14.05.2014

Quote:
Originally Posted by RajatPawar
Посмотреть сообщение
That's not helpful, I know what it does, I asked what you wanted it to do, and where you set 'OwnerTeam', etc. Why don't you add prints as to what "GangZones[RandomZone][OwnerTeam]" is, below where you use goto, it will kind of really help you resolve the issue.

pawn Код:
printf("Condition check: GangZones[%d][OwnerTeam]: Checking if (%d != 0)", RandomZone, GangZones[RandomZone][OwnerTeam]);
Well here is print results
Код:
[13:03:58] 0
[13:03:58] 1
[13:03:58] Condition check: GangZones[0][OwnerTeam]: Checking if (0 != 0)
OwnerTeam is variable which checks who is owner of the zone which team.I have 4 teams on the server.