if nesting issue?

Forum Archive - from http://theuniversal.net
Locked
User avatar
morbydvisns
Posts: 1889
Joined: Sun Jan 30, 2005 12:51 am

if nesting issue?

Post by morbydvisns »

Software:Universal Client
Version Number:54.3
________________________________________________________________________
Location
bongtopia
________________________________________________________________________
Description:
ok check this

Code: Select all

event( "custom", "ore")
 {
 *say ore
 $playervar11 = Playerinventory( "ore" )
 Customevent( "orewatch" )
 }


event( "custom", "orewatch" )
{
 $playervar2 = playerinventory("ore")
 if ( $playervar11 = $playervar2 )
 {
  sleep(5)
  customevent("orewatch")
 }
 else
 {
 $playervar15 = $playervar15 - 1
 *say %player% has used one action
if ( $playervar15 = 0 )
  {
 customevent("cycle2")
  }
 else
  {
  }
 sleep(5)
 customevent("ore")
 }
}
what this SHOULD do:
set a var for the inventory amnt of ore, and actively monitor on hand and once it changes, it sets a var and re-sets the var for amnt on hand.

it shouldnt not run custom event ore until the amnt changes.

but it does.

the problem is in the if statement nested that looks for playervar15 to be 0. this shold only execute when the amount changes. it seems like the nested if makes it forget it was in an if in the first place and goes and finishes out the if it ignored until the nested if came in to play. this will make customevent("ore") run every time as its written above and fills the chat box with red ORE.



________________________________________________________________________
Steps to Replicate:

Code: Select all


event( "custom", "ore")
 {
 *say ore
 $playervar11 = Playerinventory( "ore" )
 Customevent( "orewatch" )
 }


event( "custom", "orewatch" )
{
 $playervar2 = playerinventory("ore")
 if ( $playervar11 = $playervar2 )
 {
  sleep(5)
  customevent("orewatch")
 }
 else
 {
 $playervar15 = $playervar15 - 1
 *say %player% has used one action
 sleep(5)
 customevent("ore")
 }
}


however by removing the nested if and else (i added the else after tryign without, to see if tha tmade any diff, but same results.) it works just fine, only running ore custom if the amnt of ore on hand changes.
Locked