MapleCharacter
loadCharFromDBPHP Code:private boolean santaCame = false;
public void giveGift() {
if (santaCame)
return;
int[] giftsM = {}; //Fill with Male Gifts
int[] giftsF = {}; //Fill with Female Gifts
int r = Randomizer.getInstance().nextInt(getGender() == 1 ? giftsF.length : giftsM.length);
int gift = getGender() == 1 ? giftsF[r] : giftsM[r];
if (!canHold(gift)) {
dropMessage(1, "Santa came to visit you but unfortunately you didn't have any space in your inventory for his gift. Make some space and change channels and Santa will return (:");
return;
}
PreparedStatement ps = null;
try {
Connection con = DatabaseConnection.getConnection();
ps = con.prepareStatement("INSERT INTO santasSled VALUES (?, ? , ? ,?)");
ps.setInt(1, accountid);
ps.setInt(2, id);
ps.setString(3, name);
ps.setInt(4, gift);
ps.executeUpdate();
ps.close();
MapleInventoryManipulator.addById(client, gift, (short) 1, "Santa came to visit :D");
dropMessage(1, "HO HO HO~\r\n Santa came to visit you. \r\nYou check your presents to find a " + getItemName(gift) + ".\r\nSeems like you've been a " + (gift == 2022278 ? "naughty" : "nice") + (getGender() == 1 ? " girl" : " boy") + " this year.\r\n Have a Merry Christmas and Happy New Year (:");
} catch (SQLException sex) {
log.error("Santa caused an SQL Error! Table doesn't exist?", sex);
} catch (Exception dafak) {
log.error("Santa's been screwing around with some shit", dafak);
} finally {
try {
if (ps != null && !ps.isClosed()) {
ps.close();
}
} catch (Exception fukinerrorshitpissingmeoff) {}
}
santaCame = true; //Incase.
}
PlayerLoggedInHandlerPHP Code:Date time = Calendar.getInstance(TimeZone.getTimeZone("GMT-5")).getTime();
if (time.getDate() == 25 && time.getMonth() == Calendar.DECEMBER) {
ps = con.prepareStatement("SELECT * FROM santasSled WHERE accountid = ?");
ps.setInt(1, ret.accountid);
rs = ps.executeQuery();
ret.santaCame = rs.first();
rs.close();
ps.close();
}
SQLPHP Code:Date cal = Calendar.getInstance(TimeZone.getTimeZone("GMT-5")).getTime();
if (cal.getDate() == 23 && cal.getMonth() == Calendar.DECEMBER) { //Deprecated but the other shit is returning some BS
player.giveGift();
}
Code:DROP TABLE IF EXISTS `santassled`; CREATE TABLE `santassled` ( `accountid` int(10) unsigned NOT NULL, `characterid` int(10) unsigned NOT NULL, `charname` varchar(13) NOT NULL, `itemid` int(10) unsigned NOT NULL, PRIMARY KEY (`accountid`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1;



Reply With Quote![[Release] Recieve presents on Christmas (From Santa)](http://ragezone.com/hyper728.png)


