payday didn't work ...
#1

Hi.I have a problem with payday code now...I think i didn't have mistakes on the code but it doesn't work...Let's explain what code need to do:When the time is xx:00 who player is online to get +3 Exp.This is code:

pawn Код:
forward PayDay();
public PayDay()
{
    new hh, mm, ss;
    gettime( hh, mm, ss );
    if(mm == 00)
    {
        for(new i = 0; i < MAX_PLAYERS; i++)
        {
            PlayerInfo[i][Exp] += 3;
        }
    }
    return 1;
}
Reply
#2

Did you add a
pawn Код:
SetTimer("PayDay", 60000, false);
in GameModeInit?
Reply
#3

Quote:
Originally Posted by L.Hudson
Посмотреть сообщение
Did you add a
pawn Код:
SetTimer("PayDay", 60000, false);
in GameModeInit?
yes ...
Reply
#4

pawn Код:
forward PayDay();
public PayDay()
{
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        PlayerInfo[i][Exp] += 3;
    }
    return 1;
}
Try this since it will do it every 60 minutes of the player logged in time

The way you did it, you did add the timer, ok, but if the timer ends when the time isnt xx:00 it will not give a payday
Reply
#5

I wanna when it's xx:00 all players to get 3 Exp...

Edit:I fixed it
Reply
#6

Well I tried telling a way to make it better, anyway now it's quite a proggress to make, firstly you'll have to delete the Timer of PayDay in OnGamemodeInit and create a new one called "PayTime" or whatever which will get the time every 1 second. Example:

pawn Код:
forward PayTime();
public PayTime()
{
    new hh, mm, ss;
    gettime(hh, mm, ss);
    if(mm == 0)
    {
        PayDay();
    }
    return 1;
}

stock PayDay()
{
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        PlayerInfo[i][Exp] += 3;
    }
    return 1;
}
And in OnGamemodeInit put
pawn Код:
SetTimer("PayTime", 1000, true);
Reply
#7

i fixed it thanks for helping and rep+ for you
Reply
#8

You can't expect your timer to be synced with the minutes change! If you want the player to receive his exp every time the server's minutes change this is what you do:
pawn Код:
public OnGameModeInit()
{
    SetTimer("PayDay", 10, true);
}

forward PayDay();

public PayDay()
{
    new hh, mm, ss;
    gettime( hh, mm, ss );
    if(mm == 00)
    {
        for(new i = 0; i < MAX_PLAYERS; i++)
        {
            PlayerInfo[i][Exp] += 3;
        }
    }
    return 1;
}
EDIT: TOO LATE.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)