mIRC Home    About    Download    Register    News    Help

Print Thread
#135193 09/11/05 04:49 AM
Joined: Sep 2005
Posts: 4
S
Self-satisified door
OP Offline
Self-satisified door
S
Joined: Sep 2005
Posts: 4
let see here i am trying to get my script to update an ini file ever 5 mins all it has to do is go down the list of players and add one more trun to there truns I have all ready tried something here is the code I tried to do but it does not work

on 100:text:!on:*:{
notice $nick Time has started
timer1 0 300 writeini player.ini turns $nick $calc($readini(player.ini, turns, $nick) + 1)
}


any help on this would be great

Joined: Dec 2002
Posts: 1,245
M
Hoopy frood
Offline
Hoopy frood
M
Joined: Dec 2002
Posts: 1,245
well timers wont work right the way you have it as it "stores" the data that is entered in the string and repeats that data, so it would only ever replace say 1 in the ini with the new value of 1 + 1 (what it read when it started)
try this
Code:
on 100:text:!on:*:{
  notice $nick Time has started
  timer1 0 300 playturns $nick
}
alias playturns {
  var %lastvalue = $readini(player.ini, turns, $1)
  writeini player.ini turns $1 $calc(%lastvalue + 1)
  msg $1 Turn = $readini(player.ini, turns, $1)
}
alias testplay { playturns $me }


you may need to //writeini player.ini turns $me 1
to get it started (yes two //)

Joined: Sep 2005
Posts: 4
S
Self-satisified door
OP Offline
Self-satisified door
S
Joined: Sep 2005
Posts: 4
I have tried that code out and yes it did work for me but when more users joined up to the game it did not update there turns just mine is there a way to update all the turns?

Joined: Dec 2002
Posts: 1,245
M
Hoopy frood
Offline
Hoopy frood
M
Joined: Dec 2002
Posts: 1,245
there are alot of other things that should be changed in that code, I was showing you just that the timer can do what you want by having it call an alias.
what you will need to do is have the script set a variable to the nick and spawn a new timer with the nick as part of the timer name
you also need an "off" text as well as on part, on quit, on nick events to stop the timer for that nick. If the bot isnt using timers for anything else you can have it stop all timers, but this can create problems later. Use timer.game. $+ %thevariable and you can /timer.game* off to turn them all off that are specific to the game.

also be sure that you have added the other users to your level 100 that you have specified for the text event.

Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
An easy way to do this (assuming you don't have so many players that your line length is too long) is to do it like this:

Code:
on 100:text:!on:#:{
  .timerupdateturns 0 300 updateturns
}

alias updateturns {
  var %c = 1
  var %i = $numtok($readini(players.ini,players,names),32)
  while (%c <= %i) {
    var %nick = $gettok($readini(players.ini,players,names),%c,32)
    writeini players.ini Turns %nick $calc($readini(players.ini,Turns,%nick) + 1)
    inc %c
  }
}


Then, just add the nicks to your ini like this:

[Players]
Names=nick1 nick2 nick3 nick4 nick5 nick6

See information about $remtok and $deltok if you want to remove individual nicks later. Be careful not to have a nick on the list more than once.

This will add 1 to all players who are listed in the section I described above.


Of course, another method would be to use a hash table. smile


Oh, and I think this will not do what you really want... If you want everyone to have the same turn number, then you can use a single variable. If you want individual turn numbers and you want turns to update only every 5 minutes and not any other time, then this is good. However, if you want people to end their own turn (increase the turn number) when they complete something so that they can take another turn, then this timer will cause extra turns to be added (1 for the person ending their own turn, and another for the 5 minute timer). It will depend on exactly what you're trying to accomplish with this.


Invision Support
#Invision on irc.irchighway.net

Link Copied to Clipboard