Time stamp
#1

i don't understand tutorial for time stamp.
How to make if player not typed /rudnik command 2hours server give him quitjob ??

Here is the command

Код:
YCMD:rudnik(playerid, params[], help)
{
    #pragma unused params
	if(help) return SCM(playerid, COLOR_GREY, "Not supported");
	
    if(PlayerInfo[playerid][pJob] == 25)
	{
		if(UzeoOpremu[playerid] == 0) return SCM(playerid, COLOR_GREY, "Morate prvo uzeti opremu u kucici na vrhu rudnika!");
		if(IsPlayerInRangeOfPoint(playerid, 350, 604.7141,867.4781,-40.2878))
		{
			if(NaPoslu[playerid] == 1) return SCM(playerid, COLOR_WHITE, "** Vec ste na poslu.");
			SetPlayerCheckpoint(playerid, 551.3589,852.8019,-42.5268, 5.0);
			CP[playerid] = 2;
			NaPoslu[playerid] = 1;
			SCM(playerid, COLOR_WHITE, "Idi do CheckPoint-a i pocni da kopas");
		}
	}
	else SCM(playerid, COLOR_GRAD1, "{EA0C0C}[ERROR]{FFFFFF}Moras biti rudar da bi mogao raditi u rudniku!");
	return 1;
}
Tutorial from there:https://sampforum.blast.hk/showthread.php?tid=254915
I don't understand that tutorial clearly,because english is not my mother language.
Reply
#2

Basically when you type the function gettime(); without callbacks you will get the current unix timestamp you add 2 hours to the current time then if the player types this command again you'll have to see if it has passed 7200 MS (2 hours) yet or not.
pawn Код:
new jTime[MAX_PLAYERS]; //
CMD:examplecmd(playerid,params[])
{
new timestamp = gettime();
if(timestamp > jTime[playerid])
{
jTime[playerid] = gettime()+3600*2; // 1hour: 3600 ms
printf(" Typed /examplecmd. gettime stored in jTime ");
}
else
{
new hoursleft = (jTime[playerid]-timestamp)/3600; // 1 hour is 3600 MS as I've stated above, therefore dividing jTime[playerid]-timestamp will result into the hours left.
printf("Current time: %i | 2 Hours Added: %i | Hours left for you to type this command again %i.",timestamp,jTime[playerid],hoursleft);
}
}
Reply
#3

Quote:
Originally Posted by DaniceMcHarley
Посмотреть сообщение
Basically when you type the function gettime(); without callbacks you will get the current unix timestamp you add 2 hours to the current time then if the player types this command again you'll have to see if it has passed 7200 MS (2 hours) yet or not.
pawn Код:
new jTime[MAX_PLAYERS]; //
CMD:examplecmd(playerid,params[])
{
new timestamp = gettime();
if(timestamp > jTime[playerid])
{
jTime[playerid] = gettime()+3600*2; // 1hour: 3600 ms
printf(" Typed /examplecmd. gettime stored in jTime ");
}
else
{
new hoursleft = (jTime[playerid]-timestamp)/3600; // 1 hour is 3600 MS as I've stated above, therefore dividing jTime[playerid]-timestamp will result into the hours left.
printf("Current time: %i | 2 Hours Added: %i | Hours left for you to type this command again %i.",timestamp,jTime[playerid],hoursleft);
}
}
From this i can make if player not 2 Months on the server script delete him account ?
Reply
#4

You can, just save his last login as Timestamp and make some kind of timer to check all the accounts, including offline, and delete the account if last login is older than 2 months.
Reply
#5

Quote:
Originally Posted by DaniceMcHarley
Посмотреть сообщение
Basically when you type the function gettime(); without callbacks you will get the current unix timestamp you add 2 hours to the current time then if the player types this command again you'll have to see if it has passed 7200 MS (2 hours) yet or not.
pawn Код:
new jTime[MAX_PLAYERS]; //
CMD:examplecmd(playerid,params[])
{
new timestamp = gettime();
if(timestamp > jTime[playerid])
{
jTime[playerid] = gettime()+3600*2; // 1hour: 3600 ms
printf(" Typed /examplecmd. gettime stored in jTime ");
}
else
{
new hoursleft = (jTime[playerid]-timestamp)/3600; // 1 hour is 3600 MS as I've stated above, therefore dividing jTime[playerid]-timestamp will result into the hours left.
printf("Current time: %i | 2 Hours Added: %i | Hours left for you to type this command again %i.",timestamp,jTime[playerid],hoursleft);
}
}
This not work good.
Reply
#6

FIRST BUMP !
Reply
#7

My gettime is stored in jTime and now i can't login to the server -.-
What to do...
Reply
#8

BUMP TWO !
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)