Minutes and Hours played - 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: Minutes and Hours played (
/showthread.php?tid=190947)
Minutes and Hours played -
NewbBeginner - 17.11.2010
How to add something like online time
I have mysql system, and in database, fields are named as 'minutes' 'hours
Please help .!
Re: Minutes and Hours played -
DarrenReeder - 17.11.2010
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..
Re: Minutes and Hours played -
dark_clown - 17.11.2010
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
AW: Minutes and Hours played -
Cank - 17.11.2010
you could also simply use the return value of gettime, like:
pawn Код:
//OnPlayerConnect
p_connecttime[playerid]=gettime();
//OnPlayerDisconnect
p_seconds[playerid]=gettime()-pconnecttime[playerid];
Re: AW: Minutes and Hours played -
NewbBeginner - 17.11.2010
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(..
Re: Minutes and Hours played -
rs.pect - 17.11.2010
pawn Код:
new str[30];
format(str, 30, "Value: %d.", p_seconds[playerid]);
SendClientMessage(playerid, 0xFF0000FF, str);
Re: Minutes and Hours played -
NewbBeginner - 17.11.2010
And then how to / these seconds to minutes ?
Re: Minutes and Hours played -
Zh3r0 - 17.11.2010
Something like
pawn Код:
if ( SecondsVar[ playerid ] == 60 )
{
MinutesVar[ playerid ] += 1;
}
Easy, not?
AW: Minutes and Hours played -
Cank - 17.11.2010
pawn Код:
#define SecToMin(%0) (%0/60)
Re: Minutes and Hours played -
NewbBeginner - 17.11.2010
Waitwait. Gimme the full code I should add and where and how.