Need help
#1

Guys, can someone show me how can i do this ... i want to count admin duty time for example when he goes /onduty it should start counting time and when he go /offduty the counting should stop and store it in Total Duty Time ..
when admin go /onduty it should say "Admin % is on duty! | DutyTime: h/m/s(displays total time)" and same in /offduty ..
Reply
#2

In the command /onduty put this admTimer[playerid] = SetTimerEx("AdmDuty", 1000, 1, "i", playerid);
Create a func AdmDuty(playerid) in it it should count every sec, like this
PHP код:
{
sec[playerid]++;
if(
sec[playerid] == 60)
{
 
sec[playerid] = 0;
 
min[playerid]++;
}
if(
min[playerid] == 60)
{
 
min[playerid] = 0;
 
hours[playerid]++;
}

And at /offduty add KillTimer(admTimer[playerid]);
Reply
#3

Okey, but now how can i store time in total time, and show total time when admin is going /onduty ?
Reply
#4

Save the timestamp at which player goes on duty using https://sampwiki.blast.hk/wiki/Gettime and later when the player goes off duty subtract the saved timestamp from the current timestamp and the result is the amount of seconds player was on duty.
Reply
#5

i tried with gettime, but doesnt work as it should work ..
Reply
#6

Quote:
Originally Posted by michomkd
Посмотреть сообщение
i tried with gettime, but doesnt work as it should work ..
You could post the code.
Reply
#7

@GoldenLion

onduty

Quote:

if(PlayerInfo[playerid][pGameMaster] >= 1)
{
new sg1[128];
new hour,minuite,second,AdminDolznost;
AdminDolznost = gettime(hour,minuite,second);
printf("%02d:%02d:%02d", hour, minuite, second);
printf("Bevte na dolznost %d", AdminDolznost);
GameMasterDuty[playerid] = gettime();
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. | %02d:%02d:%02d ",sg1,(AdminDolznost / 60));
SendClientMessageToAll(COLOR_WHITE,sg1);
}

offduty
Quote:

if(PlayerInfo[playerid][pGameMaster] >= 1)
{
new sg1[128];
new hour,minuite,second,AdminDolznost;
AdminDolznost = gettime(hour,minuite,second);
printf("%02d:%02d:%02d", hour, minuite, second);
printf("Bevte na dolznost %d", AdminDolznost);
GameMasterDuty[playerid] = 0;
gettime() - GameMasterDuty[playerid];
GetPlayerName(playerid,sg1,MAX_PLAYER_NAME);
SetPlayerHealth(playerid,100);
SetPlayerArmour(playerid,0);
SetPlayerColor(playerid,COLOR_WHITE);
new originalskin = PlayerInfo[playerid][pChar];
SetPlayerSkin(playerid, originalskin);
format(sg1,sizeof(sg1),"{f79d27}ScorpionWorld RolePlay | {FFFFFF}GameMaster %s vekje ne e na dolznost. | %02d:%02d:%02d ",sg1,AdminDolznost);
SendClientMessageToAll(COLOR_WHITE,sg1);
}

Reply
#8

Код:
gettime() - GameMasterDuty[playerid];
You are subtracting here, but not storing the result anywhere.
Reply
#9

Can you give me any contact, so i can contact you ?
Reply
#10

Quote:
Код:
gettime() - GameMasterDuty[playerid];
Does this not give a warning about "expression has no effect"? Because this literally does nothing. The result never gets saved anywhere. Don't ignore warnings. They're there to tell you that you've written code that will compile but that is most likely still wrong in the logical sense.
Reply


Forum Jump:


Users browsing this thread: 4 Guest(s)