|
Hey guys, how can i made a script when Admin go "On duty" to display time spended from admin on duty ..
For example : Admin Micho_Mkd is on duty ! [DutyTIME: 21hr:21min] Here is a picture : http://prnt.sc/ezh4vy |
enum aduty
{
bool:isinduty,
dutysec,
dutymin
}
new admintime[MAX_PLAYERS][aduty];
//Global timer >>
settimer("duty",1000,true);
forward duty();
public duty()
{
for(new i;i<MAX_PLAYERS;i++)
{
if(IsAnAdmin(i))
{
if(admintime[i][isinduty])
{
if(dutysec < 60)
{
admintime[i][dutysec]++;
}
if(dutysec == 60)
{
admintime[i][dutysec] = 0;
admintime[i][dutymin]++;
}
}
}
}
return 1;
}
|
Use gettime(). You don't even need any extra variables or timers. You probably already set a variable to 1 once a player goes on duty so just replace that 1 with gettime() without parameters. When player goes off duty (or when the duty time is requested) you do gettime() - yourDutyVariable[playerid] and that will give you the time in seconds for the current session which can then be added to the total. That can then be converted into minutes and hours as desired.
|
if(PlayerInfo[playerid][pGameMaster] >= 1)
{
new sg1[128];
new hour,minuite,second;
gettime(hour,minuite,second);
GameMasterDuty[playerid] = 1;
GetPlayerName(playerid,sg1,MAX_PLAYER_NAME);
SetPlayerColor(playerid,COLOR_DBLUE);
SetPlayerHealth(playerid,999);
SetPlayerArmour(playerid,999);
SetPlayerSkin(playerid, 217);
format(sg1,sizeof(sg1),"{f79d27}ScorpionWorld RolePlay | {FFFFFF}GameMaster %s e na dolznost.",sg1);
SendClientMessageToAll(COLOR_WHITE,sg1);
}