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