Need help - 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: Need help (
/showthread.php?tid=633980)
Need help -
michomkd - 11.05.2017
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 ..
Re: Need help -
andreistalker - 11.05.2017
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]);
Re: Need help -
michomkd - 11.05.2017
Okey, but now how can i store time in total time, and show total time when admin is going /onduty ?
Re: Need help -
GoldenLion - 11.05.2017
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.
Re: Need help -
michomkd - 11.05.2017
i tried with gettime, but doesnt work as it should work ..
Re: Need help -
GoldenLion - 11.05.2017
Quote:
Originally Posted by michomkd
i tried with gettime, but doesnt work as it should work ..
|
You could post the code.
Re: Need help -
michomkd - 11.05.2017
@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);
}
|
Re: Need help -
GoldenLion - 11.05.2017
Код:
gettime() - GameMasterDuty[playerid];
You are subtracting here, but not storing the result anywhere.
Re: Need help -
michomkd - 11.05.2017
Can you give me any contact, so i can contact you ?
Re: Need help -
Vince - 11.05.2017
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.