Jump to content
  • 0
Sign in to follow this  
* Blaze *

Check weight request

Question

 
Any idea how add checkweight here thanks 
 

 

setarray .@CoinID[0],607;
 
for( set .@i,0; .@i < getarraysize( .@CoinID ); set .@i,.@i + 1 )
    set .@Menu$,.@Menu$ + getitemname( .@CoinID[.@i] )+":";
set .@i,( select( .@Menu$ ) - 1 );
if( #KAFRAPOINTS < 2 ){
    mes "Sorry but you didnt have 2 Reward Points.";
}else{
    mes "How many ^339FFFArrow Quiver^000000";
    mes "you want to purchase?";
    mes "Amount : 1 ~ "+( #KAFRAPOINTS / 2 );
    input .@Amount,0,( #KAFRAPOINTS / 2 );
    if( .@Amount ){
        set #KAFRAPOINTS,#KAFRAPOINTS - ( .@Amount * 2 );
        getitem .@CoinID[.@i],.@Amount;
        mes "Done";
    }
}
close;

 

 

Share this post


Link to post
Share on other sites

5 answers to this question

Recommended Posts

  • 0

 

 

 

setarray .@CoinID[0], 607;
 
for (.@i = 0; .@i < getarraysize(.@CoinID); ++.@i)
    .@Menu$ += getitemname( .@CoinID[.@i] )+":";
.@i = select(.@Menu$) - 1;
if (#KAFRAPOINTS < 2) {
    mes "Sorry but you didnt have 2 Reward Points.";
} else {
    mes "How many ^339FFFArrow Quiver^000000";
    mes "you want to purchase?";
    mes "Amount : 1 ~ " + (#KAFRAPOINTS / 2);
    input .@Amount, 0, (#KAFRAPOINTS / 2);
    if (.@Amount) {
		if (!checkweight(Knife, 1) || MaxWeight - Weight < 1000) {
			mes "- You're over weight or you dont have enough space in your inventory -";
			close;
		}
        #KAFRAPOINTS -= .@Amount * 2;
        getitem .@CoinID[.@i], .@Amount;
        mes "Done";
    }
}
close;

 

hello i got error line 763tG5cGJ.png

it seems like you're not using hercules  -_-

 

Hello im using rAmod sorry old revision

Fixed thanks

Share this post


Link to post
Share on other sites
  • 0


setarray .@CoinID[0], 607;

 

for (.@i = 0; .@i < getarraysize(.@CoinID); ++.@i)

.@Menu$ += getitemname( .@CoinID[.@i] )+":";

.@i = select(.@Menu$) - 1;

if (#KAFRAPOINTS < 2) {

mes "Sorry but you didnt have 2 Reward Points.";

} else {

mes "How many ^339FFFArrow Quiver^000000";

mes "you want to purchase?";

mes "Amount : 1 ~ " + (#KAFRAPOINTS / 2);

input .@Amount, 0, (#KAFRAPOINTS / 2);

if (.@Amount) {

if (!checkweight(Knife, 1) || MaxWeight - Weight < 1000) {

mes "- You're over weight or you dont have enough space in your inventory -";

close;

}

#KAFRAPOINTS -= .@Amount * 2;

getitem .@CoinID[.@i], .@Amount;

mes "Done";

}

}

close;

Share this post


Link to post
Share on other sites
  • 0

Just after the if( .@Amount ){ check, you can add a new check to verify weight:

 

	if (.@Amount) {
		if (checkweight(.@CoinID[.@i], .@Amount)) {
			#KAFRAPOINTS = #KAFRAPOINTS - ( .@Amount * 2 );
			getitem .@CoinID[.@i], .@Amount;
			mes "Done";
		} else {
			mes "You have no space on inventory.";
		}
	}

 

Also, you need to avoid usage of set command, Set script command is deprecated and it may be remove in any future. Instead, set values directly in this way:

 

.@i = 1;

.@i = select(.@string$);

.@i = .@a + .@b;

 

Or, as in previous example: #KAFRAPOINTS = #KAFRAPOINTS - ( .@Amount * 2 );

 

It's easier and more clean.

 

Also, I recommend you to put a space after a comma, since it is standard in Hercules and also makes the script more clean and more readable.

Share this post


Link to post
Share on other sites
  • 0

 

setarray .@CoinID[0], 607;
 
for (.@i = 0; .@i < getarraysize(.@CoinID); ++.@i)
    .@Menu$ += getitemname( .@CoinID[.@i] )+":";
.@i = select(.@Menu$) - 1;
if (#KAFRAPOINTS < 2) {
    mes "Sorry but you didnt have 2 Reward Points.";
} else {
    mes "How many ^339FFFArrow Quiver^000000";
    mes "you want to purchase?";
    mes "Amount : 1 ~ " + (#KAFRAPOINTS / 2);
    input .@Amount, 0, (#KAFRAPOINTS / 2);
    if (.@Amount) {
		if (!checkweight(Knife, 1) || MaxWeight - Weight < 1000) {
			mes "- You're over weight or you dont have enough space in your inventory -";
			close;
		}
        #KAFRAPOINTS -= .@Amount * 2;
        getitem .@CoinID[.@i], .@Amount;
        mes "Done";
    }
}
close;

 

hello i got error line 763tG5cGJ.png

Share this post


Link to post
Share on other sites
  • 0

 

 

setarray .@CoinID[0], 607;
 
for (.@i = 0; .@i < getarraysize(.@CoinID); ++.@i)
    .@Menu$ += getitemname( .@CoinID[.@i] )+":";
.@i = select(.@Menu$) - 1;
if (#KAFRAPOINTS < 2) {
    mes "Sorry but you didnt have 2 Reward Points.";
} else {
    mes "How many ^339FFFArrow Quiver^000000";
    mes "you want to purchase?";
    mes "Amount : 1 ~ " + (#KAFRAPOINTS / 2);
    input .@Amount, 0, (#KAFRAPOINTS / 2);
    if (.@Amount) {
		if (!checkweight(Knife, 1) || MaxWeight - Weight < 1000) {
			mes "- You're over weight or you dont have enough space in your inventory -";
			close;
		}
        #KAFRAPOINTS -= .@Amount * 2;
        getitem .@CoinID[.@i], .@Amount;
        mes "Done";
    }
}
close;

 

hello i got error line 763tG5cGJ.png

it seems like you're not using hercules  -_-

Share this post


Link to post
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.   Restore formatting

  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  

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.