Jump to content
  • 0

How to add Checkweight in my script ?


eJay

Question


  • Group:  Members
  • Topic Count:  80
  • Topics Per Day:  0.02
  • Content Count:  325
  • Reputation:   76
  • Joined:  03/22/12
  • Last Seen:  

Hello Please Help me. where i can put checkweight because when player's exchanger from coupon to berry. the berry will drop because player cannot hold 500 berry or overweight here's my script.

prontera,163,185,4	script	Converter	83,{
set @name$,"[^FF0000Converter^000000]";
mes @name$;
mes "Hello, 1 Coupon is equals to 500 Berry.";
mes "What would you like to do?";
next;
switch(select("Coupon to Berry:Berry to Coupon"))
{
case 1:
mes @name$;
mes "How many Berry(s) do you want?";
mes "1 Coupon is equal 500 pcs Yggdrasil Berry's";
input .@num;
next;
if(countitem(7037) < .@num)
{
mes @name$;
mes "Sorry, you don't have enough Coupon!";
close;
}
mes @name$;
mes "This will cost ^FF0000"+.@num*1+" Coupon^000000.";
next;
if(select("Proceed:Nevermind")!=1){mes @name$; mes "Goodbye!"; close;}
getitem 607,.@num*500;
delitem 7037,.@num;
break;
case 2:
mes @name$;
mes "How many Coupon(s) will you give?";
input .@num;
next;
if(countitem(607) < .@num)
{
mes @name$;
mes "Sorry, you don't have enough Berry!";
close;
}
mes @name$;
mes "I can give you ^FF0000"+.@num*1+" Coupon^000000 for this.";
next;
if(select("Proceed:Nevermind")!=1){mes @name$; mes "Goodbye!"; close;}
getitem 7037,.@num;
delitem 607,.@num*500;
}
close;
}

Edited by Emistry
use [CODEBOX] for long contents.
  • Upvote 1
Link to comment
Share on other sites

7 answers to this question

Recommended Posts

  • 1

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

change all the getitem / delitem part to this....

if( checkweight( 7037,.@num ) ){
getitem 7037,.@num;
delitem 607,.@num*500;
}else{
mes "You are Overweight";
}

*checkweight(<item id>,<amount>)
*checkweight("<item name>",<amount>)

This function will compute and return 1 if the total weight of a specified
number of specific items does not exceed the invoking character's carrying
capacity, and 0 otherwise. It is important to see if a player can carry the
items you expect to give them, failing to do that may open your script up to
abuse or create some very unfair errors.

This function, in addition to checking to see if the player is capable of
holding a set amount of items, also ensures the player has room in their
inventory for the item(s) they will be receiving.

Like 'getitem', this function will also accept an 'english name' from the
database as an argument.

  • Upvote 1
Link to comment
Share on other sites


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

checkweight(<item id>,<amount>)

checkweight("<item name>",<amount>)

Reference: http://rathena.org/wiki/Checkweight

prontera.gat,163,185,4 script Cenverter 83,{
set @name$,"[^FF0000Converter^000000]";
mes @name$;
mes "What do you want to do?";
next;
switch(select("Information","Convert")) {
	case 1:
		mes @name$;
		mes "I can convert your Coupon/s into Berry and vice versa.";
		mes "1 Coupon = 500 Berry";
		close;
	case 2:
		switch(select("Coupon to Berry","Berry to Coupon")) {
			case 1:
				if (checkweight(607,500) == 0 ) goto overWeight;
				if (countitem(7073) < 1) goto noCoupon;
 mes @name$;
 mes "How many coupon to berries?";
 input .@num;
 if (countitem(7073 < .@num){
  mes @name$;
  mes "Insufficient coupon!";
  close;
 }else
 {
				delitem 7037,.@num;
				getitem 607,.@num*500;
				mes @name$;
				mes "There you go. Hope to see you again!";
				close;
 }
			case 2:
				if (checkweight(7073,1) == 0 ) goto overWeight;
				if (countitem(500) < 1) goto noBerry;
				mes @name$
				mes "How many berries to coupon?";
				input .@num2;
				if (countitem(607) < .@num2){
				mes @name$;
				mes "Insufficient berries!";
				close;
			   }else
				{
				delitem 607,.@num2*500;
				getitem 7037,.@num;
				mes @name$;
				mes "There you go. Hope to see you again!";
				close;
 }
		}
		end;
}
noBerry:
mes @name$;
mes "I'm Sorry but you don't have enough berries.";
close;

noCoupon:
mes @name$;
mes "I'm Sorry you don't have enough coupon";
close;
overWeight:
mes @name$;
mes "Sorry you're overweight.";
close;
}

Edited by Emistry
Please use [CODEBOX] for long contents
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  80
  • Topics Per Day:  0.02
  • Content Count:  325
  • Reputation:   76
  • Joined:  03/22/12
  • Last Seen:  

@Rcharles and Emistry Fixed my Script for checking overweight :) but when i use Berry to coupon

npc said: How many Berries will you give?

then when i put 1000

Npc will give a same 1000 Coupons? how to fix. Help

sorry for my bad english xD

up.

Solved :)

Edited by Luffy
  • Upvote 1
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  81
  • Topics Per Day:  0.02
  • Content Count:  1654
  • Reputation:   583
  • Joined:  08/09/12
  • Last Seen:  

Use a proper tabbing.

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  80
  • Topics Per Day:  0.02
  • Content Count:  325
  • Reputation:   76
  • Joined:  03/22/12
  • Last Seen:  

lol i did

This is working

//====================== rAthena Script ===============================================================
//=== Made by Jae
//=== Recoded by: Ejay
//==================== Information ====================================================================
//==== Berry to Coupon ~ Coupon to Berry
//================= Version : =========================================================================
//=== Topic Link: http://rathena.org/board/topic/70148-how-to-add-checkweight-in-my-script/
//=== V 1.1   Fixed a weight checker [ eJay ]
//============== Credits : ============================================================================
//=== Credits to Emistry
//=== rAthena Profile Link : http://rathena.org/board/user/3300-ejay/
//=====================================================================================================
//*************************************************************************
poring_w02,83,101,5	script	Berry Exchanger	719,{
set @name$,"[^FF0000Berry Exchanger^000000]";
mes @name$;
mes "What do you want to do?";
next;
switch(select("Information","Convert")) {
	case 1:
		mes @name$;
		mes "I can convert your Coupon/s into Berry and vice versa.";
		mes "1 Coupon = 400 Yggdrasil Berry";
		close;
	case 2:
		switch(select("Coupon to Berry","Berry to Coupon")) {
			case 1:
				if (countitem(7037) < 1) goto noCoupon;
				if (checkweight(607,400) == 0 ) goto overWeight;
				delitem 7037,1;
				getitem 607,400;
				mes @name$;
				mes "There you go. Hope to see you again!";
				close;
			case 2:
				if (checkweight(7037,1) == 0 ) goto overWeight;
				if (countitem(607) < 400) goto noBerry;
				delitem 607,400;
				getitem 7037,1;
				mes @name$;
				mes "There you go. Hope to see you again!";
				close;
}
		}
		end;
noBerry:
mes @name$;
mes "I'm Sorry but you don't have enough berries.";
close;

noCoupon:
mes @name$;
mes "I'm Sorry you don't have enough coupon";
close;
overWeight:
mes @name$;
mes "Sorry you're overweight.";
close;
}

Edited by Emistry
Please use [CODEBOX] or Attachments for long contents.
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...