Jump to content
  • 0
Sign in to follow this  
Slowpoker

Help in script about weight

Question

Hello everyone, i'm with a doubt how can i get to put a npc to bar(impede to continue) a player in the script if he weighs more than 121. 

 

 

I try to create like this egs but i didn't have any advance:

 

if(Weight > 121)  {

mes "You are heavy, please remove your extra weight.";

close;

}

 

 

 

 

Anyone could help me ???

 

 

 

 

 

Share this post


Link to post
Share on other sites

11 answers to this question

Recommended Posts

  • 0

*facepalms*

 

After going over my syntax, I realised that I had misunderstood the usage of checkweight() and was trying to make this check a lot more complicated than it needed to be. checkweight() determines if the items specified would cause you to be overweight or not; I mistakenly presumed it would calculate the weight. The correct method to retrieve the weight of an item would be getiteminfo(<item ID>, 6).

 

The proper check would be this:

if (Weight > 121)

 

I didn't want to repeat chunks of code, so I used arrays to shorthand it. Give this a try; I've tested it thoroughly:

prontera,150,150,5    script    Sample#via::sample_npc    998,{    // Loop through items    for (.@i = 0; .@i < getarraysize(.item_id); .@i++)    {        // Check if player has the exact amount of these items and zeny        if (countitem(.item_id[.@i]) < .amount[.@i] || Zeny < .cost)        {            // Error message            mes "[ Divine ]";            mes "I'm sorry, but you don't have the items and zeny required to proceed.";            close;        }    }        // Loop through items    for (.@i = 0; .@i < getarraysize(.item_id); .@i++)    {        // Determine accumulative weight        .@total_weight = .@total_weight + (getiteminfo(.item_id[.@i], 6) * .amount[.@i]);    }        // Check if the player's weight exceeds the items checked for    if (Weight > .@total_weight)    {            mes "[ Divine ]";        mes "Sorry, but you're too heavy to proceed.";        close;    }        // Confirmation dialogue    mes "[ Divine ]";    mes "Ok, alright! You can go in here now!";    next;        // Loop through items    for (.@i = 0; .@i < getarraysize(.item_id); .@i++)    {        // Delete items        delitem .item_id[.@i], .amount[.@i];    }        // Delete Zeny    Zeny -= .cost;        // Warp player    warp "prontera", 154, 285;    close;        OnInit:        // Configuration        setarray .item_id[0],    628,    969,    7019;        setarray .amount[0],     20,      1,       1;        .cost = 50000;        end;        }

Share this post


Link to post
Share on other sites
  • 0

it think its something like this

 

if(MaxWeight - Weight < 3500) {mes "You are heavy, please remove your extra weight.";close;}

Share this post


Link to post
Share on other sites
  • 0

 

The proper method would be to use readparam().

 

Usage:

 

if (readparam(Weight) > 121){    mes "Sorry, but you're too heavy to proceed.";    close;}

 

i didn't get to run it here. What i wanna do is a thing like it :

 

if((countitem(628) == 20) && (countitem(969) == 1) && (countitem(7019) == 1) && (Zeny == 50000)) {
set Zeny, Zeny - 50000;
delitem 628,20;
delitem 969,1;
delitem 7019,1;
next;
mes "[ Divine ]";
mes "Ok, alright! You can go in here now!";
next;
warp "prontera",154,285;
close; 
}
if (readparam(Weight) > 121{

 mes "Sorry, but you're too heavy to proceed.";

 close;

    }

 
My problem is that always that i put one item more besides 1(969),1(7019) and 20(624), the script works like if there isn't the rest it. So, the weight gets above 121 and the message ( mes "Sorry, but you're too heavy to proceed."; )  don't show and the items are deleted from char.
 
the sum of the weight of the items(1(969),1(7019) and 20(624))  is 121.
Edited by Slowpoker

Share this post


Link to post
Share on other sites
  • 0

I'm still a little confused as to what you're trying to do, but from what I understand, you want to see if the player has the exact amounts of the items specified; the weight check is to determine if the player is carrying anything other than the items in the amounts specified. If that's the case, then your process needs to be reorganised a little.

 

Give this a try; read the comments to see how the script progresses:

 

// ...next;// Check if player has the exact amount of these items and zenyif(countitem(628) == 20 && countitem(969) == 1 && countitem(7019) == 1 && Zeny == 50000){    // Check if the player's weight exceeds the items checked for    if (checkweight(628, 20, 969, 1, 7019, 1))    {        mes "[ Divine ]";        mes "Sorry, but you're too heavy to proceed.";        close;    }        // Delete items and deduct zeny    delitem 628, 20;    delitem 969, 1;    delitem 7019, 1;    Zeny -= 50000;        // Confirmation dialogue    mes "[ Divine ]";    mes "Ok, alright! You can go in here now!";    next;        // Warp player    warp "prontera",154,285;    close;}// Error messagemes "[ Divine ]";mes "I'm sorry, but you don't have the items required to proceed.";close;

Share this post


Link to post
Share on other sites
  • 0

yes, yes is it that i'd like to do, this is my idea from what i wanna do. I saw your scrit and tryed to use it but the same error keeps on. When i have the items [ 1(969),1(7019) and 20(624) ] in my inventory the scrit works but when i create more a item in my inventory the scrit fails.

 

egs : I have my items1(969),1(7019) and 20(624) ] in my inventory and then i create a yggdrasill berry(id:607 -> weight: 30), when i going to use again the npc, it works like if this yggdrasil berry don't exist, the npc deletes my items and deduct the money and the yggdrasil keep on in my inventory but the other things disappear. The script don't read the part that do it shows ( Sorry, but you're too heavy to proceed ) if char's weight is > 121 .

Edited by Slowpoker

Share this post


Link to post
Share on other sites
  • 0

try to replace 

    if (checkweight(628, 20, 969, 1, 7019, 1))    {        mes "[ Divine ]";        mes "Sorry, but you're too heavy to proceed.";        close;    }

to 

if (readparam(Weight) > 121 && checkweight(628, 20, 969, 1, 7019, 1)){    mes "Sorry, but you're too heavy to proceed.";    close;}

this will check the weight and also the items.

Edited by sevenzz23

Share this post


Link to post
Share on other sites
  • 0

try to replace 

    if (checkweight(628, 20, 969, 1, 7019, 1))    {        mes "[ Divine ]";        mes "Sorry, but you're too heavy to proceed.";        close;    }

to 

if (readparam(Weight) > 121 && checkweight(628, 20, 969, 1, 7019, 1)){    mes "Sorry, but you're too heavy to proceed.";    close;}

this will check the weight and also the items.

 

 

 

I'm still a little confused as to what you're trying to do, but from what I understand, you want to see if the player has the exact amounts of the items specified; the weight check is to determine if the player is carrying anything other than the items in the amounts specified. If that's the case, then your process needs to be reorganised a little.

 

Give this a try; read the comments to see how the script progresses:

 

// ...next;// Check if player has the exact amount of these items and zenyif(countitem(628) == 20 && countitem(969) == 1 && countitem(7019) == 1 && Zeny == 50000){    // Check if the player's weight exceeds the items checked for    if (checkweight(628, 20, 969, 1, 7019, 1))    {        mes "[ Divine ]";        mes "Sorry, but you're too heavy to proceed.";        close;    }        // Delete items and deduct zeny    delitem 628, 20;    delitem 969, 1;    delitem 7019, 1;    Zeny -= 50000;        // Confirmation dialogue    mes "[ Divine ]";    mes "Ok, alright! You can go in here now!";    next;        // Warp player    warp "prontera",154,285;    close;}// Error messagemes "[ Divine ]";mes "I'm sorry, but you don't have the items required to proceed.";close;

 

The same error keeps guys. I tryed to replace sevenzz23 but i didn't get  any advance . I don't know why it doesn't work because seem to be one thing not so hard and error keeps on. I have already spent almost 2 day trying to fix it but no progress.

Share this post


Link to post
Share on other sites
  • 0

try to replace 

    if (checkweight(628, 20, 969, 1, 7019, 1))    {        mes "[ Divine ]";        mes "Sorry, but you're too heavy to proceed.";        close;    }

to 

if (readparam(Weight) > 121 && checkweight(628, 20, 969, 1, 7019, 1)){    mes "Sorry, but you're too heavy to proceed.";    close;}

this will check the weight and also the items.

 

I don't see why you would need to check it twice. The usage of checkweight() here will return 0 if the player is over the weight of the items and their respective amounts; this means that if the player is carry anything other than what was listed, (s)he will be unable to proceed.

 

 

@Slowpoker:

Is your character wearing any sort of equipment? Anything equipped counts towards your accumulative weight.

 

 

Edit:

I just noticed a very small (but critical) typo in the script I gave you lol.

 

Change this:

if (checkweight(628, 20, 969, 1, 7019, 1))

 

To this:

if (!checkweight(628, 20, 969, 1, 7019, 1))

 

The final output should be:

// ...next;// Check if player has the exact amount of these items and zenyif(countitem(628) == 20 && countitem(969) == 1 && countitem(7019) == 1 && Zeny == 50000){    // Check if the player's weight exceeds the items checked for    if (!checkweight(628, 20, 969, 1, 7019, 1))    {	    mes "[ Divine ]";	    mes "Sorry, but you're too heavy to proceed.";	    close;    }   	 // Delete items and deduct zeny    delitem 628, 20;    delitem 969, 1;    delitem 7019, 1;    Zeny -= 50000;   	 // Confirmation dialogue    mes "[ Divine ]";    mes "Ok, alright! You can go in here now!";    next;   	 // Warp player    warp "prontera",154,285;    close;}// Error messagemes "[ Divine ]";mes "I'm sorry, but you don't have the items required to proceed.";close;

Share this post


Link to post
Share on other sites
  • 0

 

try to replace 

    if (checkweight(628, 20, 969, 1, 7019, 1))    {        mes "[ Divine ]";        mes "Sorry, but you're too heavy to proceed.";        close;    }

to 

if (readparam(Weight) > 121 && checkweight(628, 20, 969, 1, 7019, 1)){    mes "Sorry, but you're too heavy to proceed.";    close;}

this will check the weight and also the items.

 

I don't see why you would need to check it twice. The usage of checkweight() here will return 0 if the player is over the weight of the items and their respective amounts; this means that if the player is carry anything other than what was listed, (s)he will be unable to proceed.

 

 

@Slowpoker:

Is your character wearing any sort of equipment? Anything equipped counts towards your accumulative weight.

 

 

Edit:

I just noticed a very small (but critical) typo in the script I gave you lol.

 

Change this:

 

if (checkweight(628, 20, 969, 1, 7019, 1))

 

To this:

 

if (!checkweight(628, 20, 969, 1, 7019, 1))

 

The final output should be:

 

// ...next;// Check if player has the exact amount of these items and zenyif(countitem(628) == 20 && countitem(969) == 1 && countitem(7019) == 1 && Zeny == 50000){    // Check if the player's weight exceeds the items checked for    if (!checkweight(628, 20, 969, 1, 7019, 1))    {	    mes "[ Divine ]";	    mes "Sorry, but you're too heavy to proceed.";	    close;    }   	 // Delete items and deduct zeny    delitem 628, 20;    delitem 969, 1;    delitem 7019, 1;    Zeny -= 50000;   	 // Confirmation dialogue    mes "[ Divine ]";    mes "Ok, alright! You can go in here now!";    next;   	 // Warp player    warp "prontera",154,285;    close;}// Error messagemes "[ Divine ]";mes "I'm sorry, but you don't have the items required to proceed.";close;

 

 

The error keeps on man, i'm already perturbed with it, lol. No, the char isn't wearing any kind of clothes on him. The weight's char scores 121 in the window(alt+v) when it is without clothes and carrying the items(628, 20, 969, 1, 7019, 1). When i use your script i just get to be teleported even if my weight is > 121 i get to be teleported too. It seems that the script doesn't get to run the two conditions, just one. I've been trying to fix it here but nothing happens, nothing advance.

Share this post


Link to post
Share on other sites
  • 0

Now, it's working perfectly !!!!! Thank you so much guy, you're the best! . I were almost giving up it and you saved me, thank you so much again!     :gawi:

 

 

 

 

:thx:

Edited by Slowpoker

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.