Welcome!

Join our community of MMO enthusiasts and game developers! By registering, you'll gain access to discussions on the latest developments in MMO server files and collaborate with like-minded individuals. Join us today and unlock the potential of MMO server development!

Join Today!

[Release] Recieve presents on Christmas (From Santa)

Mythic Archon
Loyal Member
Joined
May 11, 2008
Messages
722
Reaction score
50
MapleCharacter
PHP:
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 poop", dafak);
		} finally {
			try {
				if (ps != null && !ps.isClosed()) {
					ps.close();
				}
			} catch (Exception fukinerrorshitpissingmeoff) {}
		}
		santaCame = true; //Incase.
	}
loadCharFromDB
PHP:
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();
			}
PlayerLoggedInHandler
PHP:
Date cal = Calendar.getInstance(TimeZone.getTimeZone("GMT-5")).getTime();
		if (cal.getDate() == 23 && cal.getMonth() == Calendar.DECEMBER) { //Deprecated but the other poop is returning some BS
			player.giveGift();
		}
SQL
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;
 
Legendary Battlemage
Loyal Member
Joined
Jul 13, 2009
Messages
671
Reaction score
139
Interesting, sad that its 12/26 and Christmas is over.
 
Mythic Archon
Loyal Member
Joined
May 11, 2008
Messages
722
Reaction score
50
Interesting, sad that its 12/26 and Christmas is over.

That's basically why I released it. (Yeah, I'm selfish ^^)
It can be modified for other events/holidays though
 
Legendary Battlemage
Loyal Member
Joined
Jul 13, 2009
Messages
671
Reaction score
139
That's basically why I released it. (Yeah, I'm selfish ^^)
It can be modified for other events/holidays though


Yeah, I noticed how the thread was made/released on 12:01 AM -_-...
Yeah I'm EST too.
 
Back
Top