points2item alternate version

Created Diff never expires
40 removals
Lines
Total
Removed
Words
Total
Removed
To continue using this feature, upgrade to
Diffchecker logo
Diffchecker Pro
143 lines
40 additions
Lines
Total
Added
Words
Total
Added
To continue using this feature, upgrade to
Diffchecker logo
Diffchecker Pro
143 lines
/*=========================================================
/*=========================================================
Points to Item Exchanger
Points to Item Exchanger
by Mumbles
by Mumbles
===========================================================
===========================================================
Request: http://goo.gl/MplDtF
Request: https://shorturl.at/cnsy3
===========================================================
Preview: http://youtu.be/V-6ahRLqRi4
===========================================================
===========================================================
Description:
Description:
Exchanges items for points and vice-versa at a fixed rate.
Exchanges items for points and vice-versa at a fixed rate.
===========================================================
===========================================================
Compatibility:
Compatibility:
Optimised for Hercules emulators.
Optimised for Hercules emulators.
===========================================================
===========================================================
Changelog:
Changelog:
v1.0 - First version.
v1.0 - First version.
v1.0.1 - Added changelog.
v1.0.1 - Added changelog.
v1.0a - Alternate version; uses PoDs instead of points for
base-1 when converting.
=========================================================*/
=========================================================*/


prontera,164,169,3 script Donation Manager::points2item 4_M_OPERATION,{
prontera,164,169,3 script Donation Manager::points2item 4_M_OPERATION,{
/*-----------------------------------------------------
/*-----------------------------------------------------
Script
Script
-----------------------------------------------------*/
-----------------------------------------------------*/
mes .npc_name$;
mes .npc_name$;
mes "Hello there, ^FF8800"+ strcharinfo(0) +"^000000! "+
mes "Hello there, ^FF8800"+ strcharinfo(0) +"^000000! "+
"Would you exchange your "+ .pod_name$ +" "+
"Would you exchange your "+ .points_name$ +" "+
"for "+ .points_name$ +"?";
"for "+ .pod_name$ +"?";
mes " ";
mes " ";
mes "Exchange Rate: "+ .rate +":1";
mes "Exchange Rate: "+ .rate +":1";
mes .points_name$ +": [^FF0000"+ getd(.points_var$) +"^000000]";
mes .points_name$ +": [^FF0000"+ getd(.points_var$) +"^000000]";
next;
next;
switch (select(implode(.menu_options$, ":"))) {
switch (select(implode(.menu_options$, ":"))) {
case 1:
case 1:
mes .npc_name$;
mes .npc_name$;
mes "Okay, come back if you change your mind!";
mes "Okay, come back if you change your mind!";
break;
break;
case 2:
case 2:
mes .npc_name$;
mes .npc_name$;
mes "Please enter the amount of "+ .pod_name$ +" you want to exchange.";
mes "Please enter the amount of "+ .points_name$ +" that you want to exchange.";
do {
do {
mes " ";
mes " ";
mes "Input ^0000FF0^000000 to cancel.";
mes "Input ^0000FF0^000000 to cancel.";
next;
next;
input .@amount;
input .@amount;
.@total = .@amount / .rate;
.@total = .@amount / .rate;
.@remainder = .@amount % .rate;
.@remainder = .@amount % .rate;
// Check break input
// Check break input
if (!.@amount) {
if (!.@amount) {
message strcharinfo(0), strnpcinfo(1) +" : Exchange terminated.";
message strcharinfo(0), strnpcinfo(1) +" : Exchange terminated.";
close;
close;
}
}
// Check total against inventory
// Check amount against points
if (countitem(.pod_id) < .@amount) {
if (getd(.points_var$) < .@amount) {
mes .npc_name$;
mes .npc_name$;
mes "^FF0000Please enter a valid amount.^000000";
mes "^FF0000Please enter a valid amount.^000000";
}
}
// Check remainder [loss prevention]
// Check remainder [loss prevention]
else if (.@remainder) {
else if (.@remainder) {
mes .npc_name$;
mes .npc_name$;
mes "Sorry, but you must exchange multiples of "+ .rate +".";
mes "Sorry, but you must exchange multiples of "+ .rate +".";
}
}
} while (countitem(.pod_id) < .@amount || .@remainder);
} while (getd(.points_var$) < .@amount || .@remainder);
Text moved from lines 105-110
delitem .pod_id, .@amount;
// Check weight
setd .points_var$, getd(.points_var$) + .@total;
if (!checkweight(.pod_id, .@total)) {
mes .npc_name$;
mes "^FF0000You're overweight; please store some items.^000000";
break;
}
setd .points_var$, getd(.points_var$) - .@amount;
getitem .pod_id, .@total;
mes .npc_name$;
mes .npc_name$;
mes "You've exchanged "+ .@amount +" "+ .pod_name$ +" for "+ .@total +" "+ .points_name$ +". "+
mes "You've exchanged "+ .@amount +" "+ .points_name$ +" for "+ .@total +" "+ .pod_name$ +". "+
"You now have "+ getd(.points_var$) +" "+ .points_name$ +" and "+ countitem(.pod_id) +" "+ .pod_name$ +".";
"You now have "+ getd(.points_var$) +" "+ .points_name$ +" and "+ countitem(.pod_id) +" "+ .pod_name$ +".";
break;
break;
case 3:
case 3:
mes .npc_name$;
mes .npc_name$;
mes "Please enter the amount of "+ .points_name$ +" that you want to exchange.";
mes "Please enter the amount of "+ .pod_name$ +" you want to exchange.";
do {
do {
mes " ";
mes " ";
mes "Input ^0000FF0^000000 to cancel.";
mes "Input ^0000FF0^000000 to cancel.";
next;
next;
input .@amount;
input .@amount;
.@total = .@amount * .rate;
.@total = .@amount * .rate;
// Check break input
// Check break input
if (!.@amount) {
if (!.@amount) {
message strcharinfo(0), strnpcinfo(1) +" : Exchange terminated.";
message strcharinfo(0), strnpcinfo(1) +" : Exchange terminated.";
close;
close;
}
}
// Check amount against points
// Check total against inventory
if (getd(.points_var$) < .@amount) {
if (countitem(.pod_id) < .@amount) {
mes .npc_name$;
mes .npc_name$;
mes "^FF0000Please enter a valid amount.^000000";
mes "^FF0000Please enter a valid amount.^000000";
}
}
} while (getd(.points_var$) < .@amount);
} while (countitem(.pod_id) < .@amount);
Text moved to lines 72-77
// Check weight
if (!checkweight(.pod_id, .@total)) {
mes .npc_name$;
mes "^FF0000You're overweight; please store some items.^000000";
break;
}
setd .points_var$, getd(.points_var$) - .@amount;
delitem .pod_id, .@amount;
getitem .pod_id, .@total;
setd .points_var$, getd(.points_var$) + .@total;
mes .npc_name$;
mes .npc_name$;
mes "You've exchanged "+ .@amount +" "+ .points_name$ +" for "+ .@total +" "+ .pod_name$ +". "+
mes "You've exchanged "+ .@amount +" "+ .pod_name$ +" for "+ .@total +" "+ .points_name$ +". "+
"You now have "+ getd(.points_var$) +" "+ .points_name$ +" and "+ countitem(.pod_id) +" "+ .pod_name$ +".";
"You now have "+ getd(.points_var$) +" "+ .points_name$ +" and "+ countitem(.pod_id) +" "+ .pod_name$ +".";
break;
break;
}
}
close;
close;
/*-----------------------------------------------------
/*-----------------------------------------------------
Configuration
Configuration
-----------------------------------------------------*/
-----------------------------------------------------*/
OnInit:
OnInit:
.npc_name$ = "[^0000FFDonation Manager^000000]";
.npc_name$ = "[^0000FFDonation Manager^000000]";
.rate = 20; // Exchange rate (1 point * rate = total PoDs)
.rate = 10; // Exchange rate (1 point * rate = 1 PoD)
.pod_id = Donation_Card; // Proof of Donation item ID or constant
.pod_id = Donation_Card; // Proof of Donation item ID or constant
.pod_name$ = getitemname(.pod_id) +"(s)"; // Proof of Donation item name
.pod_name$ = getitemname(.pod_id) +"(s)"; // Proof of Donation item name
.points_name$ = "Cash Point(s)"; // Points name
.points_name$ = "Cash Point(s)"; // Points name
.points_var$ = "#CASHPOINTS"; // Points variable
.points_var$ = "#CASHPOINTS"; // Points variable
// Modifying these options requires updates to the corresponding case
// Modifying these options requires updates to the corresponding case
setarray .menu_options$[0], "^FF0000>^000000 Cancel",
setarray .menu_options$[0], "^FF0000>^000000 Cancel",
"^0000FF>^000000 Exchange "+ .pod_name$ +" for "+ .points_name$,
"^0000FF>^000000 Exchange "+ .points_name$ +" for "+ .pod_name$,
"^0000FF>^000000 Exchange "+ .points_name$ +" for "+ .pod_name$;
"^0000FF>^000000 Exchange "+ .pod_name$ +" for "+ .points_name$;
end;
end;
}
}