Check weight request

* Blaze *

New member
Messages
110
Points
0
Emulator
 
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;


 
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;

 
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.

 
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 76
3tG5cGJ.png


 
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 76
3tG5cGJ.png
it seems like you're not using hercules 
default_sleep.png


 
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 76
3tG5cGJ.png
it seems like you're not using hercules 
default_sleep.png
Hello im using rAmod sorry old revision

Fixed thanks

 
Back
Top