SA-MP Forums Archive
Cheque - Mysql - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Cheque - Mysql (/showthread.php?tid=166662)



Cheque - Mysql [ Solved ] - Cameltoe - 09.08.2010

- 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


Re: Cheque - Mysql - Cameltoe - 10.08.2010

Bump. really need help with this one.


Re: Cheque - Mysql - Grim_ - 10.08.2010

I believe I already helped you over MSN?


Re: Cheque - Mysql - Cameltoe - 10.08.2010

Yeah look at the date

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


Re: Cheque - Mysql - Cameltoe - 18.08.2010

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


Re: Cheque - Mysql - Cameltoe - 19.08.2010

Please somone?


Re: Cheque - Mysql - Kyosaur - 19.08.2010

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.


Re: Cheque - Mysql - Cameltoe - 19.08.2010

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?


Re: Cheque - Mysql - Kyosaur - 19.08.2010

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.


Re: Cheque - Mysql - Cameltoe - 19.08.2010

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