Loop issue
#1

hi
everything what is in loops is not callin, instead of prints that i put before have called properly.
what is wroooong?

Код:
forward starttime(playerid, vehicleid);
public starttime(playerid, vehicleid)
{
	static str[16];
	static amount = 30;
	static amount2 = 4;
	if(amount <= 0)
	{
	    IsStarted[0] = true;
	    amount2 = amount2-1;
	    format(str, sizeof(str), "%i", amount2);
		
		for(new i;i<8;i++)
		{
		    if(GrottiTPlayer[i] == -1)
		    {
		        GameTextForPlayer(i, str, 1200, 3);
		        PlayerPlaySound(i, 1056, 0, 0, 0);
		        SetCameraBehindPlayer(i);
		        TextDrawHideForPlayer(i, GrottiT[0]);
		        TextDrawHideForPlayer(i, GrottiT[1]);
		        TextDrawHideForPlayer(i, GrottiT[2]);
		        TextDrawHideForPlayer(i, GrottiT[3]);
		        TextDrawHideForPlayer(i, GrottiT[4]);
		        TextDrawHideForPlayer(i, GrottiT[5]);
		        TextDrawHideForPlayer(i, GrottiT[6]);
		        TextDrawHideForPlayer(i, GrottiT[7]);
		        TextDrawHideForPlayer(i, GrottiT[8]);
		        TextDrawHideForPlayer(i, GrottiT[9]);
		        TextDrawHideForPlayer(i, GrottiT[10]);
		    }
		}
		
	    if(amount2 <= 0)
	    {
	        KillTimer(tstarttime);
			for(new i; i < 8; i++)
			{
				if(GrottiTPlayer[i] == -1)
				{
	                TogglePlayerControllable(i, 1);
	                GameTextForPlayer(i, "GO!", 1000, 3);
	                PlayerPlaySound(i, 1057, 0, 0, 0);
	                SetPlayerRaceCheckpoint(i,0,617.816467,-1214.835815,17.872802,632.711059,-1399.011596,13.103024,6); /* Rodeo */
	                GrottiTCP[i] = 1;
                }
			}
	    }
	}
	amount = amount-1;
	format(str, sizeof(str), "Start ~y~%i", amount);
	TextDrawSetString(GrottiT[10], str);
	if(amount >= 1)
		TextDrawShowForPlayer(playerid, GrottiT[10]);
}
Reply
#2

Because loop code inside "false" statement, so it won't be called.

"amount" always 30
Код:
static amount = 30;
It'll return "false", so the code inside this statement wont be called.
Код:
	if(amount <= 0)
Reply
#3

just look what is in bottom of timer:
Код:
	amount = amount-1;
	format(str, sizeof(str), "Start ~y~%i", amount);
	TextDrawSetString(GrottiT[10], str);
	if(amount >= 1)
		TextDrawShowForPlayer(playerid, GrottiT[10]);
it is countin fine

all worked fine to some moment that everything has fucked up, many rep for any help
Reply
#4

anyone please?
Reply
#5

still needed help
Reply
#6

I just optimized it a bit and added a debug, check what does it print and make sure the value meets the conditions.

pawn Код:
forward starttime(playerid, vehicleid);
public starttime(playerid, vehicleid)
{
    static str[16];
    static amount = 30;
    static amount2 = 4;
   
    format(str, 16, "1:%d, 2:%d", amount, amout2), SendClientMessage(playerid, -1, str);
    if(amount <= 0)
    {
        amount2 = --;
       
        IsStarted[0] = true;
       
        format(str, sizeof(str), "%i", amount2);

        for(new i;i<8;i++)
        {
            if(GrottiTPlayer[i] == -1)
            {
                GameTextForPlayer(i, str, 1200, 3);
                PlayerPlaySound(i, 1056, 0, 0, 0);
                SetCameraBehindPlayer(i);
               
                for(new j; j<sizeof(GrottiT); j++) TextDrawHideForPlayer(i, GrottiT[j]);//This hides all the GrottiT textdraws
            }
        }

        if(amount2 <= 0)
        {
            KillTimer(tstarttime);
            for(new i; i < 8; i++)
            {
                if(GrottiTPlayer[i] == -1)
                {
                    TogglePlayerControllable(i, 1);
                    GameTextForPlayer(i, "GO!", 1000, 3);
                    PlayerPlaySound(i, 1057, 0, 0, 0);
                    SetPlayerRaceCheckpoint(i,0,617.816467,-1214.835815,17.872802,632.711059,-1399.011596,13.103024,6); /* Rodeo */
                    GrottiTCP[i] = 1;
                }
            }
        }
    }
    else TextDrawShowForPlayer(playerid, GrottiT[10]);
   
    amount = --;
    format(str, sizeof(str), "Start ~y~%i", amount);
    TextDrawSetString(GrottiT[10], str);
    return 1;
}
Reply
#7

this what i got:
Код:
[03:28:28] 1:30, 2:4

[03:28:29] 1:30, 2:3

[03:28:30] 1:30, 2:2

[03:28:32] 1:30, 2:1

[03:28:33] 1:30, 2:0

[03:28:34] 1:30, 2:-1

[03:28:36] 1:30, 2:-2

[03:28:37] 1:30, 2:-3

[03:28:38] 1:30, 2:-4

[03:28:40] 1:30, 2:-5

[03:28:41] 1:30, 2:-6

[03:28:42] 1:30, 2:-7

[03:28:44] 1:30, 2:-8

[03:28:45] 1:30, 2:-9

[03:28:46] 1:30, 2:-10

[03:28:48] 1:30, 2:-11

[03:28:49] 1:30, 2:-12

[03:28:50] 1:30, 2:-13

[03:28:52] 1:30, 2:-14

[03:28:53] 1:30, 2:-15

[03:28:54] 1:30, 2:-16

[03:28:56] 1:30, 2:-17

[03:28:57] 1:30, 2:-18

[03:28:59] 1:30, 2:-19

[03:29:00] 1:30, 2:-20

[03:29:01] 1:30, 2:-21

[03:29:03] 1:30, 2:-22

[03:29:04] 1:30, 2:-23

[03:29:05] 1:30, 2:-24

[03:29:07] 1:30, 2:-25

[03:29:08] 1:30, 2:-26

[03:29:09] 1:30, 2:-27

[03:29:11] 1:30, 2:-28

[03:29:12] 1:30, 2:-29

[03:29:13] 1:30, 2:-30

[03:29:15] 1:30, 2:-31

[03:29:16] 1:30, 2:-32

[03:29:17] 1:30, 2:-33

[03:29:19] 1:30, 2:-34

[03:29:20] 1:30, 2:-35

[03:29:21] 1:30, 2:-36

[03:29:23] 1:30, 2:-37

[03:29:24] 1:30, 2:-38
textdraw is not even changin.
Reply
#8

pawn Код:
forward starttime(playerid, vehicleid);
public starttime(playerid, vehicleid)
{
    static str[16];
    static amount = 30;
    static amount2 = 4;
   
    format(str, 16, "1:%d, 2:%d", amount, amout2), SendClientMessage(playerid, -1, str);
    if(amount <= 0)
    {
        amount2 = --;
       
        IsStarted[0] = true;
       
        format(str, sizeof(str), "%i", amount2);

        for(new i;i<8;i++)
        {
            if(GrottiTPlayer[i] == -1)
            {
                GameTextForPlayer(i, str, 1200, 3);
                PlayerPlaySound(i, 1056, 0, 0, 0);
                SetCameraBehindPlayer(i);
               
                for(new j; j<sizeof(GrottiT); j++) TextDrawHideForPlayer(i, GrottiT[j]);//This hides all the GrottiT textdraws
            }
        }

        if(amount2 <= 0)
        {
            KillTimer(tstarttime);
            for(new i; i < 8; i++)
            {
                if(GrottiTPlayer[i] == -1)
                {
                    TogglePlayerControllable(i, 1);
                    GameTextForPlayer(i, "GO!", 1000, 3);
                    PlayerPlaySound(i, 1057, 0, 0, 0);
                    SetPlayerRaceCheckpoint(i,0,617.816467,-1214.835815,17.872802,632.711059,-1399.011596,13.103024,6); /* Rodeo */
                    GrottiTCP[i] = 1;
                }
            }
        }
    }
    else TextDrawShowForPlayer(playerid, GrottiT[10]);
   
    amount --;
    format(str, sizeof(str), "Start ~y~%i", amount);
    TextDrawSetString(GrottiT[10], str);
    return 1;
}
I edited a little mistake, if the "1:" doesn't get below 0 then nothing will ever happen

Why are you using static though, just use global ones..
Reply
#9

there is kinda problem:
Код:
error 029: invalid expression, assumed zero
Код:
amount2 = --;
i just changed it to:
Код:
amount = amount-1;
that im not sure it is same, ive never used that what we got error from
anyway, it aint workin
Reply
#10

Quote:
Originally Posted by cnoopers
Посмотреть сообщение
there is kinda problem:
Код:
error 029: invalid expression, assumed zero
Код:
amount2 = --;
i just changed it to:
Код:
amount = amount-1;
that im not sure it is same, ive never used that what we got error from
anyway, it aint workin
"amount = amount-1" is the same as "amount --;", But I believe amount-- looks better and might be a little faster. what does it print though after editing it ?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)