SA-MP Forums Archive
hours and minutes wont work - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: hours and minutes wont work (/showthread.php?tid=247148)



hours and minutes wont work - tanush - 08.04.2011

On Top
pawn Код:
enum pData
{
    AdminLevel,
    Cash,
    Score,
    vip,
    Hour,
    Minute
};
new PlayerData[MAX_PLAYERS][pData];
when player disconnect
pawn Код:
dini_IntSet(file, "Hour", PlayerData[playerid][Hour]);
        dini_IntSet(file, "Minute", PlayerData[playerid][Minute]);
when the player registers
pawn Код:
PlayerData[playerid][Hour] = dini_Int(file, "Hour");
            PlayerData[playerid][Minute] = dini_Int(file, "Minute");
player log in
pawn Код:
PlayerData[playerid][Hour] = dini_Int(file, "Hour");
            PlayerData[playerid][Minute] = dini_Int(file, "Minute");
forward
pawn Код:
forward OnlineTimeUpdate(playerid);
public OnlineTimeUpdate(playerid)
{
    PlayerData[playerid][Minute] ++;
    if(PlayerData[playerid][Minute] == 60)
    {
        PlayerData[playerid][Hour] ++;
        PlayerData[playerid][Minute] = 0;
    }
}
when i do /stats after 3minute it shows HOURS: 0 MINUTES : 0
pawn Код:
format(string, sizeof(string), " {FFB300}Name: %s \n\n Adminlevel: %d %s\n\n Vip: %d\n\n Cash: %d\n\n Score: %d\n\n Hours: %i\n\n Minutes: %i",Name,PlayerData[playerid][AdminLevel],AdminRank,PlayerData[playerid][vip],GetPlayerMoney(playerid),GetPlayerScore(playerid),PlayerData[playerid][Hour],PlayerData[playerid][Minute]);
    ShowPlayerDialog(playerid,10000,DIALOG_STYLE_MSGBOX, "Stats",string,"Close","");



Re: hours and minutes wont work - sciman001 - 08.04.2011

hmmm... i havent a clue. im just posting because im bored. sorry.


Re: hours and minutes wont work - -Rebel Son- - 08.04.2011

Quote:
Originally Posted by sciman001
Посмотреть сообщение
hmmm... i havent a clue. im just posting because im bored. sorry.
Go post somthing useless somewhere else.

@Tanush, Try the post above with the timer, If you already have/timer doesnt work) then Post back, Illl help ya all i can.


Re: hours and minutes wont work - sciman001 - 08.04.2011

lol. sorry.


Re: hours and minutes wont work - tanush - 08.04.2011

Thanks it work


Re: hours and minutes wont work - -Rebel Son- - 08.04.2011

No problem tanush. Need any help PM me.


Re: hours and minutes wont work - tanush - 08.04.2011

Wait i found something out please help, the minute increases by 1 after 2-5minutes


Re: hours and minutes wont work - tanush - 11.04.2011

*bump*


Re: hours and minutes wont work - Fj0rtizFredde - 11.04.2011

Is your timer started when the player spawns and killed when he disconnects? Also can you post the SetTimer part?


Re: hours and minutes wont work - Joe Staff - 11.04.2011

Why are you using a timer? Just save how many milliseconds that player has been on the server.
pawn Код:
public OnPlayerConnect(playerid)
{
    PlayerData[playerid][Time] = GetTickCount();
}
public OnPlayerDisconnect(playerid,reason)
{
    dini_IntSet(file, "Time", dini_Int(file, "Time")+(GetTickCount()-PlayerData[playerid][Time]));
}
Then dini_Int(file, "Time") will return how many milliseconds the player has been on the server (use a time converter to change it to hours/minutes)