Is looping in that way wrong?
#1

Greetings,

pawn Код:
//underneath an other function
SetTimer("CheckPlayers", 1000, 1);
Код:
The function which is causing : Run time error 3: "Stack/heap collision (insufficient stack size)"
pawn Код:
public CheckPlayers()
{
    foreach(new i : Player)
    {
        if(IsPlayerInWater(i))
        {
            OnPlayerLoseDerby(i);
        }
        if(PlayerCount == 1 && PlayerIsPlaying[i] == 1)
        {
            TogglePlayerControllable(i, 0);
           
            new str[100];
            format(str, sizeof(str), "Winner is: %s", GetPlayerNameEx(i));
            SendClientMessage(i,GREEN, str);
            if(PlayerIsPlaying[i] == 1){
                GivePlayerMoney(i, 1000); }

            PlayerIsPlaying[i] = 0;
            DerbyStart = 0;
            NextMap();
        }
        if(PlayerCount == 0 && PlayerIsPlaying[i] == 0)
        {
            TogglePlayerControllable(i, 0);
           
            SendClientMessage(i,GREEN, "No Winner");
            PlayerIsPlaying[i] = 0;
            DerbyStart = 0;
            KillTimer(DetectPlayer);
            NextMap();
        }
    }
    return 1;
}
Am I doing it wrong? Thanks in advance!
Reply
#2

A day passed...
Reply
#3

try this ?

pawn Код:
public CheckPlayers()
{
    foreach(new i : Player)
    {
        if(IsPlayerInWater(i))
        {
            OnPlayerLoseDerby(i);
        }
        if(PlayerCount == 1 && PlayerIsPlaying[i] == 1)
        {
            TogglePlayerControllable(i, 0);
           
            new str[100];
            format(str, sizeof(str), "Winner is: %s", GetPlayerNameEx(i));
            SendClientMessage(i,GREEN, str);
            if(PlayerIsPlaying[i] == 1){
                GivePlayerMoney(i, 1000); }

            PlayerIsPlaying[i] = 0;
            DerbyStart = 0;
            NextMap();
        }
        else if(PlayerCount == 0 && PlayerIsPlaying[i] == 0)
        {
            TogglePlayerControllable(i, 0);
           
            SendClientMessage(i,GREEN, "No Winner");
            PlayerIsPlaying[i] = 0;
            DerbyStart = 0;
            KillTimer(DetectPlayer);
            NextMap();
        }
    }
    return 1;
}
Reply
#4

no effect, (what adjustments have you made?) I can see nothing..
Reply
#5

just add else after if

btw compile your script with -d2 mode to get error line
Reply
#6

Quote:
Originally Posted by rickisme
Посмотреть сообщение
btw compile your script with -d2 mode to get error line
how?
Reply
#7

https://github.com/Zeex/samp-plugin-...ith-debug-info
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)