SA-MP Forums Archive
Score Timer - 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: Score Timer (/showthread.php?tid=363357)



Score Timer - kbalor - 27.07.2012

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;
}



Re: Score Timer - Cjgogo - 27.07.2012

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


Re: Score Timer - TheDeath - 27.07.2012

Do you have
Код:
new secounds;



Re: Score Timer - kbalor - 27.07.2012

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!


Re: Score Timer - Cjgogo - 27.07.2012

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.


Re: Score Timer - kbalor - 27.07.2012

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