counting admin time
#1

Hello I made player variable PlayerInfo[playerid][AdminMinute]

and know how can I make how many minut was been on the server some admin if you know what I mean
Reply
#2

pawn Код:
new minuteTimer[MAX_PLAYERS];
new minutes[MAX_PLAYERS] = {0, ...};

public OnPlayerConnect(playerid)
{
    minuteTimer[playerid] = SetTimerEx("UpdateMinutes", 60 * 1000, true, "i", playerid);
    return 1;
}

forward UpdateMinutes(playerid);
public UpdateMinutes(playerid)
{
    minutes[playerid]++;
    return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
    KillTimer(minuteTimer[playerid]);
    return 1;
}
Make sure you save the information in a file, so the value doesn't get reset every time.
Reply
#3

you give me minutes[playerid] but I have my variable?
Reply
#4

Use gettime() instead of relying on resource intensive timers. I believe there's a tutorial on how to do that.
Reply
#5

No need timers for that! Use GetTickCount instead.

pawn Код:
new
    CountMilliseconds[ MAX_PLAYERS ]
;

public OnPlayerConnect(playerid)
{
    PlayerInfo[playerid][AdminMinute] = 0;
    CountMilliseconds[ playerid ] = GetTickCount( );
    return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
    PlayerInfo[playerid][AdminMinute] = ((GetTickCount( ) - CountMilliseconds[ playerid ]) % (1000*60*60)) / (1000*60);
    return 1;
}
Reply
#6

Quote:
Originally Posted by Konstantinos
Посмотреть сообщение
No need timers for that! Use GetTickCount instead.

pawn Код:
new
    CountMilliseconds[ MAX_PLAYERS ]
;

public OnPlayerConnect(playerid)
{
    PlayerInfo[playerid][AdminMinute] = 0;
    CountMilliseconds[ playerid ] = GetTickCount( );
    return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
    PlayerInfo[playerid][AdminMinute] = ((GetTickCount( ) - CountMilliseconds[ playerid ]) % (1000*60*60)) / (1000*60);
    return 1;
}
is that counting every minute if a player game admin or gamemaster? example i was on the server 4 minutes and I disconnect and in my file is writen 4
Reply
#7

You need to modify it a bit then, if you want to save it. For example, you load the minutes to PlayerInfo[playerid][AdminMinute], so when they disconnect change to:
pawn Код:
// OnPlayerDisconnect
new
    minutes_ = ((GetTickCount( ) - CountMilliseconds[ playerid ]) % (1000*60*60)) / (1000*60)
;
PlayerInfo[playerid][AdminMinute] += minutes_;
// Save here
And it will add the minutes they had + the minutes before they disconnect.
Reply
#8

Ok just one question how can I make that save only if player admin/gamemaster if you know what I mean or else it's save everyone? Thanks
Reply
#9

Quote:
Originally Posted by Luca12
Посмотреть сообщение
Ok just one question how can I make that save only if player admin/gamemaster if you know what I mean or else it's save everyone? Thanks
pawn Код:
if(IsPlayerAdmin(playerid) || Gamemaster)
{
   //save
}
Reply
#10

Quote:
Originally Posted by Tanush123
Посмотреть сообщение
pawn Код:
if(IsPlayerAdmin(playerid) || Gamemaster)
{
   //save
}
can I get 100 % working check if player game admin/ game master? Thanks
Reply
#11

Quote:
Originally Posted by Luca12
Посмотреть сообщение
can I get 100 % working check if player game admin/ game master? Thanks
What do you mean by that, Luca?
Reply
#12

I mean I want the code that check is player admin or game master example

if(PlayerInfo[playerid][pAdmin] < 0 || PlayerInfo[playerid][pGameMaster]) something like that check if player admin or gamemaster
Reply
#13

pawn Код:
if(PlayerInfo[playerid][pAdmin] >= level_you_want_here_REPLACE_IT || PlayerInfo[playerid][pGameMaster])
{
    // save the time;
}
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)