mIRC Homepage
Posted By: _DuDe_ Help again please? - 23/06/05 06:36 PM
Help again!!!!

I made an attack section, and when someone with a Strike of say 100,000,000 attacks someone with a defense of 1,000, the attacker makes an unbelievable ammount of gold, example 3,000,000,000, and the defender only has around 20,000 gold. It gives the attacker all 3,000,000,000 gold, and only takes away 3/4's of the defenders gold. I am so lost.

Code:
on *:TEXT:!attack*:*: {
  if ($2 == $null) { /msg $nick Please type !attack <nick> to attack someone | .halt
  }
  if ($2 != $null) && ( $readini( $2 $+ .ini, THINGS, gold) == $null) { /msg $nick Please attack someone that has gold. | .halt
  }
  if ($2 != $null) && ( $readini( $2 $+ .ini, THINGS, gold) != $null) {
    /msg $nick Attacking $2
    var %attack = $readini( $nick $+ .ini, THINGS, strike)
    var %defense = $readini( $2 $+ .ini, THINGS, defense)
    var %result = $calc( %attack - %defense )
  }
  if ( %result > 0 ) {
    var %loot = $round( $calc( $readini( $nick $+ .ini, THINGS, gold) + $calc( $readini( $2 $+ .ini, THINGS, gold) * .75 )) , 0)
    writeini $nick $+ .ini THINGS gold %loot
    writeini $2 $+ .ini THINGS gold $round( $calc( $readini( $2 $+ .ini, THINGS, gold) - $calc( $readini( $2 $+ .ini, THINGS, gold) * .75 )) , 0)
    msg $nick You Won  $bytes( %loot , b )  !
  }
  elseif ( %result <= 0 ) { msg $nick You Lost. }
}
 
Posted By: _DuDe_ Re: Help again please? - 23/06/05 09:01 PM
You can change the script any way you want, even re-write it if you want, just please please help me.
Posted By: DaveC Re: Help again please? - 23/06/05 09:21 PM
The "you won xxxx" message included there previous balance also, it was not ONLY what they won, but rather there total gold amount after the attack.

* I also reduced your over all IF condition checks as you can just use ELSE to represent the != of the previous IF condition.
* I removed the halts, as the script exits anyway. I believe in not putting them in unless you have to.

Code:
on *:TEXT:!attack*:*: {
  if ($2 == $null) { msg $nick Please type !attack <nick> to attack someone }
  elseif ($readini( $2 $+ .ini, THINGS, gold) == $null) { msg $nick Please attack someone that has gold. }
  else {
    msg $nick Attacking $2
    var %attack = $readini( $nick $+ .ini, THINGS, strike)
    var %defense = $readini( $2 $+ .ini, THINGS, defense)
    var %result = $calc( %attack - %defense )
    if ( %result > 0 ) {
      var %loot = $round( $calc( $readini( $2 $+ .ini, THINGS, gold) * .75 ) , 0)
      writeini $nick $+ .ini THINGS gold $round( $calc( $readini( $nick $+ .ini, THINGS, gold) + %loot ) , 0)
      writeini $2    $+ .ini THINGS gold $round( $calc( $readini( $2    $+ .ini, THINGS, gold) - %loot ) , 0)
      msg $nick You Won  $bytes( %loot , b )  !
    }
    else { msg $nick You Lost. }
  }
}


* I also think you should add some loss of gold from the attacker to the defender if they do loose. But thats just an opion.
Posted By: _DuDe_ Re: Help again please? - 23/06/05 11:39 PM
If you make that section, I will add it, I am so script confused. lol, jp. I am just tired.
Posted By: DaveC Re: Help again please? - 24/06/05 08:31 AM
Code:
on *:TEXT:!attack*:*: {
  if ($2 == $null) { msg $nick Please type !attack <nick> to attack someone }
  elseif ($readini( $2 $+ .ini, THINGS, gold) == $null) { msg $nick Please attack someone that has gold. }
  else {
    msg $nick Attacking $2
    var %attack = $readini( $nick $+ .ini, THINGS, strike)
    var %defense = $readini( $2 $+ .ini, THINGS, defense)
    var %result = $calc( %attack - %defense )
    if ( %result > 0 ) {
      var %loot = $round( $calc( $readini( $2 $+ .ini, THINGS, gold) * .75 ) , 0)
      writeini $nick $+ .ini THINGS gold $round( $calc( $readini( $nick $+ .ini, THINGS, gold) + %loot ) , 0)
      writeini $2    $+ .ini THINGS gold $round( $calc( $readini( $2    $+ .ini, THINGS, gold) - %loot ) , 0)
      msg $nick You Won  $bytes( %loot , b )  !
    }
    elseif ( %result == 0 ) { msg $nick You both bash away at each other for hours but finnally turn and trudge away to fight another day, calling today a draw!. }
    else { 
      var %loot = $round( $calc( $readini( $nick $+ .ini, THINGS, gold) * .75 ) , 0)
      writeini $2    $+ .ini THINGS gold $round( $calc( $readini( $2    $+ .ini, THINGS, gold) + %loot ) , 0)
      writeini $nick $+ .ini THINGS gold $round( $calc( $readini( $nick $+ .ini, THINGS, gold) - %loot ) , 0)
      msg $nick Oh dear oh dear, You Lost  $bytes( %loot , b )  !
    }
  }
}
© mIRC Discussion Forums