// Vote Points Exchanger by Myzter
function script VoteExchange {
mes "[^0000ff" + getarg(0) + "^000000]";
mes "Hello ^0000ff" + strcharinfo(0) + "^000000, i'm " + getarg(0) + ".";
mes "I'm offering ^ff0000" + getarg(1) + "^000000 ^0000ff" + getitemname(getarg(2)) + (getarg(1)>1?"'s":"") + "^000000 for every ^ff0000" + getarg(3) + "^000000 Vote Point" + (getarg(3)>1?"s":"") + " you pay.";
if (#VotePoints < getarg(3)) {
mes " ";
mes "Vote for us and win Vote Points!";
close;
}
// Maximum quantity by Points
set .@MaxQtt, #VotePoints / getarg(3);
// Maximum quantity by Weight
while (!checkweight(getarg(2),.@MaxQtt * getarg(1)) && .@MaxQtt > 0) {
set .@MaxQtt, .@MaxQtt - 1;
};
if (!.@MaxQtt) {
mes "Please free some space and back back later.";
close;
}
mes " ";
mes "Are you interested?";
next;
if (select("Yes, please!:Maybe later " + getarg(0) + ".") == 2) goto l_Exit;
// Limit the trades to 50 options each time
if (.@MaxQtt > 50) set .@MaxQtt,50;
mes "[^0000ff" + getarg(0) + "^000000]";
if (.@MaxQtt > 1) {
mes "How many ^0000ff" + getitemname(getarg(2)) + (getarg(1)>1?"'s":"") + "^000000 you want to trade?";
mes " ";
mes "^ff0000" + getarg(1) + "^000000 ^0000ff" + getitemname(getarg(2)) + (getarg(1)>1?"'s":"") + "^000000 x ^ff0000" + getarg(3) + "^000000 Vote Point" + (getarg(3)>1?"s":"") + " ^c0c0c0(" + #VotePoints + " VP)";
next;
set .@Menu$, "";
for (set .@x,1; .@x <= .@MaxQtt; set .@x, .@x + 1) {
set .@Menu$, .@Menu$ + "- " + (.@x * getarg(1)) + " " + getitemname(getarg(2)) + (.@x>1?"'s":"") + " (" + (.@x * getarg(3)) + " VP):";
}
set .@Menu$, .@Menu$ + ":^ff0000Cancel^000000";
set .@SelOpt, select(.@Menu$);
if (.@SelOpt == .@x + 1) goto l_Exit;
set .@SelQtt, .@SelOpt * getarg(1);
mes "[^0000ff" + getarg(0) + "^000000]";
} else {
set .@SelQtt, getarg(1);
}
set .@SelPay, .@SelQtt / getarg(1) * getarg(3);
mes "Are you sure you want to trade ^ff0000" + .@SelQtt + " ^0000ff" + getitemname(getarg(2)) + (getarg(1)>1?"'s":"") + "^000000 for ^ff0000" + .@SelPay + "^000000 Vote Point" + (getarg(3)>1?"s?":"?");
next;
if (select("Yes, please","No, thanks") == 2) goto l_Exit;
mes "[^0000ff" + getarg(0) + "^000000]";
if (#VotePoints < .@SelPay) {
mes "Something is wrong, you don't have enought Vote Points, are you trying to cheat?";
close;
}
getitem getarg(2),.@SelQtt;
set #VotePoints, #VotePoints - .@SelPay;
mes "Thank you very much for the deal, I'd love to see you again ^0000ff" + strcharinfo(0) + "^000000.";
mes " ";
mes "> Your Balance: ^ff0000" + #VotePoints + "^000000 ^0000ffVote Point" + (#VotePoints==1?"":"s") + "^000000";
mes " ";
mes "~ ^0080FFDo not forget to vote for us~ ";
close;
l_Exit:
mes "[^0000ff" + getarg(0) + "^000000]";
mes "As you want, i hope to see you again ^0000ff" + strcharinfo(0) + "^000000.";
mes " ";
mes "~ ^0080FFDo not forget to vote for us~ la la ~";
close;
}
// The function use this parameters:
// 0 -> NPC Name, don't change it because is using the name you set in the NPC
// 1 -> Quantity of Items to exchange
// 2 -> Item ID to exchange
// 3 -> Amount of Vote Points to Pay for that amount of items
// This Sample NPC changes 5 apples for every 2 Vote Points
prontera,147,164,5 script Elizabeth#001 437,{
callfunc "VoteExchange",strnpcinfo(1),5,512,2;
}
// This NPC change 1 Poring Coint for 1 Vote Point
prontera,147,166,5 script Akaru#002 437,{
callfunc "VoteExchange",strnpcinfo(1),1,7539,1;
}