Temporary Vip system
#1

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.");
		}
	}
Reply
#2

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

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!)...
Reply
#4

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
...
}
Reply
#5

that's what i've done in my code.....

you could see DonateExpire in my code contains the value of date from my mysql...
Reply
#6

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


Forum Jump:


Users browsing this thread: 1 Guest(s)