Minutes and Hours played
#1

How to add something like online time
I have mysql system, and in database, fields are named as 'minutes' 'hours

Please help .!
Reply
#2

pawn Код:
//at top of script
new minuteTimer;


//OnGameModeInit
minuteTimer = SetTimer("minute", 60000, true);

//OnGameModeExit
KillTimer(minuteTimer);

//Anywhere (near the other publics) - Use foreach if you know it..
forward minute();
public minute(){
    for(new i = 0; i<MAX_PLAYERS; i++){
    if(minute[i] => 59){
        minte[i] = 0;
        hour[i]++;
    }else{
    minute[i]++;
    }
    }
    return 1;
}
where i use minute[i] and hour[i] you will change to whatever the minutes and hours in your enum,.. like "PlayerInfo[i][pMinutes]" for example...

EDIT:
sorry for messy code, im at college so i can set it up correctly.. although break it all down and it should work..
Reply
#3

Quote:
Originally Posted by DarrenReeder
Посмотреть сообщение
pawn Код:
//at top of script
new minuteTimer;


//OnGameModeInit
minuteTimer = SetTimer("minute", 60000, true);

//OnGameModeExit
KillTimer(minuteTimer);

//Anywhere (near the other publics) - Use foreach if you know it..
forward minute();
public minute(){
    for(new i = 0; i<MAX_PLAYERS; i++){
    if(minute[i] => 59){
        minte[i] = 0;
        hour[i]++;
    }else{
    minute[i]++;
    }
    }
    return 1;
}
where i use minute[i] and hour[i] you will change to whatever the minutes and hours in your enum,.. like "PlayerInfo[i][pMinutes]" for example...

EDIT:
sorry for messy code, im at college so i can set it up correctly.. although break it all down and it should work..
yeh then if you want it to show
sendclientmessage or if you want to make it save to a file
use dini or y_ini
Reply
#4

you could also simply use the return value of gettime, like:

pawn Код:
//OnPlayerConnect
p_connecttime[playerid]=gettime();
//OnPlayerDisconnect
p_seconds[playerid]=gettime()-pconnecttime[playerid];
Reply
#5

Quote:
Originally Posted by Cank
Посмотреть сообщение
you could also simply use the return value of gettime, like:

pawn Код:
//OnPlayerConnect
p_connecttime[playerid]=gettime();
//OnPlayerDisconnect
p_seconds[playerid]=gettime()-pconnecttime[playerid];
And how can I display it ? I mean SendClientMessage(..
Reply
#6

pawn Код:
new str[30];
format(str, 30, "Value: %d.", p_seconds[playerid]);
SendClientMessage(playerid, 0xFF0000FF, str);
Reply
#7

And then how to / these seconds to minutes ?
Reply
#8

Something like

pawn Код:
if ( SecondsVar[ playerid ] == 60 )
{
    MinutesVar[ playerid ] += 1;
}
Easy, not?
Reply
#9

pawn Код:
#define SecToMin(%0) (%0/60)
Reply
#10

Waitwait. Gimme the full code I should add and where and how.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)