ScoreTimer
#1

Anyone know how to set this to 1 hour = 1 score?

Код:
#define SCORE_TIME          60 * 3
pawn Код:
forward ScoreTimer();
public ScoreTimer()
{
    new pTime[4];
    for(new i; i < MAX_PLAYERS; i++)
    {
        TotalGameTime(i, pTime[0], pTime[1], pTime[2]);
        pTime[3] = (pTime[0] * 3600) + (pTime[1] * 60) + pTime[2];
        if((pTime[3] - LastConnected[i]) == SCORE_TIME)
        {
            SetPlayerScore(i, GetPlayerScore(i) + 1);
            LastConnected[i] = pTime[3];
        }
    }
    return 1;
}
Reply
#2

Do you want something like:

pawn Код:
new szTimeTicks = 0,
    n_bTimerID; // at top
   
n_bTimerID = SetTimer( "ScoreTimer", 1000, true ); // in gamemode init

forward ScoreTimer( ); // at top

public ScoreTimer( ) // anywhere you want
{
    szTimeTicks++; // counting ticks every second
   
    switch( szTimeTicks ) // switching it
    {
        case 3600: // checking if the time ticks are 1 hour
        {
            szTimeTicks = 0; // resetting the time ticks to 0
            for( new f = 0; f < MAX_PLAYERS; f++ ) // looping the players
            {
                if( IsPlayerConnected( f ) )
                {
                    SetPlayerScore( f, GetPlayerScore( f ) + 1 ); // give the score!
                }
            }
        }
    }
}
Reply
#3

Quote:
Originally Posted by FalconX
Посмотреть сообщение
Do you want something like:

pawn Код:
new szTimeTicks = 0,
    n_bTimerID; // at top
   
n_bTimerID = SetTimer( "ScoreTimer", 1000, true ); // in gamemode init

forward ScoreTimer( ); // at top

public ScoreTimer( ) // anywhere you want
{
    szTimeTicks++; // counting ticks every second
   
    switch( szTimeTicks ) // switching it
    {
        case 3600: // checking if the time ticks are 1 hour
        {
            szTimeTicks = 0; // resetting the time ticks to 0
            for( new f = 0; f < MAX_PLAYERS; f++ ) // looping the players
            {
                if( IsPlayerConnected( f ) )
                {
                    SetPlayerScore( f, GetPlayerScore( f ) + 1 ); // give the score!
                }
            }
        }
    }
}
Thanks for the reply falcon!

I'am using Luxadmin and it has Time Login: Do you think it will have a conflict with the filstriptscript?

Also, if player leave, and he/she connects again does the timer will continue?

And last Do you think it is better than one that i post?

Sorry for the qesutions, Just want to know and to prevent lag in the server
Reply
#4

Quote:
Originally Posted by kbalor
Посмотреть сообщение
Thanks for the reply falcon!

I'am using Luxadmin and it has Time Login: Do you think it will have a conflict with the filstriptscript?

Also, if player leave, and he/she connects again does the timer will continue?

And last Do you think it is better than one that i post?

Sorry for the qesutions, Just want to know and to prevent lag in the server
I don't think it will conflict because we are using different callback name and the variables; The timer will keep running until the server is online so when the player leaves and comes back in the server the timer will not get any effect, but as soon as 1 hour of the time ticks has been completed it will give the score to the players who are currently online, no matter if they come in the server before a second.

I haven't checked how LuxAdmin is scripted (being honest) and I don't know what kind of timers and functions in that filter-script is made.

Regards,
FalconX
Reply
#5

Quote:
Originally Posted by FalconX
Посмотреть сообщение
I don't think it will conflict because we are using different callback name and the variables; The timer will keep running until the server is online so when the player leaves and comes back in the server the timer will not get any effect, but as soon as 1 hour of the time ticks has been completed it will give the score to the players who are currently online, no matter if they come in the server before a second.

I haven't checked how LuxAdmin is scripted (being honest) and I don't know what kind of timers and functions in that filter-script is made.

Regards,
FalconX
Okay I understand, gonna try it now. I have already given you a rep. Thanks for always helping me!
Reply
#6

Quote:
Originally Posted by kbalor
Посмотреть сообщение
Okay I understand, gonna try it now. I have already given you a rep. Thanks for always helping me!
No problem mate
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)