mIRC Home    About    Download    Register    News    Help

Print Thread
adding players to a game.... #250359 11/01/15 06:27 AM
Joined: Sep 2014
Posts: 83
H
HappyFappy Offline OP
Babel fish
OP Offline
Babel fish
H
Joined: Sep 2014
Posts: 83
This is a BIG tricky one... (not for you superninjas of mIRC)

I wanna add players to a game...

-when someone attacks, it adds their name to a list
-if they attack multiple times it wont add their nick more than just the once
-at the end, the players get awarded only

something like "add $nick to players.ini" <--- adds to the *tipped blah blah blah*
and then read the players.ini
and tip each one the same amount splitting a determined amount

like:
10 players total and 100 in reward

!tip playera 10
!tip playerb 10
and so on
(this part needs to go in alias rain)

Here is my gamecode i made:

Code:
alias start { 
  var %num = $rand(0,10)
  if (%num == 0) {
    /bonus
  }
  if (%num == 1) {
    set %total 100
    /set %money.deposit $calc( $readini( zombie.ini, ZOMBIE , Money ) + 100 )
    /writeini zombie.ini ZOMBIE Money %money.deposit
    /unset %money.deposit
    timer 1 1 msg # NEW WAVE! This round has %total ZOMBIES!
  }
  if (%num == 2) {
    set %total 150
    /set %money.deposit $calc( $readini( zombie.ini, ZOMBIE , Money ) + 150 )
    /writeini zombie.ini ZOMBIE Money %money.deposit
    /unset %money.deposit
    timer 1 1 msg # NEW WAVE! This round has %total ZOMBIES!
  }
  if (%num == 3) {
    set %total 200
    /set %money.deposit $calc( $readini( zombie.ini, ZOMBIE , Money ) + 200 )
    /writeini zombie.ini ZOMBIE Money %money.deposit
    /unset %money.deposit
    timer 1 1 msg # NEW WAVE! This round has %total ZOMBIES!
  }
  if (%num == 4) {
    set %total 250
    /set %money.deposit $calc( $readini( zombie.ini, ZOMBIE , Money ) + 250 )
    /writeini zombie.ini ZOMBIE Money %money.deposit
    /unset %money.deposit
    timer 1 1 msg # NEW WAVE! This round has %total ZOMBIES!
  }
  if (%num == 5) {
    set %total 300
    /set %money.deposit $calc( $readini( zombie.ini, ZOMBIE , Money ) + 300 )
    /writeini zombie.ini ZOMBIE Money %money.deposit
    /unset %money.deposit
    timer 1 1 msg # NEW WAVE! This round has %total ZOMBIES!
  }
  if (%num == 6) {
    set %total 350
    /set %money.deposit $calc( $readini( zombie.ini, ZOMBIE , Money ) + 350 )
    /writeini zombie.ini ZOMBIE Money %money.deposit
    /unset %money.deposit
    timer 1 1 msg # NEW WAVE! This round has %total ZOMBIES!
  }
  if (%num == 7) {
    set %total 400
    /set %money.deposit $calc( $readini( zombie.ini, ZOMBIE , Money ) + 400 )
    /writeini zombie.ini ZOMBIE Money %money.deposit
    /unset %money.deposit
    timer 1 1 msg # NEW WAVE! This round has %total ZOMBIES!
  }
  if (%num == 8) {
    set %total 450
    /set %money.deposit $calc( $readini( zombie.ini, ZOMBIE , Money ) + 450 )
    /writeini zombie.ini ZOMBIE Money %money.deposit
    /unset %money.deposit
    timer 1 1 msg # NEW WAVE! This round has %total ZOMBIES!
  }
  if (%num == 9) {
    set %total 500
    /set %money.deposit $calc( $readini( zombie.ini, ZOMBIE , Money ) + 500 )
    /writeini zombie.ini ZOMBIE Money %money.deposit
    /unset %money.deposit
    timer 1 1 msg # NEW WAVE! This round has %total ZOMBIES!
  }
  if (%num == 10) {
    set %total 550
    /set %money.deposit $calc( $readini( zombie.ini, ZOMBIE , Money ) + 550 )
    /writeini zombie.ini ZOMBIE Money %money.deposit
    /unset %money.deposit
    timer 1 1 msg # NEW WAVE! This round has %total ZOMBIES!
  }
}
alias bonus { 
  set %total 1000
  /set %money.deposit $calc( $readini( zombie.ini, ZOMBIE , Money ) + 1000 )
  /writeini zombie.ini ZOMBIE Money %money.deposit
  /unset %money.deposit
  msg # BONUS ROUND!
}
ON *:TEXT:*tipped nameofgame*:#:{ 
  /set %money.deposit $calc( $readini( zombie.ini, ZOMBIE , Money ) - $4 )
  /writeini zombie.ini ZOMBIE Money %money.deposit
  /unset %money.deposit
  var %num1 = $rand(0,4)
  if (%num1 == 1) {
    set %m1 $4 * 1
    timer 1 1 msg # $1 has attacked the zombies with a x1 multiplier and taken out %m1 of %total zombies this wave with $readini(zombie.ini, ZOMBIE, Money) zombies left!
    halt
  }
  if (%num1 == 2) {
    set %m2 $4 * 2
    timer 1 1 msg #doomageddon $1 has attacked the zombies with a x2 multiplier and taken out %m2 of %total zombies this wave with $readini(zombie.ini, ZOMBIE, Money) zombies left!
    halt
  }
  if (%num1 == 3) {
    set %m3 $4 * 1
    timer 1 1 msg # $1 has attacked the zombies with a x1 multiplier and taken out %m3 of %total zombies this wave with $readini(zombie.ini, ZOMBIE, Money) zombies left!
    halt
  }
  if (%num1 == 0) {
    set %m4 $4 * 3
    timer 1 1 msg # $1 has attacked the zombies with a x3 multiplier and taken out %m4 of %total zombies this wave with $readini(zombie.ini, ZOMBIE, Money) zombies left!
    halt
  }
  if (%num1 == 4) {
    set %m5 $4 * 1
    timer 1 1 msg # $1 has attacked the zombies with a x1 multiplier and taken out %m5 of %total zombies this wave with $readini(zombie.ini, ZOMBIE, Money) zombies left!
    halt 
  }
  /unset %num1
  check
}
alias check { 
  if ($readini( zombie.ini, zombie, Money ) = 0) {
    rain
  }
  if ($readini( zombie.ini, zombie, Money ) > 0) {
    halt
  }
}
alias rain { 
  msg # THE ZOMBIES HAVE BEEN DEFEATED! The warriors will recieve the spoils of war!
}
ON *:TEXT:go:?: {
  if ($nick == adminuser) { 
    start
  }
}

Re: adding players to a game.... [Re: HappyFappy] #250360 11/01/15 08:29 AM
Joined: Jun 2014
Posts: 248
B
Belhifet Offline
Fjord artisan
Offline
Fjord artisan
B
Joined: Jun 2014
Posts: 248
Code:
ON *:TEXT:!whateverillplay:#:{ 
  if (!$hget(players)) { hmake players }
  if (!$hget(players,$nick)) { 
    hadd players $nick $calc($hget(players,0).item + 1) 
    .msg $chan ok w/e added you
  }
  else { .msg $chan gtfo scrub u already play'n }
}
alias rain { 
  msg # THE ZOMBIES HAVE BEEN DEFEATED! The warriors will recieve the spoils of war!
  var %i = 1, %payout = $floor($calc($readini(zombie.ini,ZOMBIE,Money) / $hget(players,0).item))
  while (%i <= $hget(players,0).item) {
    writeini filewithmoney.ini $hget(players,%i).item $calc($readini(filewithmoney.ini,$hget(players,%i).item,moneyvalue) + %payout)
    inc %i
  }
  hfree players
}


Uhh something like this? I dunno I couldnt really test it.

Your code is kinda bloated..you can cut down that stuff by...a ton.

Code:
alias start {
  var %num = $rand(0,10)
  writeini zombie.ini ZOMBIE Money $calc($readini(zombie.ini,ZOMBIE,Money) + $iif(%num >= 1,$calc(50 + (50 * %num)),1000))
  if (%num >= 1) { msg # NEW WAVE! This round has $calc(50 * %num) ZOMBIES! }
  else { msg # BONUS ROUND! }
}


When you're writing code try to not repeat yourself.

Re: adding players to a game.... [Re: Belhifet] #250361 11/01/15 09:00 AM
Joined: Sep 2014
Posts: 83
H
HappyFappy Offline OP
Babel fish
OP Offline
Babel fish
H
Joined: Sep 2014
Posts: 83
lol i figured there was an easier way

but this:
Code:
ON *:TEXT:!whateverillplay:#:{ 
  if (!$hget(players)) { hmake players }
  if (!$hget(players,$nick)) { 
    hadd players $nick $calc($hget(players,0).item + 1) 
    .msg $chan ok w/e added you
  }
  else { .msg $chan gtfo scrub u already play'n }
}


can it accept the same player to play again but their nick wont show twice?

Re: adding players to a game.... [Re: HappyFappy] #250374 12/01/15 04:35 AM
Joined: Jun 2014
Posts: 248
B
Belhifet Offline
Fjord artisan
Offline
Fjord artisan
B
Joined: Jun 2014
Posts: 248
I'm not clear what you mean. Its setup to either add them to the list of people playing or tell them they are already playing.

Re: adding players to a game.... [Re: Belhifet] #250424 14/01/15 01:50 AM
Joined: Sep 2014
Posts: 83
H
HappyFappy Offline OP
Babel fish
OP Offline
Babel fish
H
Joined: Sep 2014
Posts: 83
im having a new problem w/ this script

how do i get it to reset an .ini file to blank

i've tried removal but it doesnt seem to do anything

Code:
/remove C:\Documents and Settings\********\Application Data\mIRC\zombie.ini

that doesnt apparently delete

Re: adding players to a game.... [Re: HappyFappy] #250476 16/01/15 11:58 PM
Joined: Mar 2014
Posts: 215
J
judge2020 Offline
Fjord artisan
Offline
Fjord artisan
J
Joined: Mar 2014
Posts: 215
if you have one section (as in one thing that is surrounded by [] at the beginning) then you can /remini path\yourini.ini yoursection

else, you could "/remove path\youini.ini" and the next time mirc tries to write to the removed INI it will automatically create the file again


#imAbeginner
i made a chat bot for mark_paintball! http://twitch.tv/mark_paintball
Re: adding players to a game.... [Re: HappyFappy] #250576 22/01/15 09:11 AM
Joined: Jan 2015
Posts: 1
T
TrihXeen Offline
Mostly harmless
Offline
Mostly harmless
T
Joined: Jan 2015
Posts: 1
I hope you don't mind, but ive played with your code and took out the bonus round(i didnt really wanna use it), made some other changes. Made to use with a twitch chat bot. im new to writing code in mIRC, so tell me what you guys think!

here is what i ended up with: http://pastebin.com/raBiy3P8