[Help] Function Multiplier

Skilled Illusionist
Joined
Sep 2, 2010
Messages
393
Reaction score
10
How does one go about creating a function in NPCCM.java or MapleCharacter.java where it multiplies your vote points for the necessary gach tickets? For example, a vote point would be worth 5 gach tickets(making believe, calm down) and the function would automatically multiply and if you had 0 vote points you could redeem 0 gach tickets. if you had 1 would redeem 5, and 2 you would redeem 10 and so on. like this (sorry if i am confusing anyone)
PHP:
You currently have #r"+cm.getPlayer().getVotePoints() +"#k #bVoting Points for#k <AND THE FUNCTION GOES HERE
The function would go there and somehow multiply it for the player making them have somewhat 10 voting points and they would be able to redeem 30 tickets.
 
Can't you do this inside the NPC? Or does this have to be a method.

Just use the getVotingPoints and multiply it by 5.

Something like (it's probably not right but it should give you an idea of what to do).
cm.gainItem(ITEMID, cm.getPlayer().getVotePoints() * 5);
 
Upvote 0
var noOfGachapon = cm.getPlayer().getVotePoints()*5;

Just implement it into your npc javascript.
PHP:
var noOfGachapon = cm.getPlayer().getVotePoints()*5;

Then call for it in the line:
PHP:
"You currently have #r"+cm.getPlayer().getVotePoints() +"#k #bVoting Points for#k " + noOfGachapon + "# Gachapon Ticket "
 
Upvote 0
Do you mean something like this?
PHP:
var item = [gachaticketid, otherids]; //item, the id of the item
var price = [price 1, price 2]; //currently mesos but you can make item
var amount = [amount 1, amount 2]; //yes, this can all be one array but meh..


cm.sendGetText("how many you want to buy la?"); //amount they want to buy
var aaa = cm.getText(); //use this to get the text of the amount they want
var ccc = selection; //determine which is which i guess? dunno if i need var, think so
if (aaa.equals("0") { //add check if they enter 0, maybe none at all o-o
cm.gainItem(item[ccc]);
} else //something to this sort.
cm.gainItem(item[ccc], amount[ccc] * aaa); //gain the item, multiplied by the amount (of the item) then add the amount given.
cm.gainMeso(-price[ccc] * aaa);

Pretty much makes a list of 1). the item id's, 2). the amount of the item by default (say 1vp is 5gacha by default), 3). price of the item.
Then makes the selection and asks for an amount, and gives it to you. This code is probably totally incorrect but it's just an example of things you would use to do so.
 
Upvote 0
Do you mean something like this?
PHP:
var item = [gachaticketid, otherids]; //item, the id of the item
var price = [price 1, price 2]; //currently mesos but you can make item
var amount = [amount 1, amount 2]; //yes, this can all be one array but meh..


cm.sendGetText("how many you want to buy la?"); //amount they want to buy
var aaa = cm.getText(); //use this to get the text of the amount they want
var ccc = selection; //determine which is which i guess? dunno if i need var, think so
if (aaa.equals("0") { //add check if they enter 0, maybe none at all o-o
cm.gainItem(item[ccc]);
} else //something to this sort.
cm.gainItem(item[ccc], amount[ccc] * aaa); //gain the item, multiplied by the amount (of the item) then add the amount given.
cm.gainMeso(-price[ccc] * aaa);

Pretty much makes a list of 1). the item id's, 2). the amount of the item by default (say 1vp is 5gacha by default), 3). price of the item.
Then makes the selection and asks for an amount, and gives it to you. This code is probably totally incorrect but it's just an example of things you would use to do so.

He want a dynamic script whereby the script will check how many vote point he has if he choose the option of changing his vote point to gachapon ticket and give him a option that used up all his votepoint for the ticket.
 
Upvote 0
PHP:
/*
------------------------------
	Created by Ryuuzi
------------------------------
*/

var status;
var chosenAmt;
var mult = 5; // Change number to the amount of tickets you would like to give per point

function start() {
	status = -1;
	action(1, 0, 0);
}

function action(mode, type, selection) {
	if (mode == -1) {
		cm.dispose();
		return;
	} else {
		if (mode == 1) {
			status++;
		} else {
			status--;
		}
	}
	if (status == 0) {
		cm.sendNext("Welcome to " + /* Insert Server name Here */ + "'s Vote Point Trader. I trade Vote Points for Gachapon Tickets");
	} else if (status == 1) {
		if (mode == 0) {
			cm.sendOk("I see. Well come back if you decide you'd like to trade in some points.");
			cm.dispose();
		} else {
			cm.sendGetNumber("How many Vote Points would you like to trade in?" 0, 0, cm.getPlayer().getVotePoints());
		}
	} else if (status == 2) {
		chosenAmt = selection;
		if (chosenAmt == 0) {
			cm.sendOk("I see. Well come back if you decide you'd like to trade in some points.");
			cm.dispose();
		} else {
			cm.sendYesNo("So you want to trade #b" + chosenAmt + " Vote Points #kfor #r" + (chosenAmt * mult) + " Gachapon Tickets#k?");
		}
	} else if (status == 3) {
		if (cm.getPlayer().getVotePoints() == chosenAmt) {
			cm.getPlayer().setVotePoints(cm.getPlayer().getVotePoints() - chosenAmt);
			cm.gainItem(/*Insert Item ID here*/, (chosenAmt * mult));
			cm.sendOk("Thanks for trading in your points!");
			cm.dispose();
		} else {
			cm.sendOk("Please double check and make sure you have the necessary amount of points.");
			cm.dispose();
		}
	}
}
 
Upvote 0
Back