mIRC Homepage
Posted By: sparta writeini - 28/01/05 11:38 PM
I have this script:

Code:
on *:TEXT:*:#teting: {
  if ($1 == !add) {
    inc %players
    writeini player.ini $2 $+(player,%players) $nick
  }
}


that working ok, and i have !add to add people to a file, they use: !add 21 <<-- to add them self to 21, and !add 22 to add them self to 22 and so on, the problem start when they addig them self to two times, then it looks like this in the ini file:

[21]
player1=Nick
player2=Nick2
player3=Nick3
[22]
player1=Nick2
player4=Nick3

the problem is that the "player4" should be the same as "player3" and the "player1" should be "player2".. cos they are added to 21 already, and they should be added as the same player below [22] too, cos its the same nicks, and its the same players. any ideas how to solve this ?? :tongue:
Posted By: Iori Re: writeini - 29/01/05 12:30 AM
Maybe add another section with each of the players respective 'group' in it.
Also $read( ,w,*=nick) to find their previous player#
Code:
on *:TEXT:!add *:#teting: {
[color:gray]  ; Search for a previous entry and re-use the same playernumber[/color]
  if $read(player.ini,nw,$+(*=,$nick)) { var %a = $gettok(v1,1,61) }
[color:gray]  ; If none, make a new one from %players[/color]
  else { inc %players | var %a = player $+ %players }
[color:gray]  ; Now delete the old entry[/color]
  if $readini(player.ini,players,%a) { remini player.ini $v1 %a }
[color:gray]  ; add the new[/color]
  writeini player.ini $2 %a $nick
[color:gray]  ; record the grouping[/color]
  writeini player.ini players %a $2
}
Posted By: sparta Re: writeini - 29/01/05 12:50 AM
that working, but now to another problem, how the h*ll do i list all players for lests say 21 .. !list 21 .. and for 22 !list 22 .. same about how do i remove one player: !remove 21 <<-- and he would be removed from 21 ?

************ EDIT **********

didnt work as it should, if i type: !add 21 once more, then i get added again, but in a difrent way.. and thats wrong :tongue:

[21]
player1=this_is_me
v1=this_is_also_me
[players]
player1=21
player2=22
v1=21
[22]
player2=another_player

so dosent work as it should.. now i can add me self how many times i want, but should only be able to add me self 1 time at 21 .. and one time at 22.. same for other players too.. :tongue: and i should be added as 1 person at 21 "if i use !add 21" and the same person but on the time 22 if i use "!add 22" .. hope you understand.. :tongue:
Posted By: tidy_trax Re: writeini - 29/01/05 01:06 AM
Iori missed a $ in:

Code:
var %a = $gettok(v1,1,61)


It should be:

Code:
var %a = $gettok([color:red]$[/color]v1,1,61)
Posted By: sparta Re: writeini - 29/01/05 01:10 AM
nope, still problems, it remve me from 21 and place me in 22 instead.. so then im not added to both.. :tongue: if i want to be added in both maybe i should add..
Posted By: Iori Re: writeini - 29/01/05 01:12 AM
Code:
on *:TEXT:!add *:#teting: {
  echo -a here
  ; Search for a previous entry and re-use the same playernumber
[color:blue]  if $read(player.ini,nw,$+(* $nick)) { var %a = $gettok($v1,1,61) }[/color]
  ; If none, make a new one from %players
  else {
    inc %players
    var %a = player $+ %players
[color:blue]    writeini player.ini players %a $nick[/color]
  }
  writeini player.ini $2 %a $nick
}
Posted By: sparta Re: writeini - 29/01/05 01:15 AM
that worked bether, but it didnt add me with the time 22

[players]
player1=21
[21]
player1=this_is_me
[22]
player1=this_is_also_me

player1=21 .. but that only say 21.. not 22 ?? or dosent that mather? :tongue: i must admit im bad at writeini and readini confused
Posted By: Iori Re: writeini - 29/01/05 01:21 AM
That doen't really matter, it only records the first time the player is added, it's only for the player#.

See the edited code above, now adds $nick instead of level (the $read() line changed too)
Posted By: sparta Re: writeini - 29/01/05 02:26 AM
how would i list all players with !list 21 then ?

$readini(players.ini, players, $2 )

tryed that, but dont work at all, and i dont get a error message on it ether.. $2 would be the time: !list 21
Posted By: Iori Re: writeini - 29/01/05 03:02 AM
Code:
alias listplayers {
  window -h @@
  loadbuf -t $+ $1 @@ player.ini
  var %i = 1
  while $line(@@,%i) {
    echo -a $gettok($v1,2,61)
    inc %i
  }
  window -c @@
}
Posted By: sparta Re: writeini - 29/01/05 03:59 AM
what does $gettok($v1,2,61) <<-- the numbers in that mean? i have a litle problem, i making a "bot", that means that people can write !list 21 , but since that line trigger the alias $2 wont be the time in the alias, so have to be replaced with a %var.. but i dont know where to set that %var :tongue:
Posted By: Iori Re: writeini - 29/01/05 04:17 AM
In a text event with the string "!list 21" - $1 = !list $2 = 21, so you'd use

  • loadbuf -t $+ $2 @@ player.ini


Code:
  while $line(@@,%i) {
    ; In this while loop,

    ; here $v1 is the line just read - something like "player16=bob"
    ; /help /if
    echo -a $gettok($v1,2,61)
    ; and $gettok($v1,2,61) is the part after the $chr(61) (the "=" equal sign), or "bob"
    ; /help $gettok
    inc %i
  }
Posted By: sparta Re: writeini - 29/01/05 02:04 PM
still no go: * /echo: insufficient parameters (line 50, script.ini)

and i dont know where to put a %var for the time..

echo -a $gettok($v1,2,61)

its in that line the problem are.. :tongue:
Code:
alias listplayers {
  .notice $nick ° Available for  $+ %time $+  is:
  window -h @@
  loadbuf -t $+ $1 @@ player.ini
  var %i = 1
  while $line(@@,%i) {
     [color:red]echo -a $gettok($v1,2,61)[/color]
    .notice $nick °  $+ $gettok($v1,2,61) $+ 
    inc %i
  }
  window -c @@
}

the red line is line 50.
Posted By: Iori Re: writeini - 29/01/05 02:12 PM
What version of mIRC are you using? If its an old version you will have to change "$v1" to "$ifmatch"

Quote:
and i dont know where to put a %var for the time..

Look at the red $2 in the last post :tongue:
Posted By: sparta Re: writeini - 29/01/05 02:14 PM
I using old mirc, and that $2 is $1 in the script.. and it work as it should with $1 so dont know if i should change it to $2 :tongue: and the problem is in line 50, $1 or as you say $2 is on the line 47. and i dont get any error on that line, tryed change to $ifmatch, but still same problem..

**************** Edit ******************

Now i got it to work, but it list the same player two times.. :P
Code:
alias listplayers {
  .notice $nick ° Available for  $+ %time $+  is:
  window -h @@
  loadbuf -t $+ $1 @@ player.ini
  var %i = 1
  while $line(@@,%i) {
    echo -a --&gt;&gt; $gettok($ifmatch,2,61)
    .notice $nick °  $+ $gettok($ifmatch,2,61) $+ 
    inc %i
  }
  window -c @@
}

i needed to add the echo -a -->> $gettok($ifmatch,2,61)
but how can i make it to only list the player 1 time.. "only added as player at 21 one time.. still listed 2 times :tongue:
Posted By: Iori Re: writeini - 29/01/05 02:41 PM
Quote:
I using old mirc
So none of the code I posted in this thread should work, I've used $v1 in all of it laugh

As for listing it twice, try again, when you got the error the script would have halted at that line so the window never was closed. and add a window -c line to the beginning too.
Code:
alias listplayers {
  .notice $nick ° Available for  $+ %time $+  is:
[color:red]  window -c @@[/color]
  window -h @@
  ...
}
Posted By: sparta Re: writeini - 29/01/05 03:04 PM
i tested it in new mirc too, same problem, but rewriting everything. maybe i post it here if i run in to problems.. thnx for your help anyway smile

************ EDIT ***************

i have a ini file that looks like this inside:

[21]
player1=21
[22]
player1=22

and now i cant get to to start read from [21] (text markes as red) and stop when it hit [22].. :tongue:
© mIRC Discussion Forums