Temporary Vip system -
DetoNater - 09.07.2015
Actually I have scripted a temporary VIP system, by the way I save the date using timestamptodate in mysql!! but when I retrieve it on loadmystats, the date must be converted to unix timestamp to compare with gettime so that it'll be shown: VIP until:, but the datetotimestamp is not returning values...
is there any alternatives??
my code
Код:
if(DonateLevel[playerid] > 0)
{
new str[128];
dex[playerid] = DateToTimestamp(DonateExpire[playerid]); <<<<< ---here is the problem--- >>>>>>
printf("dex: %s", DonateExpire[playerid]);
if(DonateExpire[playerid] != 0)
{
if(gettime() < dex[playerid]) <<<< here i want to compare the expire date >>>>>>
{
switch(Sprache[playerid])
{
case 0: format(str,sizeof(str),"DONOR: Spende Level %d bis: %s.",DonateLevel[playerid],DonateExpire[playerid]);
case 1: format(str,sizeof(str),"DONOR: Donator Level %d until: %s.",DonateLevel[playerid],DonateExpire[playerid]);
case 2: format(str,sizeof(str),"DONOR: Nivel de donante %d hasta: %s.",DonateLevel[playerid],DonateExpire[playerid]);
}
SendClientMessage(playerid,0x2641FEFF,str);
SendLangMessage(playerid,_COLOR_WHITE,"DONOR: Schreibe /donorcmds um deine Commands zu sehen","Type /donorcmds to see your commands.","Escribe /donorcmds para ver tus comandos.");
}
else
{
switch(Sprache[playerid])
{
case 0: format(str,sizeof(str),"DONOR: Dein Spende Level (%d) ist am %s abgelaufen.",DonateLevel[playerid],DonateExpire[playerid]);
case 1: format(str,sizeof(str),"DONOR: Your Donator Level (%d) expired on %s.",DonateLevel[playerid],DonateExpire[playerid]);
case 2:format(str,sizeof(str),"DONOR: Tu nivel de donante (%d) expirу el %s.",DonateLevel[playerid],DonateExpire[playerid]);
}
SendClientMessage(playerid,0x2641FEFF,str);
DonateLevel[playerid] = 0;
VIP[playerid] = 0;
DonateExpire[playerid] = 0;
}
}
else
{
switch(Sprache[playerid])
{
case 0: format(str,sizeof(str),"DONOR: Spende Level: %d bis: Unbefristet",DonateLevel[playerid]);
case 1: format(str,sizeof(str),"DONOR: Donator Level: %d until: Permanent",DonateLevel[playerid]);
case 2: format(str,sizeof(str),"DONOR: Nivel de donante: %d hasta: Permanente",DonateLevel[playerid]);
}
SendClientMessage(playerid,0x2641FEFF,str);
SendLangMessage(playerid,_COLOR_WHITE,"DONOR: Schreibe /donorcmds um deine Commands zu sehen","Type /donorcmds to see your commands.","Escribe /donorcmds para ver tus comandos.");
}
}
Re: Temporary Vip system -
dominik523 - 09.07.2015
Save the time in the timestamp and every time you need to get the correct date, use a MySQL's function called FROM_UNIXTIME().
Thanks to Vince for mentioning this in another thread.
Re: Temporary Vip system -
DetoNater - 09.07.2015
I know that, but when I change the date in database directly, I enter it as date format(so that i need not go ingame and set the vip!)...
Re: Temporary Vip system -
dominik523 - 09.07.2015
Just use it like this:
pawn Код:
new ExpireDate...
ExpireDate[playerid] = gettime(); // save the results in the database after this
CMD:vipdate(playerid)
{
// run a query here which will get the date as a string from the timestamp that you've saved before
...
}
Re: Temporary Vip system -
DetoNater - 09.07.2015
that's what i've done in my code.....
you could see DonateExpire in my code contains the value of date from my mysql...
Re: Temporary Vip system -
DetoNater - 09.07.2015
-bump- actually, i used jochemd's datetotimestamp(that to i have edited the stock) but i have a negative timestamp eg -567326678 what should i do now?