Yoh Asakura
New member
- Messages
- 261
- Points
- 0
- Emulator
Hello community,
I'm currently using Feeftys VoteForPoints addon for fluxcp and it came with a NPC script but it's not working properly. The thing is that I would like to use quest_shop (npc/custom/quests/quest_shop.txt) as my NPC to Exchange Vote Points for Items. I like this script because you can separate items by category and you can also Equip the item to see how it looks like on the character. Moreover, I have found a third script here in hercules very similar to quest_shop, but with a few changes. I would like to adapt these changes into my current quest_shop script as well, but I could not figure out how.
All I need is to:
1)
Add the SQL commands from the voteforpoints.txt script to the quest_shop.txt
Tables:
I'm currently using Feeftys VoteForPoints addon for fluxcp and it came with a NPC script but it's not working properly. The thing is that I would like to use quest_shop (npc/custom/quests/quest_shop.txt) as my NPC to Exchange Vote Points for Items. I like this script because you can separate items by category and you can also Equip the item to see how it looks like on the character. Moreover, I have found a third script here in hercules very similar to quest_shop, but with a few changes. I would like to adapt these changes into my current quest_shop script as well, but I could not figure out how.
All I need is to:
1)
Add the SQL commands from the voteforpoints.txt script to the quest_shop.txt
Tables:
CREATE TABLE IF NOT EXISTS `cp_vfp_sites` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`votename` varchar(25) NOT NULL,
`voteurl` varchar(255) NOT NULL,
`voteinterval` int(11) NOT NULL,
`votepoints` int(11) NOT NULL,
`imgname` varchar(255) DEFAULT NULL,
`imgurl` varchar(255) DEFAULT NULL,
`datetime_created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=4 ;
ALTER TABLE `cp_createlog` ADD `votepoints` int(11) NOT NULL DEFAULT '0';
CREATE TABLE IF NOT EXISTS `cp_vfp_logs` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`sites_id` int(11) NOT NULL,
`timestamp_expire` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
`timestamp_voted` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
`ipaddress` varchar(155) NOT NULL,
`account_id` int(11) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=7 ;
Quest_Shop Script:
//===== Hercules Script ======================================
//= Euphy's Quest Shop
//===== By: ==================================================
//= Euphy
//===== Current Version: =====================================
//= 1.6a
//===== Description: =========================================
//= A dynamic quest shop based on Lunar's, with easier config.
//= Includes support for multiple shops & cashpoints.
//= Item Preview script by ToastOfDoom.
//===== Additional Comments: =================================
//= 1.0 Initial script.
//= 1.2 Added category support.
//= 1.3 More options and fixes.
//= 1.4 Added debug settings.
//= 1.5 Replaced categories with shop IDs.
//= 1.6 Added support for purchasing stackables.
//= 1.6a Added support for previewing costumes and robes.
//============================================================
// Shop NPCs -- supplying no argument displays entire menu.
// callfunc "qshop"{,<shop ID>{,<shop ID>{,...}}};
//============================================================
prontera,150,150,4 script Quests#1 4_M_GENIE,{ callfunc "qshop"; }
// Script Core
//============================================================
- script quest_shop -1,{
function Add; function Chk; function Slot; function A_An;
OnInit:
freeloop(1);
// -----------------------------------------------------------
// Basic shop settings.
// -----------------------------------------------------------
set .Announce,1; // Announce quest completion? (1: yes / 0: no)
set .ShowSlot,1; // Show item slots? (2: all equipment / 1: if slots > 0 / 0: never)
set .ShowID,0; // Show item IDs? (1: yes / 0: no)
set .ShowZeny,0; // Show Zeny cost, if any? (1: yes / 0: no)
set .MaxStack,100; // Max number of quest items purchased at one time.
// -----------------------------------------------------------
// Points variable -- optional quest requirement.
// setarray .Points$[0],"<variable name>","<display name>";
// -----------------------------------------------------------
setarray .Points$[0],"#votepoints","Vote Points";
// -----------------------------------------------------------
// Shop IDs -- to add shops, copy dummy data at bottom of file.
// setarray .Shops$[1],"<Shop 1>","<Shop 2>"{,...};
// -----------------------------------------------------------
setarray .Shops$[1],"Head","Wings1","Wings";
// -----------------------------------------------------------
// Quest items -- do NOT use a reward item more than once!
// Add(<shop ID>,<reward ID>,<reward amount>,
// <Zeny cost>,<point cost>,
// <required item ID>,<required item amount>{,...});
// -----------------------------------------------------------
//Head
Add(1,19015,1,350000000,50,7027,200,7265,200,932,350,7038,400);
Add(1,15004,1,350000000,0,7027,200,7265,200,932,350,7038,400);
Add(1,15001,1,350000000,0,7027,200,7265,200,932,350,7038,400);
//Wings1
Add(2,15021,1,300000000,0,7440,100,602,250,1055,400,7168,450);
Add(2,15031,1,300000000,0,7440,100,602,250,1055,400,7168,450);
//Wings
Add(2,15022,1,400000000,0,1058,250,7168,300,7064,350,1059,520,7511,600);
// -----------------------------------------------------------
freeloop(0);
set .menu$,"";
for(set .@i,1; .@i<=getarraysize(.Shops$); set .@i,.@i+1) {
set .menu$, .menu$+.Shops$[.@i]+":";
npcshopdelitem "qshop"+.@i,909;
}
end;
OnMenu:
set .@size, getarraysize(@i);
if (!.@size) set .@i, select(.menu$);
else if (.@size == 1) set .@i, @i[0];
else {
for(set .@j,0; .@j<.@size; set .@j,.@j+1)
set .@menu$, .@menu$+.Shops$[@i[.@j]]+":";
set .@i, @i[select(.@menu$)-1];
}
deletearray @i[0],getarraysize(@i);
if (.Shops$[.@i] == "") {
message strcharinfo(0),"An error ocurred.";
end;
}
dispbottom "Select one item per time";
callshop "qshop"+.@i,1;
npcshopattach "qshop"+.@i;
end;
OnBuyItem:
// .@q[] : RewardID, BoughtAmt, RewardAmt, BaseAmt, ReqZeny, ReqPts, { ReqItem, ReqAmt, ... }
setarray .@q[0],@bought_nameid[0],((@bought_quantity[0] > .MaxStack)?.MaxStack
bought_quantity[0]);
copyarray .@q[3],getd(".q_"+.@q[0]+"[0]"),getarraysize(getd(".q_"+.@q[0]));
set .@q[2],.@q[1]*.@q[3];
if (!.@q[2] || .@q[2] > 30000) {
message strcharinfo(0),"You cannot do this many "+getitemname(.@q[0])+".";
end;
}
mes "[Quest Shop]";
mes "Reward: ^0055FF"+((.@q[2] > 1)?.@q[2]+"x ":"")+Slot(.@q[0])+"^000000";
mes "Requirements:";
if (.@q[4]) mes " > "+Chk(Zeny,.@q[4]*.@q[1])+(.@q[4]*.@q[1])+" Zeny^000000";
if (.@q[5]) mes " > "+Chk(getd(.Points$[0]),.@q[5]*.@q[1])+(.@q[5]*.@q[1])+" "+.Points$[1]+" ("+getd(.Points$[0])+"/"+(.@q[5]*.@q[1])+")^000000";
if (.@q[6]) for(set .@i,6; .@i<getarraysize(.@q); set .@i,.@i+2)
mes " > "+Chk(countitem(.@q[.@i]),.@q[.@i+1]*.@q[1])+((.ShowID)?"{"+.@q[.@i]+"} ":"")+Slot(.@q[.@i])+" ("+countitem(.@q[.@i])+"/"+(.@q[.@i+1]*.@q[1])+")^000000";
next;
setarray @qe[1], getiteminfo(.@q[0],5), getiteminfo(.@q[0],11);
if (@qe[2] > 0 && ((@qe[1] & 1) || (@qe[1] & 256) || (@qe[1] & 512) || (@qe[1] & 1024) || (@qe[1] & 2048) || (@qe[1] & 4096) || (@qe[1] & 4) || (@qe[1] & 8192)))
set .@preview,1;
addtimer 1000, strnpcinfo(0)+"::OnEnd";
while(1) {
switch(select(" ~ Do Quest ^0055FF"+getitemname(.@q[0])+"^000000:"+((.@preview && !@qe[7])?" ~ Equip Item...":"")+": ~ ^777777Cancel^000000")) {
case 1:
if (@qe[0]) {
mes "[Quest Shop]";
mes "One or more items are missing.";
close;
}
if (!checkweight(.@q[0],.@q[2])) {
mes "[Quest Shop]";
mes "^FF0000You need "+(((.@q[2]*getiteminfo(.@q[0],6))+Weight-MaxWeight)/10)+" weight capacity to complete this transaction.^000000";
close;
}
if (.@q[4]) Zeny -= (.@q[4]*.@q[1]);
if (.@q[5]) setd .Points$[0], getd(.Points$[0])-(.@q[5]*.@q[1]);
if (.@q[6]) for(set .@i,6; .@i<getarraysize(.@q); set .@i,.@i+2)
delitem .@q[.@i],.@q[.@i+1]*.@q[1];
getitem .@q[0],.@q[2];
if (.Announce) announce strcharinfo(0)+" has completed the quest "+((.@q[2] > 1)?.@q[2]+"x "+getitemname(.@q[0]):A_An(getitemname(.@q[0])))+"!",0;
specialeffect2 EF_FLOWERLEAF;
close;
case 2:
setarray @qe[3], getlook(LOOK_HEAD_BOTTOM), getlook(LOOK_HEAD_TOP), getlook(LOOK_HEAD_MID), getlook(LOOK_ROBE), 1;
if ((@qe[1] & 1) || (@qe[1] & 4096)) changelook LOOK_HEAD_BOTTOM, @qe[2];
else if ((@qe[1] & 256) || (@qe[1] & 1024)) changelook LOOK_HEAD_TOP, @qe[2];
else if ((@qe[1] & 512) || (@qe[1] & 2048)) changelook LOOK_HEAD_MID, @qe[2];
else if ((@qe[1] & 4) || (@qe[1] & 8192)) changelook LOOK_ROBE, @qe[2];
break;
case 3:
close;
}
}
OnEnd:
if (@qe[7]) {
changelook LOOK_HEAD_BOTTOM, @qe[3];
changelook LOOK_HEAD_TOP, @qe[4];
changelook LOOK_HEAD_MID, @qe[5];
changelook LOOK_ROBE, @qe[6];
}
deletearray @qe[0],8;
end;
function Add {
if (getitemname(getarg(1)) == "null") {
debugmes "Quest Reward #"+getarg(1)+" invalid (skipped).";
return;
}
setarray .@j[0],getarg(2),getarg(3),getarg(4);
for(set .@i,5; .@i<getargcount(); set .@i,.@i+2) {
if (getitemname(getarg(.@i)) == "null") {
debugmes "Quest Requirement #"+getarg(.@i)+" invalid (skipped).";
return;
} else
setarray .@j[.@i-2],getarg(.@i),getarg(.@i+1);
}
copyarray getd(".q_"+getarg(1)+"[0]"),.@j[0],getarraysize(.@j);
npcshopadditem "qshop"+getarg(0),getarg(1),((.ShowZeny)?getarg(3):0);
return;
}
function Chk {
if (getarg(0) < getarg(1)) {
set @qe[0],1;
return "^FF0000";
} else
return "^00FF00";
}
function Slot {
set .@s$,getitemname(getarg(0));
switch(.ShowSlot) {
case 1: if (!getitemslots(getarg(0))) return .@s$;
case 2: if (getiteminfo(getarg(0),2) == 4 || getiteminfo(getarg(0),2) == 5) return .@s$+" ["+getitemslots(getarg(0))+"]";
default: return .@s$;
}
}
function A_An {
setarray .@A$[0],"a","e","i","o","u";
set .@B$, "_"+getarg(0);
for(set .@i,0; .@i<5; set .@i,.@i+1)
if (compare(.@B$,"_"+.@A$[.@i])) return "an "+getarg(0);
return "a "+getarg(0);
}
}
function script qshop {
deletearray @i[0],getarraysize(@i);
for(set .@i,0; .@i<getargcount(); set .@i,.@i+1)
set @i[.@i],getarg(.@i);
doevent "quest_shop::OnMenu";
end;
}
// Dummy shop data -- copy as needed.
//============================================================
- shop qshop1 -1,19015:-1,8100:-1,8104:-1
- shop qshop2 -1,15021:-1,15039:-1
- shop qshop3 -1,8226:-1
2)
NPC Vote4Points (only need the SQL commands cause I won't be using this script):
prontera,150,150,4 script VFP Manager 62,{
function getPoints;
set .@n$, "[VFP Manager]";
set .@settings, 1; // 0 = item, 1 = shop
set .@itemReward, 501; // if settings is set to item
set .@convertRate, 2; // 2 Vote Points for 1 Red Potion
set .vp, getPoints(getcharid(3));
switch (.@settings) {
case 0:
mes .@n$;
mes "Would you like to convert your "+ .vp +" Vote Points?";
mes "^ff0000The current convert rate is "+ .@convertRate +" Vote Points for 1 "+ getitemname(.@itemReward) +".";
next;
menu "Yes", L_Convert, "No", -;
mes .@n$;
mes "Bye, then.";
break;
case 1:
mes .@n$;
mes "You have ^ff0000"+ .vp +"^000000 Vote Points.";
mes "Would you like to go shopping?";
next;
menu "Yes", -, "No", L_Goodbye;
mes .@n$;
mes "Have fun shopping!";
callshop "votepoints_shop",1;
npcshopattach "votepoints_shop";
end;
}
L_Goodbye:
mes .@n$;
mes "Goodbye, then.";
close;
L_Convert:
if (.vp < .@convertRate)
goto L_VotePointsTooLow;
mes .@n$;
mes "How much Vote Points would you like to convert?";
next;
menu "All", L_ConvertAll, "Input Amount", L_ConvertAmount;
L_ConvertAmount:
input .@convert;
if (.@convert > .vp)
goto L_VotePointsTooLow;
set .vp, ((.vp - .@convert) + (.@convert % .@convertRate));
set .@convert, (.@convert / .@convertRate);
getitem .@itemReward, .@convert;
query_sql("UPDATE cp_createlog SET votepoints = "+ .vp +" WHERE account_id = "+ getcharid(3));
mes .@n$;
mes "You have received "+ .@convert +"x "+ getitemname(.@itemReward) +".";
mes "Your current Vote Points is "+ .vp;
close;
L_ConvertAll:
set .@convert, (.vp / .@convertRate);
set .vp, (.vp % .@convertRate);
getitem .@itemReward, .@convert;
query_sql("UPDATE cp_createlog SET votepoints = "+ .vp +" WHERE account_id = "+ getcharid(3));
mes .@n$;
mes "You have received "+ .@convert +"x "+ getitemname(.@itemReward) +".";
mes "Your current Vote Points is "+ .vp;
close;
L_VotePointsTooLow:
mes .@n$;
mes "Your Vote Points is too low. Come back when you have the minimum amount of Vote Points.";
close;
function getPoints {
set .@account_id, getarg(0);
set .@count, query_sql("SELECT votepoints FROM cp_createlog WHERE account_id = "+ .@account_id, .@votepoints);
return .@count ? .@votepoints : 0;
}
OnBuyItem:
set .@cost,0;
for(set .@i,0; .@i<getarraysize(@bought_nameid); set .@i,.@i+1)
for(set .@j,0; .@j<getarraysize(.itemShop); set .@j,.@j+2)
if (@bought_nameid[.@i] == .itemShop[.@j]) {
set .@cost, .@cost+(.itemShop[.@j+1]*@bought_quantity[.@i]);
break;
}
mes .@n$;
if (.@cost > .vp) mes "You don't have enough Vote Points.";
else {
for(set .@i,0; .@i<getarraysize(@bought_nameid); set .@i,.@i+1) {
getitem @bought_nameid[.@i], @bought_quantity[.@i];
dispbottom "Purchased "+@bought_quantity[.@i]+"x "+getitemname(@bought_nameid[.@i])+".";
}
set .vp, .vp - .@cost;
query_sql("UPDATE cp_createlog SET votepoints = votepoints - "+ .@cost +" WHERE account_id = "+ getcharid(3));
mes .@n$;
mes "Deal completed.";
mes "You now have ^ff0000"+ .vp +"^000000 Vote Points.";
emotion e_cash;
}
set .@cost,0;
deletearray @bought_nameid[0], getarraysize(@bought_nameid);
deletearray @bought_quantity[0], getarraysize(@bought_quantity);
close;
OnInit:
setarray .itemShop[0], 501,2,607,5; // <ITEM_ID>,<PRICE>,...
npcshopdelitem "votepoints_shop",512;
for(set .@i, 0; .@i < getarraysize(.itemShop); set .@i, .@i+2)
npcshopadditem "votepoints_shop", .itemShop[.@i], .itemShop[.@i+1];
end;
}
- shop votepoints_shop -1,512:-1
3)
set currency as "votepoints"and display user current vote points, (since all the items will be purchased by votepoints only)
* in here we would have to remove the current quest_shop box where it shows the requirements and substitute for this one, but keeping the "Equip" item option.
Third Script:
// Leave this alone...
- shop PvPPoint_Shop -1,512:100
prontera,153,150,5 script PvP Shop 623,{
function ShopSettings;
function ValidateCost;
function CurrencyInfo;
function ClearData;
function ValueConvert;
function ErrorNotice;
mes "[PvP Shop]";
//next;
// Menu Selection
select("PvP Shop");
ClearData();
ShopSettings( @menu );
npcshopitem "PvPPoint_Shop",512,100;
npcshopdelitem "PvPPoint_Shop",512;
for(set .@i,0; .@i < getarraysize( @ItemLists ); set .@i,.@i+1)
npcshopadditem "PvPPoint_Shop",@ItemLists[.@i],@ItemCost[.@i];
mes "Okay...wait awhile";
mes "^00FF00____________________________^000000";
CurrencyInfo( @Currency$ );
mes "^00FF00____________________________^000000";
callshop "PvPPoint_Shop",1;
npcshopattach "PvPPoint_Shop";
end;
function ShopSettings {
switch( getarg(0) ){
case 1:
// Currency [ Item ID / Variable Name ]
set @Currency$,"votepoints";
// Item ID Lists // PUT YOUR CUSTOM ITEM ID's
setarray @ItemLists[0],501,502,503,504,505;
// Item Price // PUT YOUR CUSTOM ITEM Price
setarray @ItemCost[0],1,2,3,4,5;
break;
// Case 4,5,6.....etc...
default:
ErrorNotice( "Invalid Menu Selection for Menu "+@menu+"." );
close;
}
if( @Currency$ == "" )
ErrorNotice( "Invalid Currency Setting in Menu "+@menu+" ." );
if( getarraysize( @ItemCost ) != getarraysize( @ItemLists ) || getarraysize( @ItemLists ) != getarraysize( @ItemCost ) )
ErrorNotice( "Missing or Extra Value of Item or Cost Settings in Menu "+@menu+" ." );
return;
}
function ErrorNotice {
mes "^FF0000ERROR^000000 - "+getarg(0);
mes "^00FF00____________________________^000000";
mes "Inform this Message to ^0000FFGame Staffs^000000 immediately !";
close;
}
function CurrencyInfo {
if( getitemname( atoi( getarg(0) ) ) != "null" ){
mes "Item Currency : ^FF0000"+getitemname( atoi( getarg(0) ) )+"^000000";
mes "Available Amount : ^0000FF"+ValueConvert( countitem( atoi( getarg(0) ) ) )+"^000000";
}else if( getitemname( atoi( getarg(0) ) ) == "null" ){
mes "Variable Currency : ^FF0000"+getarg(0)+"^000000";
mes "Available Amount : ^0000FF"+ValueConvert( getd( getarg(0) ) )+"^000000";
}
return;
}
function ValidateCost {
if( getitemname( atoi( getarg(0) ) ) != "null" ){
if( countitem( atoi( getarg(0) ) ) < getarg(1) ) return 1;
}else{
if( getd( getarg(0) ) < getarg(1) ) return 1;
}
return 0;
}
function ClearData {
set @Currency$,"";
set @TotalCost,0;
deletearray @bought_nameid[0],getarraysize( @bought_nameid );
deletearray @bought_quantity[0],getarraysize( @bought_quantity );
deletearray @ItemLists[0],getarraysize( @ItemLists );
deletearray @ItemCost[0],getarraysize( @ItemCost );
return;
}
function ValueConvert {
set .@num, atoi(""+getarg(0));
if ( .@num == 0 || .@num >= 2147483647 ) return getarg(0);
set .@l, getstrlen(""+.@num);
for ( set .@i,0; .@i < .@l; set .@i, .@i + 1 ) {
set .@num$, .@num % pow(10,.@i+1) / pow(10,.@i) + .@num$;
if ( (.@i+1) % 3 == 0 && .@i+1 != .@l ) set .@num$, ","+ .@num$;
}
return .@num$;
}
OnBuyItem:
ShopSettings( @menu );
for(set @i,0; @i < getarraysize( @bought_nameid ); set @i,@i+1)
for(set @j,0; @j < getarraysize( @ItemLists ); set @j,@j+1)
if( @ItemLists[@j] == @bought_nameid[@i] )
set @TotalCost,@TotalCost + ( @ItemCost[@j] * @bought_quantity[@i] );
mes "^FF0000 BILLING LIST^000000";
mes "^00FF00____________________________^000000";
for( set @i,0; @i < getarraysize( @bought_nameid ); set @i,@i+1 )
mes "^FF0000"+@bought_quantity[@i]+" x ^0000FF"+getitemname( @bought_nameid[@i] )+"^000000";
mes "^00FF00____________________________^000000";
if( getitemname( atoi( @Currency$ ) ) != "null" )
mes "Total Cost : ^0000FF"+ValueConvert( @TotalCost )+" x "+getitemname( atoi( @Currency$ ) )+"^000000";
else if( getitemname( atoi( @Currency$ ) ) == "null" ){
mes "Total Cost : ^0000FF"+ValueConvert( @TotalCost )+" "+@Currency$+"^000000";
}
mes "^00FF00____________________________^000000";
if( ValidateCost( @Currency$,@TotalCost ) ){
if( getitemname( atoi( @Currency$ ) ) != "null" )
mes "[ ^FF0000X^000000 ] Insufficient ^0000FF"+getitemname( atoi( @Currency$ ) )+"^000000";
else{
mes "[ ^FF0000X^000000 ] Insufficient ^0000FF"+@Currency$+"^000000";
}
}else{
if( select( "^0000FFPurchase^000000:Cancel" ) == 1 ){
if( getitemname( atoi( @Currency$ ) ) != "null" )
delitem atoi( @Currency$ ),@TotalCost;
else{
set getd( @Currency$ ),getd( @Currency$ ) - @TotalCost;
}
for(set @i,0; @i < getarraysize( @bought_nameid ); set @i,@i+1)
getitem @bought_nameid[@i],@bought_quantity[@i];
message strcharinfo(0),"Purchased "+getarraysize( @bought_nameid )+" Items.";
// announce "["+strcharinfo(0)+"] has purchase a ["+ getitemname(@bought_nameid) +"] from the Event Shop!", 0;
mes "Thank you for shopping.";
}
}
ClearData();
close;
OnInit:
do {
delwaitingroom;
waitingroom "Check Me~!!",0;
sleep 3000; // Evites super infinity loop
} while(1); // End Loop
end;
}
}
Images:

Add the box where it shows the user current Vote Points (add it when choosing the item to purchase).

Sorry if it's confusing. I hope you guys can understand. And if anyone has a better way to do it please post bellow. I've been trying for so many days but my script knowledge is too low.
Thank you in advance!
`id` int(11) NOT NULL AUTO_INCREMENT,
`votename` varchar(25) NOT NULL,
`voteurl` varchar(255) NOT NULL,
`voteinterval` int(11) NOT NULL,
`votepoints` int(11) NOT NULL,
`imgname` varchar(255) DEFAULT NULL,
`imgurl` varchar(255) DEFAULT NULL,
`datetime_created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=4 ;
ALTER TABLE `cp_createlog` ADD `votepoints` int(11) NOT NULL DEFAULT '0';
CREATE TABLE IF NOT EXISTS `cp_vfp_logs` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`sites_id` int(11) NOT NULL,
`timestamp_expire` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
`timestamp_voted` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
`ipaddress` varchar(155) NOT NULL,
`account_id` int(11) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=7 ;
Quest_Shop Script:
//===== Hercules Script ======================================
//= Euphy's Quest Shop
//===== By: ==================================================
//= Euphy
//===== Current Version: =====================================
//= 1.6a
//===== Description: =========================================
//= A dynamic quest shop based on Lunar's, with easier config.
//= Includes support for multiple shops & cashpoints.
//= Item Preview script by ToastOfDoom.
//===== Additional Comments: =================================
//= 1.0 Initial script.
//= 1.2 Added category support.
//= 1.3 More options and fixes.
//= 1.4 Added debug settings.
//= 1.5 Replaced categories with shop IDs.
//= 1.6 Added support for purchasing stackables.
//= 1.6a Added support for previewing costumes and robes.
//============================================================
// Shop NPCs -- supplying no argument displays entire menu.
// callfunc "qshop"{,<shop ID>{,<shop ID>{,...}}};
//============================================================
prontera,150,150,4 script Quests#1 4_M_GENIE,{ callfunc "qshop"; }
// Script Core
//============================================================
- script quest_shop -1,{
function Add; function Chk; function Slot; function A_An;
OnInit:
freeloop(1);
// -----------------------------------------------------------
// Basic shop settings.
// -----------------------------------------------------------
set .Announce,1; // Announce quest completion? (1: yes / 0: no)
set .ShowSlot,1; // Show item slots? (2: all equipment / 1: if slots > 0 / 0: never)
set .ShowID,0; // Show item IDs? (1: yes / 0: no)
set .ShowZeny,0; // Show Zeny cost, if any? (1: yes / 0: no)
set .MaxStack,100; // Max number of quest items purchased at one time.
// -----------------------------------------------------------
// Points variable -- optional quest requirement.
// setarray .Points$[0],"<variable name>","<display name>";
// -----------------------------------------------------------
setarray .Points$[0],"#votepoints","Vote Points";
// -----------------------------------------------------------
// Shop IDs -- to add shops, copy dummy data at bottom of file.
// setarray .Shops$[1],"<Shop 1>","<Shop 2>"{,...};
// -----------------------------------------------------------
setarray .Shops$[1],"Head","Wings1","Wings";
// -----------------------------------------------------------
// Quest items -- do NOT use a reward item more than once!
// Add(<shop ID>,<reward ID>,<reward amount>,
// <Zeny cost>,<point cost>,
// <required item ID>,<required item amount>{,...});
// -----------------------------------------------------------
//Head
Add(1,19015,1,350000000,50,7027,200,7265,200,932,350,7038,400);
Add(1,15004,1,350000000,0,7027,200,7265,200,932,350,7038,400);
Add(1,15001,1,350000000,0,7027,200,7265,200,932,350,7038,400);
//Wings1
Add(2,15021,1,300000000,0,7440,100,602,250,1055,400,7168,450);
Add(2,15031,1,300000000,0,7440,100,602,250,1055,400,7168,450);
//Wings
Add(2,15022,1,400000000,0,1058,250,7168,300,7064,350,1059,520,7511,600);
// -----------------------------------------------------------
freeloop(0);
set .menu$,"";
for(set .@i,1; .@i<=getarraysize(.Shops$); set .@i,.@i+1) {
set .menu$, .menu$+.Shops$[.@i]+":";
npcshopdelitem "qshop"+.@i,909;
}
end;
OnMenu:
set .@size, getarraysize(@i);
if (!.@size) set .@i, select(.menu$);
else if (.@size == 1) set .@i, @i[0];
else {
for(set .@j,0; .@j<.@size; set .@j,.@j+1)
set .@menu$, .@menu$+.Shops$[@i[.@j]]+":";
set .@i, @i[select(.@menu$)-1];
}
deletearray @i[0],getarraysize(@i);
if (.Shops$[.@i] == "") {
message strcharinfo(0),"An error ocurred.";
end;
}
dispbottom "Select one item per time";
callshop "qshop"+.@i,1;
npcshopattach "qshop"+.@i;
end;
OnBuyItem:
// .@q[] : RewardID, BoughtAmt, RewardAmt, BaseAmt, ReqZeny, ReqPts, { ReqItem, ReqAmt, ... }
setarray .@q[0],@bought_nameid[0],((@bought_quantity[0] > .MaxStack)?.MaxStack
copyarray .@q[3],getd(".q_"+.@q[0]+"[0]"),getarraysize(getd(".q_"+.@q[0]));
set .@q[2],.@q[1]*.@q[3];
if (!.@q[2] || .@q[2] > 30000) {
message strcharinfo(0),"You cannot do this many "+getitemname(.@q[0])+".";
end;
}
mes "[Quest Shop]";
mes "Reward: ^0055FF"+((.@q[2] > 1)?.@q[2]+"x ":"")+Slot(.@q[0])+"^000000";
mes "Requirements:";
if (.@q[4]) mes " > "+Chk(Zeny,.@q[4]*.@q[1])+(.@q[4]*.@q[1])+" Zeny^000000";
if (.@q[5]) mes " > "+Chk(getd(.Points$[0]),.@q[5]*.@q[1])+(.@q[5]*.@q[1])+" "+.Points$[1]+" ("+getd(.Points$[0])+"/"+(.@q[5]*.@q[1])+")^000000";
if (.@q[6]) for(set .@i,6; .@i<getarraysize(.@q); set .@i,.@i+2)
mes " > "+Chk(countitem(.@q[.@i]),.@q[.@i+1]*.@q[1])+((.ShowID)?"{"+.@q[.@i]+"} ":"")+Slot(.@q[.@i])+" ("+countitem(.@q[.@i])+"/"+(.@q[.@i+1]*.@q[1])+")^000000";
next;
setarray @qe[1], getiteminfo(.@q[0],5), getiteminfo(.@q[0],11);
if (@qe[2] > 0 && ((@qe[1] & 1) || (@qe[1] & 256) || (@qe[1] & 512) || (@qe[1] & 1024) || (@qe[1] & 2048) || (@qe[1] & 4096) || (@qe[1] & 4) || (@qe[1] & 8192)))
set .@preview,1;
addtimer 1000, strnpcinfo(0)+"::OnEnd";
while(1) {
switch(select(" ~ Do Quest ^0055FF"+getitemname(.@q[0])+"^000000:"+((.@preview && !@qe[7])?" ~ Equip Item...":"")+": ~ ^777777Cancel^000000")) {
case 1:
if (@qe[0]) {
mes "[Quest Shop]";
mes "One or more items are missing.";
close;
}
if (!checkweight(.@q[0],.@q[2])) {
mes "[Quest Shop]";
mes "^FF0000You need "+(((.@q[2]*getiteminfo(.@q[0],6))+Weight-MaxWeight)/10)+" weight capacity to complete this transaction.^000000";
close;
}
if (.@q[4]) Zeny -= (.@q[4]*.@q[1]);
if (.@q[5]) setd .Points$[0], getd(.Points$[0])-(.@q[5]*.@q[1]);
if (.@q[6]) for(set .@i,6; .@i<getarraysize(.@q); set .@i,.@i+2)
delitem .@q[.@i],.@q[.@i+1]*.@q[1];
getitem .@q[0],.@q[2];
if (.Announce) announce strcharinfo(0)+" has completed the quest "+((.@q[2] > 1)?.@q[2]+"x "+getitemname(.@q[0]):A_An(getitemname(.@q[0])))+"!",0;
specialeffect2 EF_FLOWERLEAF;
close;
case 2:
setarray @qe[3], getlook(LOOK_HEAD_BOTTOM), getlook(LOOK_HEAD_TOP), getlook(LOOK_HEAD_MID), getlook(LOOK_ROBE), 1;
if ((@qe[1] & 1) || (@qe[1] & 4096)) changelook LOOK_HEAD_BOTTOM, @qe[2];
else if ((@qe[1] & 256) || (@qe[1] & 1024)) changelook LOOK_HEAD_TOP, @qe[2];
else if ((@qe[1] & 512) || (@qe[1] & 2048)) changelook LOOK_HEAD_MID, @qe[2];
else if ((@qe[1] & 4) || (@qe[1] & 8192)) changelook LOOK_ROBE, @qe[2];
break;
case 3:
close;
}
}
OnEnd:
if (@qe[7]) {
changelook LOOK_HEAD_BOTTOM, @qe[3];
changelook LOOK_HEAD_TOP, @qe[4];
changelook LOOK_HEAD_MID, @qe[5];
changelook LOOK_ROBE, @qe[6];
}
deletearray @qe[0],8;
end;
function Add {
if (getitemname(getarg(1)) == "null") {
debugmes "Quest Reward #"+getarg(1)+" invalid (skipped).";
return;
}
setarray .@j[0],getarg(2),getarg(3),getarg(4);
for(set .@i,5; .@i<getargcount(); set .@i,.@i+2) {
if (getitemname(getarg(.@i)) == "null") {
debugmes "Quest Requirement #"+getarg(.@i)+" invalid (skipped).";
return;
} else
setarray .@j[.@i-2],getarg(.@i),getarg(.@i+1);
}
copyarray getd(".q_"+getarg(1)+"[0]"),.@j[0],getarraysize(.@j);
npcshopadditem "qshop"+getarg(0),getarg(1),((.ShowZeny)?getarg(3):0);
return;
}
function Chk {
if (getarg(0) < getarg(1)) {
set @qe[0],1;
return "^FF0000";
} else
return "^00FF00";
}
function Slot {
set .@s$,getitemname(getarg(0));
switch(.ShowSlot) {
case 1: if (!getitemslots(getarg(0))) return .@s$;
case 2: if (getiteminfo(getarg(0),2) == 4 || getiteminfo(getarg(0),2) == 5) return .@s$+" ["+getitemslots(getarg(0))+"]";
default: return .@s$;
}
}
function A_An {
setarray .@A$[0],"a","e","i","o","u";
set .@B$, "_"+getarg(0);
for(set .@i,0; .@i<5; set .@i,.@i+1)
if (compare(.@B$,"_"+.@A$[.@i])) return "an "+getarg(0);
return "a "+getarg(0);
}
}
function script qshop {
deletearray @i[0],getarraysize(@i);
for(set .@i,0; .@i<getargcount(); set .@i,.@i+1)
set @i[.@i],getarg(.@i);
doevent "quest_shop::OnMenu";
end;
}
// Dummy shop data -- copy as needed.
//============================================================
- shop qshop1 -1,19015:-1,8100:-1,8104:-1
- shop qshop2 -1,15021:-1,15039:-1
- shop qshop3 -1,8226:-1
Code:
//===== Hercules Script ======================================
//= Euphy's Quest Shop
//===== By: ==================================================
//= Euphy
//===== Current Version: =====================================
//= 1.6a
//===== Description: =========================================
//= A dynamic quest shop based on Lunar's, with easier config.
//= Includes support for multiple shops & cashpoints.
//= Item Preview script by ToastOfDoom.
//===== Additional Comments: =================================
//= 1.0 Initial script.
//= 1.2 Added category support.
//= 1.3 More options and fixes.
//= 1.4 Added debug settings.
//= 1.5 Replaced categories with shop IDs.
//= 1.6 Added support for purchasing stackables.
//= 1.6a Added support for previewing costumes and robes.
//============================================================
// Shop NPCs -- supplying no argument displays entire menu.
// callfunc "qshop"{,<shop ID>{,<shop ID>{,...}}};
//============================================================
prontera,150,150,4 script Quests#1 4_M_GENIE,{ callfunc "qshop"; }
// Script Core
//============================================================
- script quest_shop -1,{
function Add; function Chk; function Slot; function A_An;
OnInit:
freeloop(1);
// -----------------------------------------------------------
// Basic shop settings.
// -----------------------------------------------------------
set .Announce,1; // Announce quest completion? (1: yes / 0: no)
set .ShowSlot,1; // Show item slots? (2: all equipment / 1: if slots > 0 / 0: never)
set .ShowID,0; // Show item IDs? (1: yes / 0: no)
set .ShowZeny,0; // Show Zeny cost, if any? (1: yes / 0: no)
set .MaxStack,100; // Max number of quest items purchased at one time.
// -----------------------------------------------------------
// Points variable -- optional quest requirement.
// setarray .Points$[0],"<variable name>","<display name>";
// -----------------------------------------------------------
setarray .Points$[0],"#votepoints","Vote Points";
// -----------------------------------------------------------
// Shop IDs -- to add shops, copy dummy data at bottom of file.
// setarray .Shops$[1],"<Shop 1>","<Shop 2>"{,...};
// -----------------------------------------------------------
setarray .Shops$[1],"Head","Wings1","Wings";
// -----------------------------------------------------------
// Quest items -- do NOT use a reward item more than once!
// Add(<shop ID>,<reward ID>,<reward amount>,
// <Zeny cost>,<point cost>,
// <required item ID>,<required item amount>{,...});
// -----------------------------------------------------------
//Head
Add(1,19015,1,350000000,50,7027,200,7265,200,932,350,7038,400);
Add(1,15004,1,350000000,0,7027,200,7265,200,932,350,7038,400);
Add(1,15001,1,350000000,0,7027,200,7265,200,932,350,7038,400);
//Wings1
Add(2,15021,1,300000000,0,7440,100,602,250,1055,400,7168,450);
Add(2,15031,1,300000000,0,7440,100,602,250,1055,400,7168,450);
//Wings
Add(2,15022,1,400000000,0,1058,250,7168,300,7064,350,1059,520,7511,600);
// -----------------------------------------------------------
freeloop(0);
set .menu$,"";
for(set .@i,1; .@i<=getarraysize(.Shops$); set .@i,.@i+1) {
set .menu$, .menu$+.Shops$[.@i]+":";
npcshopdelitem "qshop"+.@i,909;
}
end;
OnMenu:
set .@size, getarraysize(@i);
if (!.@size) set .@i, select(.menu$);
else if (.@size == 1) set .@i, @i[0];
else {
for(set .@j,0; .@j<.@size; set .@j,.@j+1)
set .@menu$, .@menu$+.Shops$[@i[.@j]]+":";
set .@i, @i[select(.@menu$)-1];
}
deletearray @i[0],getarraysize(@i);
if (.Shops$[.@i] == "") {
message strcharinfo(0),"An error ocurred.";
end;
}
dispbottom "Select one item per time";
callshop "qshop"+.@i,1;
npcshopattach "qshop"+.@i;
end;
OnBuyItem:
// .@q[] : RewardID, BoughtAmt, RewardAmt, BaseAmt, ReqZeny, ReqPts, { ReqItem, ReqAmt, ... }
setarray .@q[0],@bought_nameid[0],((@bought_quantity[0] > .MaxStack)?.MaxStack:@bought_quantity[0]);
copyarray .@q[3],getd(".q_"+.@q[0]+"[0]"),getarraysize(getd(".q_"+.@q[0]));
set .@q[2],.@q[1]*.@q[3];
if (!.@q[2] || .@q[2] > 30000) {
message strcharinfo(0),"You cannot do this many "+getitemname(.@q[0])+".";
end;
}
mes "[Quest Shop]";
mes "Reward: ^0055FF"+((.@q[2] > 1)?.@q[2]+"x ":"")+Slot(.@q[0])+"^000000";
mes "Requirements:";
if (.@q[4]) mes " > "+Chk(Zeny,.@q[4]*.@q[1])+(.@q[4]*.@q[1])+" Zeny^000000";
if (.@q[5]) mes " > "+Chk(getd(.Points$[0]),.@q[5]*.@q[1])+(.@q[5]*.@q[1])+" "+.Points$[1]+" ("+getd(.Points$[0])+"/"+(.@q[5]*.@q[1])+")^000000";
if (.@q[6]) for(set .@i,6; .@i<getarraysize(.@q); set .@i,.@i+2)
mes " > "+Chk(countitem(.@q[.@i]),.@q[.@i+1]*.@q[1])+((.ShowID)?"{"+.@q[.@i]+"} ":"")+Slot(.@q[.@i])+" ("+countitem(.@q[.@i])+"/"+(.@q[.@i+1]*.@q[1])+")^000000";
next;
setarray @qe[1], getiteminfo(.@q[0],5), getiteminfo(.@q[0],11);
if (@qe[2] > 0 && ((@qe[1] & 1) || (@qe[1] & 256) || (@qe[1] & 512) || (@qe[1] & 1024) || (@qe[1] & 2048) || (@qe[1] & 4096) || (@qe[1] & 4) || (@qe[1] & 8192)))
set .@preview,1;
addtimer 1000, strnpcinfo(0)+"::OnEnd";
while(1) {
switch(select(" ~ Do Quest ^0055FF"+getitemname(.@q[0])+"^000000:"+((.@preview && !@qe[7])?" ~ Equip Item...":"")+": ~ ^777777Cancel^000000")) {
case 1:
if (@qe[0]) {
mes "[Quest Shop]";
mes "One or more items are missing.";
close;
}
if (!checkweight(.@q[0],.@q[2])) {
mes "[Quest Shop]";
mes "^FF0000You need "+(((.@q[2]*getiteminfo(.@q[0],6))+Weight-MaxWeight)/10)+" weight capacity to complete this transaction.^000000";
close;
}
if (.@q[4]) Zeny -= (.@q[4]*.@q[1]);
if (.@q[5]) setd .Points$[0], getd(.Points$[0])-(.@q[5]*.@q[1]);
if (.@q[6]) for(set .@i,6; .@i<getarraysize(.@q); set .@i,.@i+2)
delitem .@q[.@i],.@q[.@i+1]*.@q[1];
getitem .@q[0],.@q[2];
if (.Announce) announce strcharinfo(0)+" has completed the quest "+((.@q[2] > 1)?.@q[2]+"x "+getitemname(.@q[0]):A_An(getitemname(.@q[0])))+"!",0;
specialeffect2 EF_FLOWERLEAF;
close;
case 2:
setarray @qe[3], getlook(LOOK_HEAD_BOTTOM), getlook(LOOK_HEAD_TOP), getlook(LOOK_HEAD_MID), getlook(LOOK_ROBE), 1;
if ((@qe[1] & 1) || (@qe[1] & 4096)) changelook LOOK_HEAD_BOTTOM, @qe[2];
else if ((@qe[1] & 256) || (@qe[1] & 1024)) changelook LOOK_HEAD_TOP, @qe[2];
else if ((@qe[1] & 512) || (@qe[1] & 2048)) changelook LOOK_HEAD_MID, @qe[2];
else if ((@qe[1] & 4) || (@qe[1] & 8192)) changelook LOOK_ROBE, @qe[2];
break;
case 3:
close;
}
}
OnEnd:
if (@qe[7]) {
changelook LOOK_HEAD_BOTTOM, @qe[3];
changelook LOOK_HEAD_TOP, @qe[4];
changelook LOOK_HEAD_MID, @qe[5];
changelook LOOK_ROBE, @qe[6];
}
deletearray @qe[0],8;
end;
function Add {
if (getitemname(getarg(1)) == "null") {
debugmes "Quest Reward #"+getarg(1)+" invalid (skipped).";
return;
}
setarray .@j[0],getarg(2),getarg(3),getarg(4);
for(set .@i,5; .@i<getargcount(); set .@i,.@i+2) {
if (getitemname(getarg(.@i)) == "null") {
debugmes "Quest Requirement #"+getarg(.@i)+" invalid (skipped).";
return;
} else
setarray .@j[.@i-2],getarg(.@i),getarg(.@i+1);
}
copyarray getd(".q_"+getarg(1)+"[0]"),.@j[0],getarraysize(.@j);
npcshopadditem "qshop"+getarg(0),getarg(1),((.ShowZeny)?getarg(3):0);
return;
}
function Chk {
if (getarg(0) < getarg(1)) {
set @qe[0],1;
return "^FF0000";
} else
return "^00FF00";
}
function Slot {
set .@s$,getitemname(getarg(0));
switch(.ShowSlot) {
case 1: if (!getitemslots(getarg(0))) return .@s$;
case 2: if (getiteminfo(getarg(0),2) == 4 || getiteminfo(getarg(0),2) == 5) return .@s$+" ["+getitemslots(getarg(0))+"]";
default: return .@s$;
}
}
function A_An {
setarray .@A$[0],"a","e","i","o","u";
set .@B$, "_"+getarg(0);
for(set .@i,0; .@i<5; set .@i,.@i+1)
if (compare(.@B$,"_"+.@A$[.@i])) return "an "+getarg(0);
return "a "+getarg(0);
}
}
function script qshop {
deletearray @i[0],getarraysize(@i);
for(set .@i,0; .@i<getargcount(); set .@i,.@i+1)
set @i[.@i],getarg(.@i);
doevent "quest_shop::OnMenu";
end;
}
// Dummy shop data -- copy as needed.
//============================================================
- shop qshop1 -1,19015:-1,8100:-1,8104:-1
- shop qshop2 -1,15021:-1,15039:-1
- shop qshop3 -1,8226:-1
NPC Vote4Points (only need the SQL commands cause I won't be using this script):
prontera,150,150,4 script VFP Manager 62,{
function getPoints;
set .@n$, "[VFP Manager]";
set .@settings, 1; // 0 = item, 1 = shop
set .@itemReward, 501; // if settings is set to item
set .@convertRate, 2; // 2 Vote Points for 1 Red Potion
set .vp, getPoints(getcharid(3));
switch (.@settings) {
case 0:
mes .@n$;
mes "Would you like to convert your "+ .vp +" Vote Points?";
mes "^ff0000The current convert rate is "+ .@convertRate +" Vote Points for 1 "+ getitemname(.@itemReward) +".";
next;
menu "Yes", L_Convert, "No", -;
mes .@n$;
mes "Bye, then.";
break;
case 1:
mes .@n$;
mes "You have ^ff0000"+ .vp +"^000000 Vote Points.";
mes "Would you like to go shopping?";
next;
menu "Yes", -, "No", L_Goodbye;
mes .@n$;
mes "Have fun shopping!";
callshop "votepoints_shop",1;
npcshopattach "votepoints_shop";
end;
}
L_Goodbye:
mes .@n$;
mes "Goodbye, then.";
close;
L_Convert:
if (.vp < .@convertRate)
goto L_VotePointsTooLow;
mes .@n$;
mes "How much Vote Points would you like to convert?";
next;
menu "All", L_ConvertAll, "Input Amount", L_ConvertAmount;
L_ConvertAmount:
input .@convert;
if (.@convert > .vp)
goto L_VotePointsTooLow;
set .vp, ((.vp - .@convert) + (.@convert % .@convertRate));
set .@convert, (.@convert / .@convertRate);
getitem .@itemReward, .@convert;
query_sql("UPDATE cp_createlog SET votepoints = "+ .vp +" WHERE account_id = "+ getcharid(3));
mes .@n$;
mes "You have received "+ .@convert +"x "+ getitemname(.@itemReward) +".";
mes "Your current Vote Points is "+ .vp;
close;
L_ConvertAll:
set .@convert, (.vp / .@convertRate);
set .vp, (.vp % .@convertRate);
getitem .@itemReward, .@convert;
query_sql("UPDATE cp_createlog SET votepoints = "+ .vp +" WHERE account_id = "+ getcharid(3));
mes .@n$;
mes "You have received "+ .@convert +"x "+ getitemname(.@itemReward) +".";
mes "Your current Vote Points is "+ .vp;
close;
L_VotePointsTooLow:
mes .@n$;
mes "Your Vote Points is too low. Come back when you have the minimum amount of Vote Points.";
close;
function getPoints {
set .@account_id, getarg(0);
set .@count, query_sql("SELECT votepoints FROM cp_createlog WHERE account_id = "+ .@account_id, .@votepoints);
return .@count ? .@votepoints : 0;
}
OnBuyItem:
set .@cost,0;
for(set .@i,0; .@i<getarraysize(@bought_nameid); set .@i,.@i+1)
for(set .@j,0; .@j<getarraysize(.itemShop); set .@j,.@j+2)
if (@bought_nameid[.@i] == .itemShop[.@j]) {
set .@cost, .@cost+(.itemShop[.@j+1]*@bought_quantity[.@i]);
break;
}
mes .@n$;
if (.@cost > .vp) mes "You don't have enough Vote Points.";
else {
for(set .@i,0; .@i<getarraysize(@bought_nameid); set .@i,.@i+1) {
getitem @bought_nameid[.@i], @bought_quantity[.@i];
dispbottom "Purchased "+@bought_quantity[.@i]+"x "+getitemname(@bought_nameid[.@i])+".";
}
set .vp, .vp - .@cost;
query_sql("UPDATE cp_createlog SET votepoints = votepoints - "+ .@cost +" WHERE account_id = "+ getcharid(3));
mes .@n$;
mes "Deal completed.";
mes "You now have ^ff0000"+ .vp +"^000000 Vote Points.";
emotion e_cash;
}
set .@cost,0;
deletearray @bought_nameid[0], getarraysize(@bought_nameid);
deletearray @bought_quantity[0], getarraysize(@bought_quantity);
close;
OnInit:
setarray .itemShop[0], 501,2,607,5; // <ITEM_ID>,<PRICE>,...
npcshopdelitem "votepoints_shop",512;
for(set .@i, 0; .@i < getarraysize(.itemShop); set .@i, .@i+2)
npcshopadditem "votepoints_shop", .itemShop[.@i], .itemShop[.@i+1];
end;
}
- shop votepoints_shop -1,512:-1
Code:
prontera,150,150,4 script VFP Manager 62,{
function getPoints;
set .@n$, "[VFP Manager]";
set .@settings, 1; // 0 = item, 1 = shop
set .@itemReward, 501; // if settings is set to item
set .@convertRate, 2; // 2 Vote Points for 1 Red Potion
set .vp, getPoints(getcharid(3));
switch (.@settings) {
case 0:
mes .@n$;
mes "Would you like to convert your "+ .vp +" Vote Points?";
mes "^ff0000The current convert rate is "+ .@convertRate +" Vote Points for 1 "+ getitemname(.@itemReward) +".";
next;
menu "Yes", L_Convert, "No", -;
mes .@n$;
mes "Bye, then.";
break;
case 1:
mes .@n$;
mes "You have ^ff0000"+ .vp +"^000000 Vote Points.";
mes "Would you like to go shopping?";
next;
menu "Yes", -, "No", L_Goodbye;
mes .@n$;
mes "Have fun shopping!";
callshop "votepoints_shop",1;
npcshopattach "votepoints_shop";
end;
}
L_Goodbye:
mes .@n$;
mes "Goodbye, then.";
close;
L_Convert:
if (.vp < .@convertRate)
goto L_VotePointsTooLow;
mes .@n$;
mes "How much Vote Points would you like to convert?";
next;
menu "All", L_ConvertAll, "Input Amount", L_ConvertAmount;
L_ConvertAmount:
input .@convert;
if (.@convert > .vp)
goto L_VotePointsTooLow;
set .vp, ((.vp - .@convert) + (.@convert % .@convertRate));
set .@convert, (.@convert / .@convertRate);
getitem .@itemReward, .@convert;
query_sql("UPDATE cp_createlog SET votepoints = "+ .vp +" WHERE account_id = "+ getcharid(3));
mes .@n$;
mes "You have received "+ .@convert +"x "+ getitemname(.@itemReward) +".";
mes "Your current Vote Points is "+ .vp;
close;
L_ConvertAll:
set .@convert, (.vp / .@convertRate);
set .vp, (.vp % .@convertRate);
getitem .@itemReward, .@convert;
query_sql("UPDATE cp_createlog SET votepoints = "+ .vp +" WHERE account_id = "+ getcharid(3));
mes .@n$;
mes "You have received "+ .@convert +"x "+ getitemname(.@itemReward) +".";
mes "Your current Vote Points is "+ .vp;
close;
L_VotePointsTooLow:
mes .@n$;
mes "Your Vote Points is too low. Come back when you have the minimum amount of Vote Points.";
close;
function getPoints {
set .@account_id, getarg(0);
set .@count, query_sql("SELECT votepoints FROM cp_createlog WHERE account_id = "+ .@account_id, .@votepoints);
return .@count ? .@votepoints : 0;
}
OnBuyItem:
set .@cost,0;
for(set .@i,0; .@i<getarraysize(@bought_nameid); set .@i,.@i+1)
for(set .@j,0; .@j<getarraysize(.itemShop); set .@j,.@j+2)
if (@bought_nameid[.@i] == .itemShop[.@j]) {
set .@cost, .@cost+(.itemShop[.@j+1]*@bought_quantity[.@i]);
break;
}
mes .@n$;
if (.@cost > .vp) mes "You don't have enough Vote Points.";
else {
for(set .@i,0; .@i<getarraysize(@bought_nameid); set .@i,.@i+1) {
getitem @bought_nameid[.@i], @bought_quantity[.@i];
dispbottom "Purchased "+@bought_quantity[.@i]+"x "+getitemname(@bought_nameid[.@i])+".";
}
set .vp, .vp - .@cost;
query_sql("UPDATE cp_createlog SET votepoints = votepoints - "+ .@cost +" WHERE account_id = "+ getcharid(3));
mes .@n$;
mes "Deal completed.";
mes "You now have ^ff0000"+ .vp +"^000000 Vote Points.";
emotion e_cash;
}
set .@cost,0;
deletearray @bought_nameid[0], getarraysize(@bought_nameid);
deletearray @bought_quantity[0], getarraysize(@bought_quantity);
close;
OnInit:
setarray .itemShop[0], 501,2,607,5; // <ITEM_ID>,<PRICE>,...
npcshopdelitem "votepoints_shop",512;
for(set .@i, 0; .@i < getarraysize(.itemShop); set .@i, .@i+2)
npcshopadditem "votepoints_shop", .itemShop[.@i], .itemShop[.@i+1];
end;
}
- shop votepoints_shop -1,512:-1
set currency as "votepoints"and display user current vote points, (since all the items will be purchased by votepoints only)
* in here we would have to remove the current quest_shop box where it shows the requirements and substitute for this one, but keeping the "Equip" item option.
Third Script:
// Leave this alone...
- shop PvPPoint_Shop -1,512:100
prontera,153,150,5 script PvP Shop 623,{
function ShopSettings;
function ValidateCost;
function CurrencyInfo;
function ClearData;
function ValueConvert;
function ErrorNotice;
mes "[PvP Shop]";
//next;
// Menu Selection
select("PvP Shop");
ClearData();
ShopSettings( @menu );
npcshopitem "PvPPoint_Shop",512,100;
npcshopdelitem "PvPPoint_Shop",512;
for(set .@i,0; .@i < getarraysize( @ItemLists ); set .@i,.@i+1)
npcshopadditem "PvPPoint_Shop",@ItemLists[.@i],@ItemCost[.@i];
mes "Okay...wait awhile";
mes "^00FF00____________________________^000000";
CurrencyInfo( @Currency$ );
mes "^00FF00____________________________^000000";
callshop "PvPPoint_Shop",1;
npcshopattach "PvPPoint_Shop";
end;
function ShopSettings {
switch( getarg(0) ){
case 1:
// Currency [ Item ID / Variable Name ]
set @Currency$,"votepoints";
// Item ID Lists // PUT YOUR CUSTOM ITEM ID's
setarray @ItemLists[0],501,502,503,504,505;
// Item Price // PUT YOUR CUSTOM ITEM Price
setarray @ItemCost[0],1,2,3,4,5;
break;
// Case 4,5,6.....etc...
default:
ErrorNotice( "Invalid Menu Selection for Menu "+@menu+"." );
close;
}
if( @Currency$ == "" )
ErrorNotice( "Invalid Currency Setting in Menu "+@menu+" ." );
if( getarraysize( @ItemCost ) != getarraysize( @ItemLists ) || getarraysize( @ItemLists ) != getarraysize( @ItemCost ) )
ErrorNotice( "Missing or Extra Value of Item or Cost Settings in Menu "+@menu+" ." );
return;
}
function ErrorNotice {
mes "^FF0000ERROR^000000 - "+getarg(0);
mes "^00FF00____________________________^000000";
mes "Inform this Message to ^0000FFGame Staffs^000000 immediately !";
close;
}
function CurrencyInfo {
if( getitemname( atoi( getarg(0) ) ) != "null" ){
mes "Item Currency : ^FF0000"+getitemname( atoi( getarg(0) ) )+"^000000";
mes "Available Amount : ^0000FF"+ValueConvert( countitem( atoi( getarg(0) ) ) )+"^000000";
}else if( getitemname( atoi( getarg(0) ) ) == "null" ){
mes "Variable Currency : ^FF0000"+getarg(0)+"^000000";
mes "Available Amount : ^0000FF"+ValueConvert( getd( getarg(0) ) )+"^000000";
}
return;
}
function ValidateCost {
if( getitemname( atoi( getarg(0) ) ) != "null" ){
if( countitem( atoi( getarg(0) ) ) < getarg(1) ) return 1;
}else{
if( getd( getarg(0) ) < getarg(1) ) return 1;
}
return 0;
}
function ClearData {
set @Currency$,"";
set @TotalCost,0;
deletearray @bought_nameid[0],getarraysize( @bought_nameid );
deletearray @bought_quantity[0],getarraysize( @bought_quantity );
deletearray @ItemLists[0],getarraysize( @ItemLists );
deletearray @ItemCost[0],getarraysize( @ItemCost );
return;
}
function ValueConvert {
set .@num, atoi(""+getarg(0));
if ( .@num == 0 || .@num >= 2147483647 ) return getarg(0);
set .@l, getstrlen(""+.@num);
for ( set .@i,0; .@i < .@l; set .@i, .@i + 1 ) {
set .@num$, .@num % pow(10,.@i+1) / pow(10,.@i) + .@num$;
if ( (.@i+1) % 3 == 0 && .@i+1 != .@l ) set .@num$, ","+ .@num$;
}
return .@num$;
}
OnBuyItem:
ShopSettings( @menu );
for(set @i,0; @i < getarraysize( @bought_nameid ); set @i,@i+1)
for(set @j,0; @j < getarraysize( @ItemLists ); set @j,@j+1)
if( @ItemLists[@j] == @bought_nameid[@i] )
set @TotalCost,@TotalCost + ( @ItemCost[@j] * @bought_quantity[@i] );
mes "^FF0000 BILLING LIST^000000";
mes "^00FF00____________________________^000000";
for( set @i,0; @i < getarraysize( @bought_nameid ); set @i,@i+1 )
mes "^FF0000"+@bought_quantity[@i]+" x ^0000FF"+getitemname( @bought_nameid[@i] )+"^000000";
mes "^00FF00____________________________^000000";
if( getitemname( atoi( @Currency$ ) ) != "null" )
mes "Total Cost : ^0000FF"+ValueConvert( @TotalCost )+" x "+getitemname( atoi( @Currency$ ) )+"^000000";
else if( getitemname( atoi( @Currency$ ) ) == "null" ){
mes "Total Cost : ^0000FF"+ValueConvert( @TotalCost )+" "+@Currency$+"^000000";
}
mes "^00FF00____________________________^000000";
if( ValidateCost( @Currency$,@TotalCost ) ){
if( getitemname( atoi( @Currency$ ) ) != "null" )
mes "[ ^FF0000X^000000 ] Insufficient ^0000FF"+getitemname( atoi( @Currency$ ) )+"^000000";
else{
mes "[ ^FF0000X^000000 ] Insufficient ^0000FF"+@Currency$+"^000000";
}
}else{
if( select( "^0000FFPurchase^000000:Cancel" ) == 1 ){
if( getitemname( atoi( @Currency$ ) ) != "null" )
delitem atoi( @Currency$ ),@TotalCost;
else{
set getd( @Currency$ ),getd( @Currency$ ) - @TotalCost;
}
for(set @i,0; @i < getarraysize( @bought_nameid ); set @i,@i+1)
getitem @bought_nameid[@i],@bought_quantity[@i];
message strcharinfo(0),"Purchased "+getarraysize( @bought_nameid )+" Items.";
// announce "["+strcharinfo(0)+"] has purchase a ["+ getitemname(@bought_nameid) +"] from the Event Shop!", 0;
mes "Thank you for shopping.";
}
}
ClearData();
close;
OnInit:
do {
delwaitingroom;
waitingroom "Check Me~!!",0;
sleep 3000; // Evites super infinity loop
} while(1); // End Loop
end;
}
}
Code:
// Leave this alone...
- shop PvPPoint_Shop -1,512:100
prontera,153,150,5 script PvP Shop 623,{
function ShopSettings;
function ValidateCost;
function CurrencyInfo;
function ClearData;
function ValueConvert;
function ErrorNotice;
mes "[PvP Shop]";
//next;
// Menu Selection
select("PvP Shop");
ClearData();
ShopSettings( @menu );
npcshopitem "PvPPoint_Shop",512,100;
npcshopdelitem "PvPPoint_Shop",512;
for(set .@i,0; .@i < getarraysize( @ItemLists ); set .@i,.@i+1)
npcshopadditem "PvPPoint_Shop",@ItemLists[.@i],@ItemCost[.@i];
mes "Okay...wait awhile";
mes "^00FF00____________________________^000000";
CurrencyInfo( @Currency$ );
mes "^00FF00____________________________^000000";
callshop "PvPPoint_Shop",1;
npcshopattach "PvPPoint_Shop";
end;
function ShopSettings {
switch( getarg(0) ){
case 1:
// Currency [ Item ID / Variable Name ]
set @Currency$,"votepoints";
// Item ID Lists // PUT YOUR CUSTOM ITEM ID's
setarray @ItemLists[0],501,502,503,504,505;
// Item Price // PUT YOUR CUSTOM ITEM Price
setarray @ItemCost[0],1,2,3,4,5;
break;
// Case 4,5,6.....etc...
default:
ErrorNotice( "Invalid Menu Selection for Menu "+@menu+"." );
close;
}
if( @Currency$ == "" )
ErrorNotice( "Invalid Currency Setting in Menu "+@menu+" ." );
if( getarraysize( @ItemCost ) != getarraysize( @ItemLists ) || getarraysize( @ItemLists ) != getarraysize( @ItemCost ) )
ErrorNotice( "Missing or Extra Value of Item or Cost Settings in Menu "+@menu+" ." );
return;
}
function ErrorNotice {
mes "^FF0000ERROR^000000 - "+getarg(0);
mes "^00FF00____________________________^000000";
mes "Inform this Message to ^0000FFGame Staffs^000000 immediately !";
close;
}
function CurrencyInfo {
if( getitemname( atoi( getarg(0) ) ) != "null" ){
mes "Item Currency : ^FF0000"+getitemname( atoi( getarg(0) ) )+"^000000";
mes "Available Amount : ^0000FF"+ValueConvert( countitem( atoi( getarg(0) ) ) )+"^000000";
}else if( getitemname( atoi( getarg(0) ) ) == "null" ){
mes "Variable Currency : ^FF0000"+getarg(0)+"^000000";
mes "Available Amount : ^0000FF"+ValueConvert( getd( getarg(0) ) )+"^000000";
}
return;
}
function ValidateCost {
if( getitemname( atoi( getarg(0) ) ) != "null" ){
if( countitem( atoi( getarg(0) ) ) < getarg(1) ) return 1;
}else{
if( getd( getarg(0) ) < getarg(1) ) return 1;
}
return 0;
}
function ClearData {
set @Currency$,"";
set @TotalCost,0;
deletearray @bought_nameid[0],getarraysize( @bought_nameid );
deletearray @bought_quantity[0],getarraysize( @bought_quantity );
deletearray @ItemLists[0],getarraysize( @ItemLists );
deletearray @ItemCost[0],getarraysize( @ItemCost );
return;
}
function ValueConvert {
set .@num, atoi(""+getarg(0));
if ( .@num == 0 || .@num >= 2147483647 ) return getarg(0);
set .@l, getstrlen(""+.@num);
for ( set .@i,0; .@i < .@l; set .@i, .@i + 1 ) {
set .@num$, .@num % pow(10,.@i+1) / pow(10,.@i) + .@num$;
if ( (.@i+1) % 3 == 0 && .@i+1 != .@l ) set .@num$, ","+ .@num$;
}
return .@num$;
}
OnBuyItem:
ShopSettings( @menu );
for(set @i,0; @i < getarraysize( @bought_nameid ); set @i,@i+1)
for(set @j,0; @j < getarraysize( @ItemLists ); set @j,@j+1)
if( @ItemLists[@j] == @bought_nameid[@i] )
set @TotalCost,@TotalCost + ( @ItemCost[@j] * @bought_quantity[@i] );
mes "^FF0000 BILLING LIST^000000";
mes "^00FF00____________________________^000000";
for( set @i,0; @i < getarraysize( @bought_nameid ); set @i,@i+1 )
mes "^FF0000"+@bought_quantity[@i]+" x ^0000FF"+getitemname( @bought_nameid[@i] )+"^000000";
mes "^00FF00____________________________^000000";
if( getitemname( atoi( @Currency$ ) ) != "null" )
mes "Total Cost : ^0000FF"+ValueConvert( @TotalCost )+" x "+getitemname( atoi( @Currency$ ) )+"^000000";
else if( getitemname( atoi( @Currency$ ) ) == "null" ){
mes "Total Cost : ^0000FF"+ValueConvert( @TotalCost )+" "+@Currency$+"^000000";
}
mes "^00FF00____________________________^000000";
if( ValidateCost( @Currency$,@TotalCost ) ){
if( getitemname( atoi( @Currency$ ) ) != "null" )
mes "[ ^FF0000X^000000 ] Insufficient ^0000FF"+getitemname( atoi( @Currency$ ) )+"^000000";
else{
mes "[ ^FF0000X^000000 ] Insufficient ^0000FF"+@Currency$+"^000000";
}
}else{
if( select( "^0000FFPurchase^000000:Cancel" ) == 1 ){
if( getitemname( atoi( @Currency$ ) ) != "null" )
delitem atoi( @Currency$ ),@TotalCost;
else{
set getd( @Currency$ ),getd( @Currency$ ) - @TotalCost;
}
for(set @i,0; @i < getarraysize( @bought_nameid ); set @i,@i+1)
getitem @bought_nameid[@i],@bought_quantity[@i];
message strcharinfo(0),"Purchased "+getarraysize( @bought_nameid )+" Items.";
// announce "["+strcharinfo(0)+"] has purchase a ["+ getitemname(@bought_nameid) +"] from the Event Shop!", 0;
mes "Thank you for shopping.";
}
}
ClearData();
close;
OnInit:
do {
delwaitingroom;
waitingroom "Check Me~!!",0;
sleep 3000; // Evites super infinity loop
} while(1); // End Loop
end;
}
}

Add the box where it shows the user current Vote Points (add it when choosing the item to purchase).

Sorry if it's confusing. I hope you guys can understand. And if anyone has a better way to do it please post bellow. I've been trying for so many days but my script knowledge is too low.
Thank you in advance!
Last edited by a moderator: