Jump to content

How to read a .ini?


Mania-92

Recommended Posts

if ($readini(bla.ini,TEST,Mania-92[NL]) == 1) { blablabla }

on *:SIGNAL:mta.join:{
 if ($readini(bla.ini,TEST,$mta.name($1,$2)) == 1) mta.text $1 hello $mta.name($1,$2)
}

elseif ($3 == !warn) {
   if ($readini(test.ini,WARNS,$4) == 0) {
     !writeini -n " $+ $scriptdir $+ test.ini" WARNS $4 1
 }

This doesn't works. :roll: Anyone some suggestions?

Link to comment
elseif ($3 == !warn) {
 if ($readini($scriptdir $+ test.ini,WARNS,$4) == 0) {
   !writeini -n " $+ $scriptdir $+ test.ini" WARNS $4 1
 }
}

Still doesn't work.

This is my whole script:

on *:SIGNAL:mta.command: {
 ;Parameters:
 ;$1 = Server
 ;$2 = ID
 ;$3 = Command
 ;$4- = Parameters
 /*
 if ($3 == !nice) {
   mta.text $1 $mta.nick($1,$2) thinks the victory of $4 was nice! 
 }
 */
 if ($3 == !nice) {
   mta.text $1 $mta.nick($1,$2) thinks the victory of $mta.nick($1,$mta.getid($1,$4)) was nice! 
 }
 elseif ($3 == !warn2) {
   if ($mta.level($1,$2) == 5) {
     mta.text $1 $mta.nick($1,$2) warned $4!
   }
   else mta.pm $1 $2 Error - You need to be level 5 to use this command.
 }
 elseif ($3 == !warn) {
 if ($readini($scriptdir $+ test.ini,WARNS,$4) == 0) {
   !writeini -n " $+ $scriptdir $+ test.ini" WARNS $4 1
 }
}

on *:SIGNAL:mta.text: {
 if ($3 == brb) {
   mta.text $1 $mta.nick($1,$2) will be right back!
 }
}

on *:SIGNAL:mta.join: {
 !writeini -n " $+ $scriptdir $+ test.ini" WARNS $mta.ip 0
 }
}

Edited by Guest
Link to comment
if ($readini(bla.ini,TEST,Mania-92[NL]) == 1) { blablabla }

on *:SIGNAL:mta.join:{
 if ($readini(bla.ini,TEST,$mta.name($1,$2)) == 1) mta.text $1 hello $mta.name($1,$2)
}

your mixed up with VC again :P

i know your used to mta 0.5 so i guess

if ($readini(bla.ini,TEST,Mania-92[NL]) == 1) { blablabla }

on *:SIGNAL:mta.join:{
 if ($readini(bla.ini,TEST,$mta.nick($1,$2)) == 1) mta.text $1 hello $mta.nick($1,$2)
}

right ?

Link to comment
on *:SIGNAL:mta.command: {
 var %a = $iif($4,$iif($mta.nick($1,$4) != Unknown,$4,$bla.getid($1,$4)),$2)
 if ($3 == !nice) mta.text $1 $mta.nick($1,$2) thinks the victory of $mta.nick($1,%a) was nice!
 elseif ($3 == !warn) {
   var %b = $readini($scriptdir $+ test.ini,WARNS,$mta.nick($1,%a))
   if (!%b) {
     !writeini " $+ $scriptdir $+ test.ini" WARNS $mta.nick($1,%a) $calc(%b + 1)
     mta.text $1 $mta.nick($1,%a) has been warned ( $+ $readini($scriptdir $+ test.ini,WARNS,$mta.nick($1,%a)) warnings in total)
   }
 }
}
on *:SIGNAL:mta.text: {
 if ($3 == brb) mta.text $1 $mta.nick($1,$2) will be right back!
}
on *:SIGNAL:mta.join: {
 !writeini -n " $+ $scriptdir $+ test.ini" WARNS $mta.nick($1,$2) 0
}
alias bla.getid {
 var %a = 0
 while (%a <= $mta.server($1).cmax)  {
   if ($2 isin $mta.nick($1,%a)) !return %a
   !inc %a
 }
 !return -1
}

Link to comment

If for example an ini is BLABLA=1, can write it back to 0 with !writeini?

This for example?:

on *:SIGNAL:mta.text: {
 if ($3 == brb) {
   mta.text $1 $mta.nick($1,$2) will be back soon!
   !writeini -n " $+ $scriptdir $+ brb.ini" BRB $mta.ip($1,$2) 1
 }
 elseif ($3 == *) {
   if ($readini($scriptdir $+ brb.ini,BRB,$mta.ip($1,$2)) == 1) {
     !writeini -n " $+ $scriptdir $+ brb.ini" BRB $mta.ip($1,$2) 0
     mta.text $1 $mta.nick($1,$2) is back!
   }    
 }
}

Link to comment

of course you can.. but you can also remove that from the ini

thats how i'd do that if i was you:

on *:SIGNAL:mta.text: {
 if ($3 == brb) {
   mta.text $1 $mta.nick($1,$2) will be back soon!
   !writeini -n " $+ $scriptdir $+ brb.ini" BRB $mta.ip($1,$2) 1
 }
 elseif ($readini($scriptdir $+ brb.ini,BRB,$mta.ip($1,$2))) {
   !remini " $+ $scriptdir $+ brb.ini" BRB $mta.ip($1,$2)
   mta.text $1 $mta.nick($1,$2) is back!
 }   
}

Link to comment
of course you can.. but you can also remove that from the ini

thats how i'd do that if i was you:

on *:SIGNAL:mta.text: {
 if ($3 == brb) {
   mta.text $1 $mta.nick($1,$2) will be back soon!
   !writeini -n " $+ $scriptdir $+ brb.ini" BRB $mta.ip($1,$2) 1
 }
 elseif ($readini($scriptdir $+ brb.ini,BRB,$mta.ip($1,$2))) {
   !remini " $+ $scriptdir $+ brb.ini" BRB $mta.ip($1,$2)
   mta.text $1 $mta.nick($1,$2) is back!
 }   
}

Now i have a script like this:

on *:SIGNAL:mta.text: {
 if ($3 == brb) {
   if ($readini(bla.ini,TEST,$mta.nick($1,$2)) == 1) {
     mta.text $1 $mta.nick($1,$2) will be back soon!
     !remini " $+ $scriptdir $+ brb.ini" BRB $mta.ip($1,$2)
     !writeini -n " $+ $scriptdir $+ brb.ini" BRB $mta.ip($1,$2) 2
   }
 }
 elseif ($3 == *) {
   if ($readini($scriptdir $+ brb.ini,BRB,$mta.ip($1,$2)) == 2) {
     !remini " $+ $scriptdir $+ brb.ini" BRB $mta.ip($1,$2)
     !writeini -n " $+ $scriptdir $+ brb.ini" BRB $mta.ip($1,$2) 1
     mta.text $1 $mta.nick($1,$2) is back!
   }
 }   
}

on *:SIGNAL:mta.join: {
!writeini -n " $+ $scriptdir $+ brb.ini" BRB $mta.ip($1,$2) 1
}

mta.join works because there is writen an ini "IP=1", but on text brb there is no text no text and on the ini line it's still 1.

PS, the rest of my scrips works fine only this:

elseif ($3 == !players) {
   mta.text $1 $mta.players($1,$2)

Doesn't work eather

Kind Regards, Mania

Link to comment

don't get why didn't you use my on *:SIGNAL:mta.text:{ example.. but ok, thats your script:

on *:SIGNAL:mta.text: {
 if ($3 == brb) {
   if ($readini($scriptdir $+ brb.ini,BRB,$mta.ip($1,$2)) == 1) {
     mta.text $1 $mta.nick($1,$2) will be back soon!
     !writeini -n " $+ $scriptdir $+ brb.ini" BRB $mta.ip($1,$2) 2
   }
 }
 elseif ($readini($scriptdir $+ brb.ini,BRB,$mta.ip($1,$2)) == 2) {
   !writeini -n " $+ $scriptdir $+ brb.ini" BRB $mta.ip($1,$2) 1
   mta.text $1 $mta.nick($1,$2) is back!
 }
}
on *:SIGNAL:mta.join: {
 !writeini -n " $+ $scriptdir $+ brb.ini" BRB $mta.ip($1,$2) 1
}
on *:SIGNAL:mta.command:{
 if ($3 == !players) {
   var %a = 0,%b
   while (%a <= $mta.server($1).cmax) {
     if ($mta.nick($1,%a) != Unknown) %b = $iif(%b,%b $+ $chr(44) $mta.nick($1,%a),$mta.nick($1,%a))
     !inc %a
   }
   mta.text $1 Players: %b
 }
}

Edited by Guest
Link to comment
don't get why didn't you use my on *:SIGNAL:mta.text:{ example.. but ok, thats your script:

on *:SIGNAL:mta.text: {
 if ($3 == brb) {
   if ($readini($scriptdir $+ brb.ini,BRB,$mta.ip($1,$2)) == 1) {
     mta.text $1 $mta.nick($1,$2) will be back soon!
     !writeini -n " $+ $scriptdir $+ brb.ini" BRB $mta.ip($1,$2) 2
   }
 }
 elseif ($3 == *) {
   if ($readini($scriptdir $+ brb.ini,BRB,$mta.ip($1,$2)) == 2) {
     !writeini -n " $+ $scriptdir $+ brb.ini" BRB $mta.ip($1,$2) 1
     mta.text $1 $mta.nick($1,$2) is back!
   }
 }   
}
on *:SIGNAL:mta.join: {
 !writeini -n " $+ $scriptdir $+ brb.ini" BRB $mta.ip($1,$2) 1
}
on *:SIGNAL:mta.command:{
 if ($3 == !players) {
   var %a = 0,%b
   while (%a <= $mta.server($1).cmax) {
     if ($mta.nick($1,%a) != Unknown) %b = $iif(%b,%b $+ $chr(44) $mta.nick($1,%a),$mta.nick($1,%a))
     !inc %a
   }
   mta.text $1 Players: %b
 }
}

It was ment to give with !players a number (1/20 or just 1 for example) :wink: .

And on text brb it is doing well and ini is writin to 2 but on than on text f no message orso and ini stays on 2.

[EDIT] I already see the problem, in mIRC * is being seen as some kind of char. But i ment a random sentence or word.

:roll:

So how?

Link to comment

you dont need that 'if ($3 == *) {' line at all!.. the 'on *:SIGNAL:mta.text:{' is called when player says something, so you dont need to check if there is a word

on *:SIGNAL:mta.text: {
 if ($3 == brb) {
   if ($readini($scriptdir $+ brb.ini,BRB,$mta.ip($1,$2)) == 1) {
     mta.text $1 $mta.nick($1,$2) will be back soon!
     !writeini -n " $+ $scriptdir $+ brb.ini" BRB $mta.ip($1,$2) 2
   }
 }
 elseif ($readini($scriptdir $+ brb.ini,BRB,$mta.ip($1,$2)) == 2) {
   !writeini -n " $+ $scriptdir $+ brb.ini" BRB $mta.ip($1,$2) 1
   mta.text $1 $mta.nick($1,$2) is back!
 }
}
on *:SIGNAL:mta.join: {
 !writeini -n " $+ $scriptdir $+ brb.ini" BRB $mta.ip($1,$2) 1
}
on *:SIGNAL:mta.command:{
 if ($3 == !players) mta.text $1 There are currently $mta.server($1).players players on the server
}

Link to comment
you dont need that 'if ($3 == *) {' line at all!.. the 'on *:SIGNAL:mta.text:{' is called when player says something, so you dont need to check if there is a word

on *:SIGNAL:mta.text: {
 if ($3 == brb) {
   if ($readini($scriptdir $+ brb.ini,BRB,$mta.ip($1,$2)) == 1) {
     mta.text $1 $mta.nick($1,$2) will be back soon!
     !writeini -n " $+ $scriptdir $+ brb.ini" BRB $mta.ip($1,$2) 2
   }
 }
 elseif ($readini($scriptdir $+ brb.ini,BRB,$mta.ip($1,$2)) == 2) {
   !writeini -n " $+ $scriptdir $+ brb.ini" BRB $mta.ip($1,$2) 1
   mta.text $1 $mta.nick($1,$2) is back!
 }
}
on *:SIGNAL:mta.join: {
 !writeini -n " $+ $scriptdir $+ brb.ini" BRB $mta.ip($1,$2) 1
}
on *:SIGNAL:mta.command:{
 if ($3 == !players) mta.text $1 There are currently $mta.server($1).players players on the server
}

!players still doesn't work.

Link to comment
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...