Jump to content
  • 0

Problem with donation NPC


Question

Posted

Hello rAthena Board,

I scripted a donate npc and it works but it does not check if the player got the donation item and the amount , here is my script pls help:

prontera,160,183,4 script Donation Reward 872,{
set .@donatename$,"^0000FF[ Donation Reward ]^000000";
set .donateid,26770;
setarray @ItemID[0],19438,19649,19650,19651;
setarray @Cost[0],125,50,45,30;
setarray @item_count[0],1,1,1,1; // Item Count wich will be given
mes .@donatename$;
mes "Hello ^0000FF["+strcharinfo(0)+"]^000000,do";
mes "you want to buy donate";
mes "items?";
next;
if (select("Yes,sure","Cancel") == 2)
close;
next;
mes "[^ff0000List^000000]";
mes "^0000ffItem^000000 = ^00aa00Cost^000000";
for( set .@i, 0; .@i < getarraysize(@ItemID); set .@i, .@i + 1 ) {
mes "^0000ff"+@item_count[.@i]+"x "+getitemname(@ItemID[.@i])+"^000000 = ^00aa00"+@Cost[.@i]+"^000000";
if( .@i < 1 )
set .@menu$, getitemname(@ItemID[.@i]);
else
set .@menu$, .@menu$+":"+getitemname(@ItemID[.@i]);
}

next;
select(.@menu$);
set @choice, @menu - 1;

mes @npcname$;
if( @Cost[@choice] > .donateid ) {
mes "^ff0000You dont have enough Donation Coins for "+@item_count[@choice]+"x '"+getitemname(@ItemID[@choice])+"' :/^000000";
close;
}
mes "Are u realy sure to trade "+@item_count[@choice]+"x '^ff0000"+getitemname(@ItemID[@choice])+"^000000' for ^00aa00"+@Cost[@choice]+"^000000 Donate Coins?";
if(select("No! Cancel!:Yes, Trade me!") == 1 ) {
mes "^ff0000Trade was canceled~^000000";
close;
}

set .@new, .donateid - @Cost[@choice];
if( .@new < 0 ) // safty first..
set .@new, 0;
delitem .donateid,@Cost[@choice];
getitem @ItemID[@choice], @item_count[@choice];
mes "^00aa00Trade was Successfull Hope to see u again =)!^000000";
close;
}[/codeBOX]

2 answers to this question

Recommended Posts

Posted

Aww,sry for the problems I fixed it by myself I had it like this in the script first :

if( @Cost[@choice] > .donateid ) {

and changed it to this:

if(countitem(.donateid) <@Cost[@choice]) {

change this topic to solved pls.

thx

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.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...