Admin Online Time
#1

Hello guys.
I need help with this .. When Admin go /onduty i want something that can count time spended on duty, and when he goes /offduty to save time spended on duty .. is it possible ?

For Example : When go /onduty : Admin Micho is on duty! | Spendedtime: 21hr:21min
And after 30min when go /offduty : Admin Micho is on duty ! | Spendedtime : 21hr:51min

pawn Код:
CMD:on(playerid,params[])
{
    if(PlayerInfo[playerid][pAdmin] == 1)
    {
        new sg[128];
        AdminDuty[playerid] = 1;
        GetPlayerName(playerid,sg,MAX_PLAYER_NAME);
        SetPlayerColor(playerid,COLOR_YELLOW);
        SetPlayerHealth(playerid,999);
        SetPlayerArmour(playerid,999);
        SetPlayerSkin(playerid, 217);
        format(sg,sizeof(sg),"{f79d27}ScorpionWorld RolePlay | {FFFFFF}Admin %s e na dolznost. [%d:%d:%d] ",sg,PlayerInfo[playerid][pHour], PlayerInfo[playerid][pMinute], PlayerInfo[playerid][pSecond]);
        SendClientMessageToAll(COLOR_WHITE,sg);
    }
pawn Код:
CMD:off(playerid,params[])
{
    if(PlayerInfo[playerid][pAdmin] == 1 )
    {
        new sg[128];
        AdminDuty[playerid] = 0;
        GetPlayerName(playerid,sg,MAX_PLAYER_NAME);
        SetPlayerHealth(playerid,100);
        SetPlayerArmour(playerid,0);
        SetPlayerColor(playerid,COLOR_WHITE);
        new originalskin = PlayerInfo[playerid][pChar];
        SetPlayerSkin(playerid, originalskin);
        format(sg,sizeof(sg),"{f79d27}ScorpionWorld RolePlay | {FFFFFF}Admin %s vekje ne e na dolznost.",sg);
        SendClientMessageToAll(COLOR_WHITE,sg);
    }
Reply
#2

What system are you using to save the player's data? MySQL? Y_INI? dini?

I ask because you'll have to save the amount of time for the admin in order to accomplish this.
Reply
#3

I think its y_ini

pawn Код:
public OnPlayerRegister(playerid, password[])
{
    if(IsPlayerConnected(playerid))
    {
            new string3[32];
            new playername3[MAX_PLAYER_NAME];
            GetPlayerName(playerid, playername3, sizeof(playername3));
            format(string3, sizeof(string3), "Smetke/%s.ini", playername3);
            new File: hFile = fopen(string3, io_write);
            if (hFile)
            {
                strmid(PlayerInfo[playerid][pKey], password, 0, strlen(password), 255);
                new var[64];
                format(var, 64, "Key=%s\n", PlayerInfo[playerid][pKey]);fwrite(hFile, var);
Reply
#4

Why did you post the same thread again? https://sampforum.blast.hk/showthread.php?tid=633024

It doesn't look like it's Y_INI at all...
Reply
#5

Quote:
Originally Posted by Sew_Sumi
Посмотреть сообщение
Why did you post the same thread again? https://sampforum.blast.hk/showthread.php?tid=633024

It doesn't look like it's Y_INI at all...
I explained here better
Reply
#6

Quote:
Originally Posted by michomkd
Посмотреть сообщение
I explained here better
Should've just bumped the other thread. People subbed to that, and now you're in here asking again.


You're going to need to learn to do some scripting, not just hope that someone will provide you code to make what you want.

As was stated in that thread, you need to use gettime, assign a variable to the players enum (Setting this with /on), and count the time for what the person has been onduty for, adding in what they had done prior when /on and /off is used. When /off is used you add the last sessions duty, to the current overall time and it's done.
Reply
#7

http://prntscr.com/f3inkr and yea i got this now ..

Код:
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);
    }
Код:
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

Should put it in the player enum, just so it's tracked better than using a second array to track that data.

Rather than using /on /off, you could do /aduty and check in there if the player is on duty, and use that as a toggle rather than having 2 commands.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)