Score Timer
#1

I already have passed 30 minutes time ingame, and it's about 48 minutes but still the Score doesn't change at all. This is the ScoreTimer I'am using. Is there something wrong with script??
1800 seconds = 30 minutes


OnGameModeInit
Код:
 SetTimer("scoretimer", 1000, true);
pawn Код:
forward scoretimer();
public scoretimer()
{
    for(new i; i<MAX_PLAYERS; i++)
    {
        if(!IsPlayerConnected(i)) continue;
        seconds[i] ++;
        if(seconds[i] >= 1800)
        {
            SetPlayerScore(i, GetPlayerScore(i) + 1);
            seconds[i] = 0;
        }
    }
    return 1;
}
Reply
#2

pawn Код:
forward scoretimer();
public scoretimer()
{
    for(new i; i<MAX_PLAYERS; i++)
    {
        if(!IsPlayerConnected(i)) break;
        else
        {
         seconds[i] ++;
         if(seconds[i] >= 1800)
         {
            SetPlayerScore(i, GetPlayerScore(i) + 1);
            seconds[i] = 0;
        }
       }
    }
    return 1;
}
Try it now,not sure if it'll work tough
Reply
#3

Do you have
Код:
new secounds;
Reply
#4

Quote:
Originally Posted by Cjgogo
Посмотреть сообщение
pawn Код:
forward scoretimer();
public scoretimer()
{
    for(new i; i<MAX_PLAYERS; i++)
    {
        if(!IsPlayerConnected(i)) break;
        else
        {
         seconds[i] ++;
         if(seconds[i] >= 1800)
         {
            SetPlayerScore(i, GetPlayerScore(i) + 1);
            seconds[i] = 0;
        }
       }
    }
    return 1;
}
Try it now,not sure if it'll work tough
Sorry it's not. i have tried to changed the 1800 to 500 so i don't need to wait 30 minutes. And still no luck. Hope to fix this soon!
Reply
#5

Well,as TheDeath specified,I do rely on the fact that at the top of your gamemode you have:
pawn Код:
new seconds[MAX_PLAYERS];
YOU might have forget something very,VERY IMPORTANT,I hope you did not,and that important thing being this:
pawn Код:
public OnPlayerConnect(playerid)
{
   seconds[playerid]=0;
   return 1;
}
I hope you initialized seconds as 0,when player connects,otherwise,that's definetely the problem what's causing the bug.
And in the end,here's a better layout for your timer:
pawn Код:
forward scoretimer();
public scoretimer()
{
    for(new i=0; i<MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i))
        {
         seconds[i] ++;
         if(seconds[i] >= 1800)
         {
            SetPlayerScore(i, GetPlayerScore(i) + 1);
            seconds[i] = 0;
         }
       }
    }
    return 1;
}
Hopefully,that works.
Reply
#6

Quote:
Originally Posted by Cjgogo
Посмотреть сообщение
Well,as TheDeath specified,I do rely on the fact that at the top of your gamemode you have:
pawn Код:
new seconds[MAX_PLAYERS];
YOU might have forget something very,VERY IMPORTANT,I hope you did not,and that important thing being this:
pawn Код:
public OnPlayerConnect(playerid)
{
   seconds[playerid]=0;
   return 1;
}
I hope you initialized seconds as 0,when player connects,otherwise,that's definetely the problem what's causing the bug.
And in the end,here's a better layout for your timer:
pawn Код:
forward scoretimer();
public scoretimer()
{
    for(new i=0; i<MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i))
        {
         seconds[i] ++;
         if(seconds[i] >= 1800)
         {
            SetPlayerScore(i, GetPlayerScore(i) + 1);
            seconds[i] = 0;
         }
       }
    }
    return 1;
}
Hopefully,that works.
EDIT: Working fine! Just a mistake i though 500 is 5 seconds. LOLOL My bad. +rep
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)