Cheque - Mysql
#1

- Cheque System

Special thanks:
- Thanks to Kyosaur that helped me solve this puzzle 5 AM!

What it does:
- Checks the given gettime and calculates how many secs/days/weeks/months/years there been since stored gettime.
- This dosn't really have something to do with Cheque's but i needed something like this to make an system.

Sample:
pawn Код:
public OnGameModeInit()
{
    new
        tmp,
        Time = gettime() - (48*60*60);
       
    printf("%s", ConvertTime(gettime() - Time, .cth=tmp));
   
    return 0;
}
ConvertTime:
http://forum.sa-mp.com/showpost.php?...&postcount=980
Reply
#2

Bump. really need help with this one.
Reply
#3

I believe I already helped you over MSN?
Reply
#4

Yeah look at the date

i'll update my post to show the answer i got .
Reply
#5

This method didn't really work as well as i thought.. Someone help?
Reply
#6

Please somone?
Reply
#7

This might be of use to you :P

http://forum.sa-mp.com/showpost.php?...&postcount=980

Basically what you would do is store the time with gettime(); (no paramters) and then you could use this to convert it. I would've built an example but im to tired at the moment, besides, i think me post explains its use pretty well :P.

if you want to JUST get the days use it like this:

ConvertTime(SECONDS_HERE, .ctd=VARIABLE_TO_STORE_DAYS_HERE);


If you find any bugs, feel free to post them and i'll fix them as soon as possible.
Reply
#8

Did like you said:

pawn Код:
times[playerid][cTime] = strval(field[3]); // Time from mysql "1282217431" stored with gettime();
new DAY;
printf("%s",ConvertTime(times[playerid][cTime], .ctd=DAY));
This prints 14840 days, 11 hours, 30 minutes, 31 seconds.

Do you see where i did go wrong?
Reply
#9

Quote:
Originally Posted by Cameltoe
Посмотреть сообщение
Did like you said:

times[playerid][cTime] = strval(field[3]); // Time from mysql "1282217431" stored with gettime();
new DAY;
printf("%s",ConvertTime(times[playerid][cTime], .ctd=DAY));

This prints 14840 days, 11 hours, 30 minutes, 31 seconds.

Do you see where i did go wrong?
Yes, its because i was short with you lol.

The gettime() function returns the number of days since january 1st 1997, this means nothing to us lol. So what you would have to do is subtract the time from another time.

I'll try to explain the best i can. Lets say a player joins your server, and its been 3 days since the last time you stored the time with gettime().

When he connects what you would want to do is: gettime()-oldtime and that will get the amount of time it has been since his last time storage. Pretty simple, right?

Once you give him the money, you have to update his time to gettime() once again.
Reply
#10

So would be more like this:

pawn Код:
printf("%s",ConvertTime(gettime() - times[playerid][cTime], .ctd=DAY));
this prints that it's 1.3k secs since last update .. but that aint right either its like 5 mins ago or so
Reply


Forum Jump:


Users browsing this thread: 6 Guest(s)