mIRC Home    About    Download    Register    News    Help

Print Thread
Help again please? #123466 23/06/05 06:36 PM
Joined: Jun 2005
Posts: 30
_
_DuDe_ Offline OP
Ameglian cow
OP Offline
Ameglian cow
_
Joined: Jun 2005
Posts: 30
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. }
}
 

Re: Help again please? #123467 23/06/05 09:01 PM
Joined: Jun 2005
Posts: 30
_
_DuDe_ Offline OP
Ameglian cow
OP Offline
Ameglian cow
_
Joined: Jun 2005
Posts: 30
You can change the script any way you want, even re-write it if you want, just please please help me.

Re: Help again please? #123468 23/06/05 09:21 PM
Joined: Sep 2003
Posts: 4,230
D
DaveC Offline
Hoopy frood
Offline
Hoopy frood
D
Joined: Sep 2003
Posts: 4,230
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.

Re: Help again please? #123469 23/06/05 11:39 PM
Joined: Jun 2005
Posts: 30
_
_DuDe_ Offline OP
Ameglian cow
OP Offline
Ameglian cow
_
Joined: Jun 2005
Posts: 30
If you make that section, I will add it, I am so script confused. lol, jp. I am just tired.

Re: Help again please? #123470 24/06/05 08:31 AM
Joined: Sep 2003
Posts: 4,230
D
DaveC Offline
Hoopy frood
Offline
Hoopy frood
D
Joined: Sep 2003
Posts: 4,230
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 )  !
    }
  }
}