Problem - Days System -
TheHonnor - 28.07.2016
Hi yall. I've begun a House & Property System and i want to make it temporary.
A house or a property will be available 30 days. And in database i want to save this time/day.
How can I do?
Re: Problem - Days System -
Logic_ - 28.07.2016
gettime and getday function.
Re: Problem - Days System -
F1N4L - 28.07.2016
By seconds
Код:
30 * 24 * 60 + gettime()
By milisseconds
Код:
30 * 24 * 60 * 1000 + GetTickCount()
Re: Problem - Days System - WhiteGhost - 28.07.2016
U want it to last 30days in real life and after 30days ( Month ) Delete the ownership from the house?
Re: Problem - Days System -
TheHonnor - 28.07.2016
Yes, after 30 days valability, the house must be automatically sold by the server.
I have already tried something such as: "House[houseid][Update] = gettime() + 60*60*24", but. It didn't work...
Re: Problem - Days System -
Stuntff - 28.07.2016
Код:
House[houseid][Update] = (gettime() + (30*86400));
Re: Problem - Days System -
[XST]O_x - 28.07.2016
Have a variable to store the time in which the lease will expire
Код:
House[houseid][ExpirationDate] = gettime() + 60 * 60 * 24 * 30 //The current timestamp with addition of 30 days, converted to seconds
And set a timer that will check every minute or every hour if the timestamp has been reached or exceeded
Код:
House[houseid][ExpirationTimer] = SetTimerEx("CheckTimestamp", 60 * 1000 * 60, true, "i", houseid);
forward CheckTimestamp(houseid);
public CheckTimestamp(houseid)
{
if(gettime() >= House[houseid][ExpirationDate]) {
//Date reached
KillTimer(House[houseid][ExpirationTimer]);
//Do whatever you want here
}
return 1;
}
That code would check every hour(to prevent spamming the server with checks) if the 30 days has passed.
Re: Problem - Days System -
TheHonnor - 29.07.2016
I was thinking to place that check when the house valability has been reached / exceeded when the player disconnects. 'Cuz some friends of mine told me that the timers can make lag...
But thanks for your help, I'm gonna try right now !
Re: Problem - Days System -
Logic_ - 29.07.2016
Timers can cause lag if you use a lot of timers with a lot of shit in each of them.
Re: Problem - Days System -
[XST]O_x - 29.07.2016
Quote:
Originally Posted by TheHonnor
I was thinking to place that check when the house valability has been reached / exceeded when the player disconnects. 'Cuz some friends of mine told me that the timers can make lag...
But thanks for your help, I'm gonna try right now !
|
A timer with 1 hour interval shouldn't cause any lag.