Jump to content
  • 1
Sign in to follow this  
hadiesyafiq

Request script display time left for vip account

Question

hi all i use vip script base on group id...but how to put message expired time for that script?i need change the script?i need alter SQL table? can someone teach me?

here vip script that i use..

Quote

function	script	F_TicketAddVip	{
	Query_SQL "SELECT `days` FROM `viptable` WHERE `vipacc_id` = '"+GetCharID(3)+"'", .@checkDays;
	if (.@checkDays > 0) {
		Set .@setDays, (.@checkDays + 30);
		Query_SQL "UPDATE `viptable` SET `days`='"+.@setDays+"' WHERE `vipacc_id`='"+GetCharID(3)+"'";
		Query_SQL "SELECT `group_id` FROM `login` WHERE  `account_id`='"+GetCharID(3)+"'", .@userLevel;
		If (.@userLevel < 1) 
			Query_SQL "UPDATE `login` SET `group_id`='2' WHERE `account_id`='"+GetCharID(3)+"'";
	}
	Else {
		Query_SQL "UPDATE `login` SET `group_id`='2' WHERE `account_id`='"+GetCharID(3)+"'";
		Query_SQL "SELECT `userid` FROM `login` WHERE `account_id`='"+GetCharID(3)+"'", .@userID$;
		Query_SQL "SELECT `email` FROM `login` WHERE `account_id`='"+GetCharID(3)+"'", .@userEmail$;
		Query_SQL "INSERT INTO `viptable` (`vipacc_id`,`vip_id`,`days`,`email`) VALUES ('"+GetCharID(3)+"','"+.@userID$+"','30','"+.@accEmail$+"')";
	}
	AtCommand "@reloadpcdb";
	dispbottom "You received 30 days of VIP Account, congrats!";
	specialeffect2 338;
	End;
Return;
}

here SQL table

Quote

DROP TABLE IF EXISTS `viptable`;
CREATE TABLE `viptable` (
  `vipacc_id` int(11) unsigned NOT NULL default '0',
  `vip_id` varchar(255) NOT NULL default '',
  `days` int(11) NOT NULL default '0',
  `email` varchar(39) NOT NULL default '',
  PRIMARY KEY  (`vipacc_id`),
  KEY `name` (`vip_id`)
) ENGINE=MyISAM; 

INSERT INTO `viptable` (`vipacc_id`, `vip_id`, `days`, `email`) VALUES ('1', 'VIP', '1', '[email protected]');

here the script can someone teach me how add?

Quote

-    script    VIP_STATUS    FAKE_NPC,{
OnPCLoginEvent:
    if (getgroupid() >= 2) {
            dispbottom "========================";
            dispbottom "Account Status : VIP";
            dispbottom "Expire Date : "+???;
            dispbottom "Time left : "+???
            dispbottom "========================";
      end;
    }
}

 

Share this post


Link to post
Share on other sites

8 answers to this question

Recommended Posts

  • 0

Hi.

Alter your SQL table:

ALTER TABLE `viptable` ADD COLUMN `insert_on` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP AFTER `email`;

Or recreate it:

DROP TABLE IF EXISTS `viptable`;
CREATE TABLE `viptable` (
  `vipacc_id` int(11) unsigned NOT NULL default '0',
  `vip_id` varchar(255) NOT NULL default '',
  `days` int(11) NOT NULL default '0',
  `email` varchar(39) NOT NULL default '',
  `insert_on` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY  (`vipacc_id`),
  KEY `name` (`vip_id`)
) ENGINE=MyISAM;


Change your function (note line 2):

function	script	F_TicketAddVip	{
	Query_SQL "DELETE FROM `viptable` WHERE `vipacc_id` = '"+GetCharID(3)+"' AND DATEDIFF(DATE_ADD(`insert_on`, INTERVAL `days` DAY), NOW()) < 0"; // remove expired VIP status before reapplying
	Query_SQL "SELECT `days` FROM `viptable` WHERE `vipacc_id` = '"+GetCharID(3)+"'", .@checkDays;
	if (.@checkDays > 0) {
		Set .@setDays, (.@checkDays + 30);
		Query_SQL "UPDATE `viptable` SET `days`='"+.@setDays+"' WHERE `vipacc_id`='"+GetCharID(3)+"'";
		Query_SQL "SELECT `group_id` FROM `login` WHERE `account_id`='"+GetCharID(3)+"'", .@userLevel;
		If (.@userLevel < 1) 
			Query_SQL "UPDATE `login` SET `group_id`='2' WHERE `account_id`='"+GetCharID(3)+"'";
	}
	Else {
		Query_SQL "UPDATE `login` SET `group_id`='2' WHERE `account_id`='"+GetCharID(3)+"'";
		Query_SQL "SELECT `userid` FROM `login` WHERE `account_id`='"+GetCharID(3)+"'", .@userID$;
		Query_SQL "SELECT `email` FROM `login` WHERE `account_id`='"+GetCharID(3)+"'", .@userEmail$;
		Query_SQL "INSERT INTO `viptable` (`vipacc_id`,`vip_id`,`days`,`email`) VALUES ('"+GetCharID(3)+"','"+.@userID$+"','30','"+.@accEmail$+"')";
	}
	AtCommand "@reloadpcdb";
	dispbottom "You received 30 days of VIP Account, congrats!";
	specialeffect2 338;
	End;
Return;
}

 

The info script could look like this:

-    script    VIP_STATUS    FAKE_NPC,{
OnPCLoginEvent:
	if (getgroupid() >= 2) {
		Query_SQL "SELECT DATE(DATE_ADD(`insert_on`, INTERVAL `days` DAY)), DATEDIFF(DATE_ADD(`insert_on`, INTERVAL `days` DAY), NOW()) FROM `viptable` WHERE `vipacc_id` = '"+GetCharID(3)+"'", .@expire_date$, .@days_left;
		dispbottom "========================";
		dispbottom "Account Status : VIP";
		dispbottom "Expire Date : " + .@expire_date$;
		dispbottom "Time left : " + .@days_left;
		dispbottom "========================";
		end;
	}
}



~Kenpachi

Share this post


Link to post
Share on other sites
  • 0
14 hours ago, Kenpachi said:

Hi.

Alter your SQL table:

ALTER TABLE `viptable` ADD COLUMN `insert_on` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP AFTER `email`;


ALTER TABLE `viptable` ADD COLUMN `insert_on` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP AFTER `email`;

Or recreate it:

DROP TABLE IF EXISTS `viptable`; CREATE TABLE `viptable` ( `vipacc_id` int(11) unsigned NOT NULL default '0', `vip_id` varchar(255) NOT NULL default '', `days` int(11) NOT NULL default '0', `email` varchar(39) NOT NULL default '', `insert_on` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (`vipacc_id`), KEY `name` (`vip_id`) ) ENGINE=MyISAM;


DROP TABLE IF EXISTS `viptable`;
CREATE TABLE `viptable` (
  `vipacc_id` int(11) unsigned NOT NULL default '0',
  `vip_id` varchar(255) NOT NULL default '',
  `days` int(11) NOT NULL default '0',
  `email` varchar(39) NOT NULL default '',
  `insert_on` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY  (`vipacc_id`),
  KEY `name` (`vip_id`)
) ENGINE=MyISAM;


Change your function (note line 2):

function script F_TicketAddVip { Query_SQL "DELETE FROM `viptable` WHERE `vipacc_id` = '"+GetCharID(3)+"' AND DATEDIFF(DATE_ADD(`insert_on`, INTERVAL `days` DAY), NOW()) < 0"; // remove expired VIP status before reapplying Query_SQL "SELECT `days` FROM `viptable` WHERE `vipacc_id` = '"+GetCharID(3)+"'", .@checkDays; if (.@checkDays > 0) { Set .@setDays, (.@checkDays + 30); Query_SQL "UPDATE `viptable` SET `days`='"+.@setDays+"' WHERE `vipacc_id`='"+GetCharID(3)+"'"; Query_SQL "SELECT `group_id` FROM `login` WHERE `account_id`='"+GetCharID(3)+"'", .@userLevel; If (.@userLevel < 1) Query_SQL "UPDATE `login` SET `group_id`='2' WHERE `account_id`='"+GetCharID(3)+"'"; } Else { Query_SQL "UPDATE `login` SET `group_id`='2' WHERE `account_id`='"+GetCharID(3)+"'"; Query_SQL "SELECT `userid` FROM `login` WHERE `account_id`='"+GetCharID(3)+"'", .@userID$; Query_SQL "SELECT `email` FROM `login` WHERE `account_id`='"+GetCharID(3)+"'", .@userEmail$; Query_SQL "INSERT INTO `viptable` (`vipacc_id`,`vip_id`,`days`,`email`) VALUES ('"+GetCharID(3)+"','"+.@userID$+"','30','"+.@accEmail$+"')"; } AtCommand "@reloadpcdb"; dispbottom "You received 30 days of VIP Account, congrats!"; specialeffect2 338; End; Return; }


function	script	F_TicketAddVip	{
	Query_SQL "DELETE FROM `viptable` WHERE `vipacc_id` = '"+GetCharID(3)+"' AND DATEDIFF(DATE_ADD(`insert_on`, INTERVAL `days` DAY), NOW()) < 0"; // remove expired VIP status before reapplying
	Query_SQL "SELECT `days` FROM `viptable` WHERE `vipacc_id` = '"+GetCharID(3)+"'", .@checkDays;
	if (.@checkDays > 0) {
		Set .@setDays, (.@checkDays + 30);
		Query_SQL "UPDATE `viptable` SET `days`='"+.@setDays+"' WHERE `vipacc_id`='"+GetCharID(3)+"'";
		Query_SQL "SELECT `group_id` FROM `login` WHERE  `account_id`='"+GetCharID(3)+"'", .@userLevel;
		If (.@userLevel < 1) 
			Query_SQL "UPDATE `login` SET `group_id`='2' WHERE `account_id`='"+GetCharID(3)+"'";
	}
	Else {
		Query_SQL "UPDATE `login` SET `group_id`='2' WHERE `account_id`='"+GetCharID(3)+"'";
		Query_SQL "SELECT `userid` FROM `login` WHERE `account_id`='"+GetCharID(3)+"'", .@userID$;
		Query_SQL "SELECT `email` FROM `login` WHERE `account_id`='"+GetCharID(3)+"'", .@userEmail$;
		Query_SQL "INSERT INTO `viptable` (`vipacc_id`,`vip_id`,`days`,`email`) VALUES ('"+GetCharID(3)+"','"+.@userID$+"','30','"+.@accEmail$+"')";
	}
	AtCommand "@reloadpcdb";
	dispbottom "You received 30 days of VIP Account, congrats!";
	specialeffect2 338;
	End;
Return;
}

 

The info script could look like this:

- script VIP_STATUS FAKE_NPC,{ OnPCLoginEvent: if (getgroupid() >= 2) { Query_SQL "SELECT DATE(DATE_ADD(`insert_on`, INTERVAL `days` DAY)), DATEDIFF(DATE_ADD(`insert_on`, INTERVAL `days` DAY), NOW()) FROM `viptable` WHERE `vipacc_id` = '"+GetCharID(3)+"'", .@expire_date$, .@days_left; dispbottom "========================"; dispbottom "Account Status : VIP"; dispbottom "Expire Date : " + .@expire_date$; dispbottom "Time left : " + .@days_left; dispbottom "========================"; end; } }


-    script    VIP_STATUS    FAKE_NPC,{
OnPCLoginEvent:
	if (getgroupid() >= 2) {
		Query_SQL "SELECT DATE(DATE_ADD(`insert_on`, INTERVAL `days` DAY)), DATEDIFF(DATE_ADD(`insert_on`, INTERVAL `days` DAY), NOW()) FROM `viptable` WHERE `vipacc_id` = '"+GetCharID(3)+"'", .@expire_date$, .@days_left;
		dispbottom "========================";
		dispbottom "Account Status : VIP";
		dispbottom "Expire Date : " + .@expire_date$;
		dispbottom "Time left : " + .@days_left;
		dispbottom "========================";
		end;
	}
}



~Kenpachi

Thanks @Kenpachi

Share this post


Link to post
Share on other sites
  • 0
3 hours ago, Kenpachi said:

There is a hidden character behind the semicolon in that line. (Probably caused by text encoding mismatch.)

Can you teach me how to fix ?

Share this post


Link to post
Share on other sites
  • 0
  • Open script file in editor.
  • Find the line which contains query_sql "DELETE FROM `viptable` ......
  • Set cursor to the end of that line (click behind the semicolon)
  • Press Backspace.
  • Save file.

You'll notice that the semicolon wasn't removed, because you deleted the hidden character (whitespace) behind it.


~Kenpachi

Share this post


Link to post
Share on other sites
  • 0
On 12/1/2019 at 10:07 AM, Kenpachi said:
  • Open script file in editor.
  • Find the line which contains query_sql "DELETE FROM `viptable` ......
  • Set cursor to the end of that line (click behind the semicolon)
  • Press Backspace.
  • Save file.

You'll notice that the semicolon wasn't removed, because you deleted the hidden character (whitespace) behind it.


~Kenpachi

Thank you very much sir @Kenpachi all working nice

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.