counting admin time -
Luca12 - 06.08.2013
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
Re: counting admin time -
[XST]O_x - 06.08.2013
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.
Re: counting admin time -
Luca12 - 06.08.2013
you give me minutes[playerid] but I have my variable?
Re: counting admin time -
Vince - 06.08.2013
Use gettime() instead of relying on resource intensive timers. I believe there's a tutorial on how to do that.
Re: counting admin time -
Konstantinos - 06.08.2013
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;
}
Re: counting admin time -
Luca12 - 06.08.2013
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
Re: counting admin time -
Konstantinos - 06.08.2013
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.
Re: counting admin time -
Luca12 - 06.08.2013
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
Re: counting admin time -
Tanush123 - 06.08.2013
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
}
Re: counting admin time -
Luca12 - 06.08.2013
Quote:
Originally Posted by Tanush123
pawn Код:
if(IsPlayerAdmin(playerid) || Gamemaster) { //save }
|
can I get 100 % working check if player game admin/ game master? Thanks
Re: counting admin time -
Konstantinos - 06.08.2013
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?
Re: counting admin time -
Luca12 - 06.08.2013
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
Re: counting admin time -
Konstantinos - 07.08.2013
pawn Код:
if(PlayerInfo[playerid][pAdmin] >= level_you_want_here_REPLACE_IT || PlayerInfo[playerid][pGameMaster])
{
// save the time;
}