Help me - 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)
+--- Thread: Help me (
/showthread.php?tid=633024)
Help me -
michomkd - 23.04.2017
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
Re: Help me -
khRamin78 - 23.04.2017
Quote:
Originally Posted by michomkd
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
|
PHP Code:
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;
}
Re: Help me -
Vince - 23.04.2017
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.
Re: Help me -
michomkd - 24.04.2017
Quote:
Originally Posted by Vince
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.
|
Can u add me on ********, i didn't get it :/
https://www.********.com/michomkd
Re: Help me -
michomkd - 29.04.2017
BUMP !
Re: Help me -
michomkd - 02.05.2017
BUMPP!
Re: Help me -
Sew_Sumi - 02.05.2017
He's saying instead of using the timer, you could simply use gettime and count how long they were on duty for.
You'd be storing the time the admin went on duty currently as a variable. The time overall that the player has been on duty would be included in the playerinfo enum/account info.
The current gettime would be compared to the onduty "start" of the current session, and added to the overall time.
When the admin goes off duty then that time would be added to the players account info.
Re: Help me -
Loinal - 02.05.2017
Quote:
Originally Posted by michomkd
BUMPP!
|
Hey, u can use gettime()
GetTime()
Re: Help me -
michomkd - 02.05.2017
Code:
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);
}
Is this okey ?
Re: Help me -
Sew_Sumi - 02.05.2017
Those hour minute second variables will only be visible IN that if statement, so close, but you'll need to learn a bit more.