Problem - Days System
#1

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?
Reply
#2

gettime and getday function.
Reply
#3

By seconds
Код:
30 * 24 * 60 + gettime()
By milisseconds
Код:
30 * 24 * 60 * 1000 + GetTickCount()
Reply
#4

U want it to last 30days in real life and after 30days ( Month ) Delete the ownership from the house?
Reply
#5

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...
Reply
#6

Код:
House[houseid][Update] = (gettime() + (30*86400));
Reply
#7

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.
Reply
#8

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 !
Reply
#9

Timers can cause lag if you use a lot of timers with a lot of shit in each of them.
Reply
#10

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.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)