• 0
Sign in to follow this  
Yoh Asakura

Help with Vote4Points NPC

Question

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:  

 
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 [email protected],1; [email protected]<=getarraysize(.Shops$); set [email protected],[email protected]+1) { set .menu$, .menu$+.Shops$[[email protected]]+":"; npcshopdelitem "qshop"[email protected],909; } end; OnMenu: set [email protected], getarraysize(@i); if ([email protected]) set [email protected], select(.menu$); else if ([email protected] == 1) set [email protected], @i[0]; else { for(set [email protected],0; [email protected]<[email protected]; set [email protected],[email protected]+1) set [email protected]$, [email protected]$+.Shops$[@i[[email protected]]]+":"; set [email protected], @i[select([email protected]$)-1]; } deletearray @i[0],getarraysize(@i); if (.Shops$[[email protected]] == "") { message strcharinfo(0),"An error ocurred."; end; } dispbottom "Select one item per time"; callshop "qshop"[email protected],1; npcshopattach "qshop"[email protected]; end; OnBuyItem: // [email protected][] : RewardID, BoughtAmt, RewardAmt, BaseAmt, ReqZeny, ReqPts, { ReqItem, ReqAmt, ... } setarray [email protected][0],@bought_nameid[0],((@bought_quantity[0] > .MaxStack)?.MaxStack:@bought_quantity[0]); copyarray [email protected][3],getd(".q_"[email protected][0]+"[0]"),getarraysize(getd(".q_"[email protected][0])); set [email protected][2],[email protected][1]*[email protected][3]; if ([email protected][2] || [email protected][2] > 30000) { message strcharinfo(0),"You cannot do this many "+getitemname([email protected][0])+"."; end; } mes "[Quest Shop]"; mes "Reward: ^0055FF"+(([email protected][2] > 1)[email protected][2]+"x ":"")+Slot([email protected][0])+"^000000"; mes "Requirements:"; if ([email protected][4]) mes " > "+Chk(Zeny,[email protected][4]*[email protected][1])+([email protected][4]*[email protected][1])+" Zeny^000000"; if ([email protected][5]) mes " > "+Chk(getd(.Points$[0]),[email protected][5]*[email protected][1])+([email protected][5]*[email protected][1])+" "+.Points$[1]+" ("+getd(.Points$[0])+"/"+([email protected][5]*[email protected][1])+")^000000"; if ([email protected][6]) for(set [email protected],6; [email protected]<getarraysize([email protected]); set [email protected],[email protected]+2) mes " > "+Chk(countitem([email protected][[email protected]]),[email protected][[email protected]+1]*[email protected][1])+((.ShowID)?"{"[email protected][[email protected]]+"} ":"")+Slot([email protected][[email protected]])+" ("+countitem([email protected][[email protected]])+"/"+([email protected][[email protected]+1]*[email protected][1])+")^000000"; next; setarray @qe[1], getiteminfo([email protected][0],5), getiteminfo([email protected][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 [email protected],1; addtimer 1000, strnpcinfo(0)+"::OnEnd"; while(1) { switch(select(" ~ Do Quest ^0055FF"+getitemname([email protected][0])+"^000000:"+(([email protected] && [email protected][7])?" ~ Equip Item...":"")+": ~ ^777777Cancel^000000")) { case 1: if (@qe[0]) { mes "[Quest Shop]"; mes "One or more items are missing."; close; } if (!checkweight([email protected][0],[email protected][2])) { mes "[Quest Shop]"; mes "^FF0000You need "+((([email protected][2]*getiteminfo([email protected][0],6))+Weight-MaxWeight)/10)+" weight capacity to complete this transaction.^000000"; close; } if ([email protected][4]) Zeny -= ([email protected][4]*[email protected][1]); if ([email protected][5]) setd .Points$[0], getd(.Points$[0])-([email protected][5]*[email protected][1]); if ([email protected][6]) for(set [email protected],6; [email protected]<getarraysize([email protected]); set [email protected],[email protected]+2) delitem [email protected][[email protected]],[email protected][[email protected]+1]*[email protected][1]; getitem [email protected][0],[email protected][2]; if (.Announce) announce strcharinfo(0)+" has completed the quest "+(([email protected][2] > 1)[email protected][2]+"x "+getitemname([email protected][0]):A_An(getitemname([email protected][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 [email protected][0],getarg(2),getarg(3),getarg(4); for(set [email protected],5; [email protected]<getargcount(); set [email protected],[email protected]+2) { if (getitemname(getarg([email protected])) == "null") { debugmes "Quest Requirement #"+getarg([email protected])+" invalid (skipped)."; return; } else setarray [email protected][[email protected]],getarg([email protected]),getarg([email protected]+1); } copyarray getd(".q_"+getarg(1)+"[0]"),[email protected][0],getarraysize([email protected]); 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 [email protected]$,getitemname(getarg(0)); switch(.ShowSlot) { case 1: if (!getitemslots(getarg(0))) return [email protected]$; case 2: if (getiteminfo(getarg(0),2) == 4 || getiteminfo(getarg(0),2) == 5) return [email protected]$+" ["+getitemslots(getarg(0))+"]"; default: return [email protected]$; } } function A_An { setarray [email protected]$[0],"a","e","i","o","u"; set [email protected]$, "_"+getarg(0); for(set [email protected],0; [email protected]<5; set [email protected],[email protected]+1) if (compare([email protected]$,"_"[email protected]$[[email protected]])) return "an "+getarg(0); return "a "+getarg(0); } } function script qshop { deletearray @i[0],getarraysize(@i); for(set [email protected],0; [email protected]<getargcount(); set [email protected],[email protected]+1) set @i[[email protected]],getarg([email protected]); 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
//===== 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 [email protected],1; [email protected]<=getarraysize(.Shops$); set [email protected],[email protected]+1) {
		set .menu$, .menu$+.Shops$[[email protected]]+":";
		npcshopdelitem "qshop"[email protected],909;
	}
	end;

OnMenu:
	set [email protected], getarraysize(@i);
	if ([email protected]) set [email protected], select(.menu$);
	else if ([email protected] == 1) set [email protected], @i[0];
	else {
		for(set [email protected],0; [email protected]<[email protected]; set [email protected],[email protected]+1)
			set [email protected]$, [email protected]$+.Shops$[@i[[email protected]]]+":";
		set [email protected], @i[select([email protected]$)-1];
	}
	deletearray @i[0],getarraysize(@i);
	if (.Shops$[[email protected]] == "") {
		message strcharinfo(0),"An error ocurred.";
		end;
	}
	dispbottom "Select one item per time";
	callshop "qshop"[email protected],1;
	npcshopattach "qshop"[email protected];
	end;

OnBuyItem:
	// [email protected][] : RewardID, BoughtAmt, RewardAmt, BaseAmt, ReqZeny, ReqPts, { ReqItem, ReqAmt, ... }
	setarray [email protected][0],@bought_nameid[0],((@bought_quantity[0] > .MaxStack)?.MaxStack:@bought_quantity[0]);
	copyarray [email protected][3],getd(".q_"[email protected][0]+"[0]"),getarraysize(getd(".q_"[email protected][0]));
	set [email protected][2],[email protected][1]*[email protected][3];
	if ([email protected][2] || [email protected][2] > 30000) {
		message strcharinfo(0),"You cannot do this many "+getitemname([email protected][0])+".";
		end;
	}
	mes "[Quest Shop]";
	mes "Reward: ^0055FF"+(([email protected][2] > 1)[email protected][2]+"x ":"")+Slot([email protected][0])+"^000000";
	mes "Requirements:";
	if ([email protected][4]) mes " > "+Chk(Zeny,[email protected][4]*[email protected][1])+([email protected][4]*[email protected][1])+" Zeny^000000";
	if ([email protected][5]) mes " > "+Chk(getd(.Points$[0]),[email protected][5]*[email protected][1])+([email protected][5]*[email protected][1])+" "+.Points$[1]+" ("+getd(.Points$[0])+"/"+([email protected][5]*[email protected][1])+")^000000";
	if ([email protected][6]) for(set [email protected],6; [email protected]<getarraysize([email protected]); set [email protected],[email protected]+2)
		mes " > "+Chk(countitem([email protected][[email protected]]),[email protected][[email protected]+1]*[email protected][1])+((.ShowID)?"{"[email protected][[email protected]]+"} ":"")+Slot([email protected][[email protected]])+" ("+countitem([email protected][[email protected]])+"/"+([email protected][[email protected]+1]*[email protected][1])+")^000000";
	next;
	setarray @qe[1], getiteminfo([email protected][0],5), getiteminfo([email protected][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 [email protected],1;
	addtimer 1000, strnpcinfo(0)+"::OnEnd";
	while(1) {
		switch(select(" ~ Do Quest ^0055FF"+getitemname([email protected][0])+"^000000:"+(([email protected] && [email protected][7])?" ~ Equip Item...":"")+": ~ ^777777Cancel^000000")) {
		case 1:
			if (@qe[0]) {
				mes "[Quest Shop]";
				mes "One or more items are missing.";
				close;
			}
			if (!checkweight([email protected][0],[email protected][2])) {
				mes "[Quest Shop]";
				mes "^FF0000You need "+((([email protected][2]*getiteminfo([email protected][0],6))+Weight-MaxWeight)/10)+" weight capacity to complete this transaction.^000000";
				close;
			}
			if ([email protected][4]) Zeny -= ([email protected][4]*[email protected][1]);
			if ([email protected][5]) setd .Points$[0], getd(.Points$[0])-([email protected][5]*[email protected][1]);
			if ([email protected][6]) for(set [email protected],6; [email protected]<getarraysize([email protected]); set [email protected],[email protected]+2)
				delitem [email protected][[email protected]],[email protected][[email protected]+1]*[email protected][1];
			getitem [email protected][0],[email protected][2];
			if (.Announce) announce strcharinfo(0)+" has completed the quest "+(([email protected][2] > 1)[email protected][2]+"x "+getitemname([email protected][0]):A_An(getitemname([email protected][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 [email protected][0],getarg(2),getarg(3),getarg(4);
	for(set [email protected],5; [email protected]<getargcount(); set [email protected],[email protected]+2) {
		if (getitemname(getarg([email protected])) == "null") {
			debugmes "Quest Requirement #"+getarg([email protected])+" invalid (skipped).";
			return;
		} else
			setarray [email protected][[email protected]],getarg([email protected]),getarg([email protected]+1);
	}
	copyarray getd(".q_"+getarg(1)+"[0]"),[email protected][0],getarraysize([email protected]);
	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 [email protected]$,getitemname(getarg(0));
	switch(.ShowSlot) {
		case 1: if (!getitemslots(getarg(0))) return [email protected]$;
		case 2: if (getiteminfo(getarg(0),2) == 4 || getiteminfo(getarg(0),2) == 5) return [email protected]$+" ["+getitemslots(getarg(0))+"]";
		default: return [email protected]$;
	}
}

function A_An {
	setarray [email protected]$[0],"a","e","i","o","u";
	set [email protected]$, "_"+getarg(0);
	for(set [email protected],0; [email protected]<5; set [email protected],[email protected]+1)
		if (compare([email protected]$,"_"[email protected]$[[email protected]])) return "an "+getarg(0);
	return "a "+getarg(0);
}
}

function	script	qshop	{
	deletearray @i[0],getarraysize(@i);
	for(set [email protected],0; [email protected]<getargcount(); set [email protected],[email protected]+1)
		set @i[[email protected]],getarg([email protected]);
	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 [email protected]$, "[VFP Manager]"; set [email protected], 1; // 0 = item, 1 = shop set [email protected], 501; // if settings is set to item set [email protected], 2; // 2 Vote Points for 1 Red Potion set .vp, getPoints(getcharid(3)); switch ([email protected]) { case 0: mes [email protected]$; mes "Would you like to convert your "+ .vp +" Vote Points?"; mes "^ff0000The current convert rate is "+ [email protected] +" Vote Points for 1 "+ getitemname([email protected]) +"."; next; menu "Yes", L_Convert, "No", -; mes [email protected]$; mes "Bye, then."; break; case 1: mes [email protected]$; mes "You have ^ff0000"+ .vp +"^000000 Vote Points."; mes "Would you like to go shopping?"; next; menu "Yes", -, "No", L_Goodbye; mes [email protected]$; mes "Have fun shopping!"; callshop "votepoints_shop",1; npcshopattach "votepoints_shop"; end; } L_Goodbye: mes [email protected]$; mes "Goodbye, then."; close; L_Convert: if (.vp < [email protected]) goto L_VotePointsTooLow; mes [email protected]$; mes "How much Vote Points would you like to convert?"; next; menu "All", L_ConvertAll, "Input Amount", L_ConvertAmount; L_ConvertAmount: input [email protected]; if ([email protected] > .vp) goto L_VotePointsTooLow; set .vp, ((.vp - [email protected]) + ([email protected] % [email protected])); set [email protected], ([email protected] / [email protected]); getitem [email protected], [email protected]; query_sql("UPDATE cp_createlog SET votepoints = "+ .vp +" WHERE account_id = "+ getcharid(3)); mes [email protected]$; mes "You have received "+ [email protected] +"x "+ getitemname([email protected]) +"."; mes "Your current Vote Points is "+ .vp; close; L_ConvertAll: set [email protected], (.vp / [email protected]); set .vp, (.vp % [email protected]); getitem [email protected], [email protected]; query_sql("UPDATE cp_createlog SET votepoints = "+ .vp +" WHERE account_id = "+ getcharid(3)); mes [email protected]$; mes "You have received "+ [email protected] +"x "+ getitemname([email protected]) +"."; mes "Your current Vote Points is "+ .vp; close; L_VotePointsTooLow: mes [email protected]$; mes "Your Vote Points is too low. Come back when you have the minimum amount of Vote Points."; close; function getPoints { set [email protected]_id, getarg(0); set [email protected], query_sql("SELECT votepoints FROM cp_createlog WHERE account_id = "+ [email protected]_id, [email protected]); return [email protected] ? [email protected] : 0; } OnBuyItem: set [email protected],0; for(set [email protected],0; [email protected]<getarraysize(@bought_nameid); set [email protected],[email protected]+1) for(set [email protected],0; [email protected]<getarraysize(.itemShop); set [email protected],[email protected]+2) if (@bought_nameid[[email protected]] == .itemShop[[email protected]]) { set [email protected], [email protected]+(.itemShop[[email protected]+1]*@bought_quantity[[email protected]]); break; } mes [email protected]$; if ([email protected] > .vp) mes "You don't have enough Vote Points."; else { for(set [email protected],0; [email protected]<getarraysize(@bought_nameid); set [email protected],[email protected]+1) { getitem @bought_nameid[[email protected]], @bought_quantity[[email protected]]; dispbottom "Purchased "[email protected]_quantity[[email protected]]+"x "+getitemname(@bought_nameid[[email protected]])+"."; } set .vp, .vp - [email protected]; query_sql("UPDATE cp_createlog SET votepoints = votepoints - "+ [email protected] +" WHERE account_id = "+ getcharid(3)); mes [email protected]$; mes "Deal completed."; mes "You now have ^ff0000"+ .vp +"^000000 Vote Points."; emotion e_cash; } set [email protected],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 [email protected], 0; [email protected] < getarraysize(.itemShop); set [email protected], [email protected]+2) npcshopadditem "votepoints_shop", .itemShop[[email protected]], .itemShop[[email protected]+1]; end; } - shop votepoints_shop -1,512:-1
prontera,150,150,4	script	VFP Manager	62,{
	function getPoints;

	set [email protected]$, 			"[VFP Manager]";
	set [email protected], 	1;		// 0 = item, 1 = shop
	set [email protected], 	501;	// if settings is set to item
	set [email protected], 	2;		// 2 Vote Points for 1 Red Potion
	set .vp, 			getPoints(getcharid(3));
	
	switch ([email protected]) {
		case 0:
			mes [email protected]$;
			mes "Would you like to convert your "+ .vp +" Vote Points?";
			mes "^ff0000The current convert rate is "+ [email protected] +" Vote Points for 1 "+ getitemname([email protected]) +".";
			next;
			menu "Yes", L_Convert, "No", -;
			mes [email protected]$;
			mes "Bye, then.";
			break;
		case 1:
			mes [email protected]$;
			mes "You have ^ff0000"+ .vp +"^000000 Vote Points.";
			mes "Would you like to go shopping?";
			next;
			menu "Yes", -, "No", L_Goodbye;
			mes [email protected]$;
			mes "Have fun shopping!";
			callshop "votepoints_shop",1;
			npcshopattach "votepoints_shop";
			end;
	}
	
	L_Goodbye:
		mes [email protected]$;
		mes "Goodbye, then.";
		close;
	
	L_Convert:
		if (.vp < [email protected])
			goto L_VotePointsTooLow;
		mes [email protected]$;
		mes "How much Vote Points would you like to convert?";
		next;
		menu "All", L_ConvertAll, "Input Amount", L_ConvertAmount;
	
	L_ConvertAmount:
		input [email protected];
		
		if ([email protected] > .vp)
			goto L_VotePointsTooLow;
		
		set .vp, ((.vp - [email protected]) + ([email protected] % [email protected]));
		set [email protected], ([email protected] / [email protected]);
		getitem [email protected], [email protected];
		query_sql("UPDATE cp_createlog SET votepoints = "+ .vp +" WHERE account_id = "+ getcharid(3));
		
		mes [email protected]$;
		mes "You have received "+ [email protected] +"x "+ getitemname([email protected]) +".";
		mes "Your current Vote Points is "+ .vp;
		close;
		
	L_ConvertAll:
		set [email protected], (.vp / [email protected]);
		set .vp, (.vp % [email protected]);
		getitem [email protected], [email protected];
		query_sql("UPDATE cp_createlog SET votepoints = "+ .vp +" WHERE account_id = "+ getcharid(3));
		
		mes [email protected]$;
		mes "You have received "+ [email protected] +"x "+ getitemname([email protected]) +".";
		mes "Your current Vote Points is "+ .vp;
		close;
	
	L_VotePointsTooLow:
		mes [email protected]$;
		mes "Your Vote Points is too low. Come back when you have the minimum amount of Vote Points.";
		close;
	
	function getPoints {
		set [email protected]_id, getarg(0);
		
		set [email protected], query_sql("SELECT votepoints FROM cp_createlog WHERE account_id = "+ [email protected]_id, [email protected]);
		
		return [email protected] ? [email protected] : 0;
	}
	
	OnBuyItem:
		set [email protected],0;
		for(set [email protected],0; [email protected]<getarraysize(@bought_nameid); set [email protected],[email protected]+1)
			for(set [email protected],0; [email protected]<getarraysize(.itemShop); set [email protected],[email protected]+2)
				if (@bought_nameid[[email protected]] == .itemShop[[email protected]]) {
					set [email protected], [email protected]+(.itemShop[[email protected]+1]*@bought_quantity[[email protected]]);
					break;
				}
		mes [email protected]$;
		if ([email protected] > .vp) mes "You don't have enough Vote Points.";
		else {
			for(set [email protected],0; [email protected]<getarraysize(@bought_nameid); set [email protected],[email protected]+1) {
				getitem @bought_nameid[[email protected]], @bought_quantity[[email protected]];
				dispbottom "Purchased "[email protected]_quantity[[email protected]]+"x "+getitemname(@bought_nameid[[email protected]])+".";
			}
			set .vp, .vp - [email protected];
			query_sql("UPDATE cp_createlog SET votepoints = votepoints - "+ [email protected] +" WHERE account_id = "+ getcharid(3));
			mes [email protected]$;
			mes "Deal completed.";
			mes "You now have ^ff0000"+ .vp +"^000000 Vote Points.";
			emotion e_cash;
		}
		set [email protected],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 [email protected], 0; [email protected] < getarraysize(.itemShop); set [email protected], [email protected]+2)
			npcshopadditem "votepoints_shop", .itemShop[[email protected]], .itemShop[[email protected]+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 [email protected],0; [email protected] < getarraysize( @ItemLists ); set [email protected],[email protected]+1) npcshopadditem "PvPPoint_Shop",@ItemLists[[email protected]],@ItemCost[[email protected]]; 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 "[email protected]+"." ); close; } if( @Currency$ == "" ) ErrorNotice( "Invalid Currency Setting in Menu "[email protected]+" ." ); if( getarraysize( @ItemCost ) != getarraysize( @ItemLists ) || getarraysize( @ItemLists ) != getarraysize( @ItemCost ) ) ErrorNotice( "Missing or Extra Value of Item or Cost Settings in Menu "[email protected]+" ." ); 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 [email protected], atoi(""+getarg(0)); if ( [email protected] == 0 || [email protected] >= 2147483647 ) return getarg(0); set [email protected], getstrlen(""[email protected]); for ( set [email protected],0; [email protected] < [email protected]; set [email protected], [email protected] + 1 ) { set [email protected]$, [email protected] % pow(10,[email protected]+1) / pow(10,[email protected]) + [email protected]$; if ( ([email protected]+1) % 3 == 0 && [email protected]+1 != [email protected] ) set [email protected]$, ","+ [email protected]$; } return [email protected]$; } 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"[email protected]_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 )+" "[email protected]$+"^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"[email protected]$+"^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; } }
// 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 [email protected],0; [email protected] < getarraysize( @ItemLists ); set [email protected],[email protected]+1)
	npcshopadditem "PvPPoint_Shop",@ItemLists[[email protected]],@ItemCost[[email protected]];
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 "[email protected]+"." );
			close;
	}

if( @Currency$ == "" )
	ErrorNotice( "Invalid Currency Setting in Menu "[email protected]+" ." );
if( getarraysize( @ItemCost ) != getarraysize( @ItemLists ) || getarraysize( @ItemLists ) != getarraysize( @ItemCost ) )
	ErrorNotice( "Missing or Extra Value of Item or Cost Settings in Menu "[email protected]+" ." );
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 [email protected], atoi(""+getarg(0));
	if ( [email protected] == 0 || [email protected] >= 2147483647 ) return getarg(0);
	set [email protected], getstrlen(""[email protected]);
	for ( set [email protected],0; [email protected] < [email protected]; set [email protected], [email protected] + 1 ) {
		set [email protected]$, [email protected] % pow(10,[email protected]+1) / pow(10,[email protected]) + [email protected]$;
			if ( ([email protected]+1) % 3 == 0 && [email protected]+1 != [email protected] ) set [email protected]$, ","+ [email protected]$;
	}
	return [email protected]$;
}

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"[email protected]_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 )+" "[email protected]$+"^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"[email protected]$+"^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: 

 

tab2.jpg.f3c20daaa16dda892ad8300fd6de3865.jpg

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

1667454503_tabmessage.jpg.f85d64fde737e15b95af0a283d4dddbb.jpg

 

 

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!

Edited by Yoh Asakura

Share this post


Link to post
Share on other sites

1 answer to this question

Recommended Posts

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this