score help for server
#1

could someone help me make a timer/code that makes all the players score go up every second or every minute go up 1 piont


TY
Nathanael_Tavares
Reply
#2

Easy
do it like this:
On the top of your script,after the includes put:
pawn Код:
forward ScoreTimer(playerid);
Under OnPlayerConnect:
pawn Код:
SetTimerEx("ScoreTimer",60000,0,"d",playerid);
And in the end of the script,make a callback,here:
pawn Код:
public ScoreTimer(playerid)
{
    SetPlayerScore(playerid,(playerid)+1);
    return 1;
}
Hope i helped.
PS:now after every 60 seconds everyone will get +1 point
I've tested it,its working

Oh and,you see the "60000",it means every 60 seconds,its in ms,it means,miliseconds,1000=1 second,so if you want any player to get
1 point after every second,change the 60000 to 1000.
Reply
#3

Quote:
Originally Posted by 3xPloSioNxXx
Easy
do it like this:
On the top of your script,after the includes put:
pawn Код:
forward ScoreTimer(playerid);
Under OnPlayerConnect:
pawn Код:
SetTimerEx("ScoreTimer",60000,0,"d",playerid);
And in the end of the script,make a callback,here:
pawn Код:
public ScoreTimer(playerid)
{
    SetPlayerScore(playerid,(playerid)+1);
    return 1;
}
Hope i helped.
PS:now after every 60 seconds everyone will get +1 point
I've tested it,its working
TY very much
Reply
#4

Whoa Whoa Whoa.... dude, instead of making that, which creates many timers for every player.

Use a loop:

pawn Код:
forward Score(playerid);

SetTimer("Score",60000,true);

public Score(playerid)
{
    for(new i=0; i<MAX_PLAYERS; i++)
    {
        if (IsPlayerConnected(i))
        {
        new Current;
        Current = GetPlayerScore(i);
        SetPlayerScore(i,Current + 1);
        }
    }
}
Reply
#5

Quote:
Originally Posted by Enemy_Plus[SA:MP
]
Whoa Whoa Whoa.... dude, instead of making that, which creates many timers for every player.

Use a loop:

pawn Код:
forward Score(playerid);

SetTimer("Score",60000,true);

public Score(playerid)
{
    for(new i=0; i<MAX_PLAYERS; i++)
    {
        if (IsPlayerConnected(i))
        {
        new Current;
        Current = GetPlayerScore(i);
        SetPlayerScore(i,Current + 1);
        }
    }
}
Yeah after i tested my timer after two minutes the score still stays 1
so its working only for one minute,listen to Enemy_Plus he know better than me about scripting :P
i can say i've tried my luck.
Reply
#6

Hahahaha I find this funny lol.... well you did try :P
Reply
#7

Mozilla Firefox, that's because you put
pawn Код:
SetTimerEx("ScoreTimer",60000,0,"d",playerid);
instead of
pawn Код:
SetTimerEx("ScoreTimer",60000,1,"d",playerid);
The third parameter means if the timer should repeat or not
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)