Item Exchange

nyxfatalis

New member
Messages
64
Points
0
Hi hercules,

Can Someone make me 

An NPC That will change ( with menu )

100 TCG to 10 PODS

100 TCG to 20 Convex Mirror

100 TCG to 15 Jellopy.

NPC message will be :

Hi there, i can trade your 100 TCG's to 10 PODS or 20 Convex Mirror or 15 Jellopy.

Pick what you want.

menu : 10 PODS , 20 Convex Mirror , 15 Jellopy.

THANKS IN ADVANCE. ^^~!

 
Code:
prontera,150,150,0	script	Exchanger	100,{	mes .npc$;	mes "Hi there, i can trade your 100 TCG's to 10 PODS or 20 Convex Mirror or 15 Jellopy.";	next;		switch(select(.choice$)) {		case 1:			if ( countitem(7227) < 100 ) end;			delitem 7227,100;			getitem 7179,10;			break;		case 2:			if ( countitem(7227) < 100 ) end;			delitem 7227,100;			getitem 12214,20;			break;		case 3:			 if ( countitem(7227) < 100 ) end;			delitem 7227,100;			getitem 909,15;			break;		default: break;	}		OnInit:		.npc$ = "[ " +strnpcinfo(1)+ " ]";		.choice$ = "10 PODS:20 Convex Mirror:15 Jellopy";		end;}
 
prontera,150,150,0 script Exchanger 100,{ mes .npc$; mes "Hi there, i can trade your 100 TCG's to 10 PODS or 20 Convex Mirror or 15 Jellopy."; next; switch(select(.choice$)) { case 1: if ( countitem(7227) < 100 ) end; delitem 7227,100; getitem 7179,10; break; case 2: if ( countitem(7227) < 100 ) end; delitem 7227,100; getitem 12214,20; break; case 3:  if ( countitem(7227) < 100 ) end; delitem 7227,100; getitem 909,15; break; default: break; } OnInit: .npc$ = "[ " +strnpcinfo(1)+ " ]"; .choice$ = "10 PODS:20 Convex Mirror:15 Jellopy"; end;}
Err...this line will cause the player to freeze if the expression is false:

if ( countitem(7227) < 100 ) end;

Additionally, the check can be placed before the switch; since it's checked every time anyways, it would be pointless to repeat the check.

Here's my method:

Code:
prontera,150,150,5    script    Exchanger    100,{        // Dialogue I    mes .name$;    mes "Hi there, I can exchange "+ .voucher_amt +" of your "+ getitemname(.voucher_id) +" for several different rewards.";    next;        // Choose item to exchange    menu .option$, -;        // Dialogue II    mes .name$;            // Check required voucher amount    if (countitem(.voucher_id) < .voucher_amt)    {        mes "Sorry, but you do not have enough "+ getitemname(.voucher_id) +" to complete this transaction.";        close;    }        // Delete required item    delitem .voucher_id, .voucher_amt;        // Get reward    .@i = @menu - 1;    getitem .item_id[.@i], .amount[.@i];        // Dialogue III    mes "Thank you! Enjoy your "+ .amount[.@i] +" "+ getitemname(.item_id[.@i]) +"!";    close;   	 OnInit:        // NPC name	    .name$ = "["+ strnpcinfo(1) +"]";                // Voucher ID and amount        .voucher_id = 7227;        .voucher_amt = 100;                // Item IDs and corresponding amounts        setarray .item_id[0],    7179,    12214,    909;        setarray .amount[0],      10,       20,     15;                // Fill secondary menu items        for (.@i = 1; .@i < getarraysize(.item_id); .@i++)            .option$ = .option$ +":"+ .amount[.@i] +" "+ getitemname(.item_id[.@i]);                // Add menu items to primary option	    .option$ = .amount[0] +" "+ getitemname(.item_id[0]) + .option$;            end;}
 
Last edited by a moderator:
Back
Top