Jump to content
  • 0

npc request


Byakuran

Question


  • Group:  Members
  • Topic Count:  110
  • Topics Per Day:  0.02
  • Content Count:  229
  • Reputation:   5
  • Joined:  12/16/11
  • Last Seen:  

can someone make this npc announce when someone buy ... but i want it to announce this

"Player name" has purchase a "item name" from donation npc

heres my npc

//================ DONATION Trader===================
turbo_room,99,120,6 script    Donation Shop 403,{
mes .name$;
mes "You currently have "+countitem(.tcg_item)+" TCG.";
mes "Would you like to look at the shop?";
next;
if(select("Yes:No") == 2) {close;}
close2;
callshop "Donation_SHOP",1;
npcshopattach "Donation_SHOP";
dispbottom "You currently have "+countitem(.Donation_item)+" TCG.";
end;

OnBuyItem:
for(set @i,0; @i < getarraysize(@bought_nameid); set @i,@i+1) {
for(set @j,0; @j < getarraysize(.TCG_ITEMS); set @j,@j+1) {
if(.TCG_ITEMS[@j] == @bought_nameid[@i]) {
set @itemcost,(.ITEMPRICE[@j]*@bought_quantity[@i]);
set @totalcost,(@totalcost+@itemcost);
break;
}
}
}

if(@totalcost > countitem(.tcg_item)) {
dispbottom "You don't have enough TCG.";
} else {
for(set @i,0; @i < getarraysize(@bought_nameid); set @i,@i+1) {
getitem @bought_nameid[@i],@bought_quantity[@i];
}
delitem .tcg_item,@totalcost;
dispbottom "Thank you for shopping.";
}
set @totalcost,0;
deletearray @bought_nameid[0],128;
deletearray @bought_quantity[0],128;
end;

OnInit:
npcshopdelitem "Donation_SHOP",909; // Leave this alone
set .name$,"[Donation Trader]";
set .tcg_item,7179; // Input TCG ID
setarray .TCG_ITEMS[0],5467,2720,2721,2722,2723,2724,2725,5374,5518,2629,20001,1228,13017,2630,4441,2554,5325;
setarray .ITEMPRICE[0],10,7,7,7,7,7,7,10,10,8,6,5,6,4,10,6,4; // Item prices - Should followe ID's order

for(set .@item,0; .@item < getarraysize(.TCG_ITEMS); set .@item,.@item+1) {
npcshopadditem "Donation_SHOP",.TCG_ITEMS[.@item],.ITEMPRICE[.@item];
}
end;
}

- shop Donation_SHOP -1,909:5

Link to comment
Share on other sites

4 answers to this question

Recommended Posts


  • Group:  Members
  • Topic Count:  8
  • Topics Per Day:  0.00
  • Content Count:  117
  • Reputation:   8
  • Joined:  05/07/12
  • Last Seen:  

goto this line:

for(set @i,0; @i < getarraysize(@bought_nameid); set @i,@i+1) {
getitem @bought_nameid[@i],@bought_quantity[@i];

add below:

announce "["+strcharinfo(0)+"] has purchase a ["+ getitemname(@bought_nameid) +"] from the Donation NPC!", 0;

should look like this:

for(set @i,0; @i < getarraysize(@bought_nameid); set @i,@i+1) {
getitem @bought_nameid[@i],@bought_quantity[@i];
announce "["+strcharinfo(0)+"] has purchase a ["+ getitemname(@bought_nameid) +"] from the Donation NPC!", 0;
}

Link to comment
Share on other sites


  • Group:  Forum Moderator
  • Topic Count:  93
  • Topics Per Day:  0.02
  • Content Count:  10015
  • Reputation:   2348
  • Joined:  10/28/11
  • Last Seen:  

change


for(set @i,0; @i < getarraysize(@bought_nameid); set @i,@i+1) {
getitem @bought_nameid[@i],@bought_quantity[@i];
}

into this


for(set @i,0; @i < getarraysize(@bought_nameid); set @i,@i+1) {
getitem @bought_nameid[@i],@bought_quantity[@i];
announce "[ "+strcharinfo(0)+" ] has brought "+@bought_quantity[@i]+" x "+getitemname( @bought_nameid[@i] ),0;
}

Aw....slower than Docubo ~

Edited by Emistry
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  17
  • Topics Per Day:  0.00
  • Content Count:  382
  • Reputation:   38
  • Joined:  01/17/12
  • Last Seen:  

This should work. please test it first because I haven't tested it myself:

//================ DONATION Trader===================
turbo_room,99,120,6<tab>script<tab>Donation Shop<tab>403,{
mes .name$;
mes "You currently have "+countitem(.tcg_item)+" TCG.";
mes "Would you like to look at the shop?";
next;
if (select("Yes:No") == 2) close;
close2;
callshop "Donation_SHOP",1;
npcshopattach "Donation_SHOP";
dispbottom "You currently have "+countitem(.Donation_item)+" TCG.";
end;

OnBuyItem:
	for(set @i,0; @i < getarraysize(@bought_nameid); set @i,@i+1) {
		for(set @j,0; @j < getarraysize(.TCG_ITEMS); set @j,@j+1) {
			if(.TCG_ITEMS[@j] == @bought_nameid[@i]) {
				set @itemcost,(.ITEMPRICE[@j]*@bought_quantity[@i]);
				set @totalcost,(@totalcost+@itemcost);
				break;
			}
		}
	}

if(@totalcost > countitem(.tcg_item)) {
	dispbottom "You don't have enough TCG.";
} else {
	for(set @i,0; @i < getarraysize(@bought_nameid); set @i,@i+1) {
		getitem @bought_nameid[@i],@bought_quantity[@i];
		announce strcharinfo(0) + " has purchase a " + getitemname(@bought_nameid[@i]) + " from the donation NPC";
	}
	delitem .tcg_item,@totalcost;
	dispbottom "Thank you for shopping.";
}
set @totalcost,0;
deletearray @bought_nameid[0],128;
deletearray @bought_quantity[0],128;
end;

OnInit:
	npcshopdelitem "Donation_SHOP",909; // Leave this alone
	set .name$,"[Donation Trader]";
	set .tcg_item,7179; // Input TCG ID
	setarray .TCG_ITEMS[0],5467,2720,2721,2722,2723,2724,2725,5374,5518,2629,20001,1228,13017,2630,4441,2554,5325;
	setarray .ITEMPRICE[0],10,7,7,7,7,7,7,10,10,8,6,5,6,4,10,6,4; // Item prices - Should followe ID's order

	for(set .@item,0; .@item < getarraysize(.TCG_ITEMS); set .@item,.@item+1) {
		npcshopadditem "Donation_SHOP",.TCG_ITEMS[.@item],.ITEMPRICE[.@item];
	}
	end;
}

- shop Donation_SHOP -1,909:5

EDIT:

xD too late

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  110
  • Topics Per Day:  0.02
  • Content Count:  229
  • Reputation:   5
  • Joined:  12/16/11
  • Last Seen:  

tnks :D need to try it :D

Link to comment
Share on other sites

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.

×
×
  • Create New...