mIRC Homepage
Posted By: michaelukz Search ini file for a name - 14/09/15 08:37 PM
Now I know this is simple
Code:
$readini(derp.ini, herps, $2/$nick)
However I know you can search for $null but how do you search if there IS a name IE return if there is a name there but else continue, Here is the code I am working on.

Code:
/////////////////
///Head Admin///
///////////////
on *:text:!hadmin:#: {
var %permstat = $readini(adminlist.ini, HeadAdmin)
  if (%permstat == $null) {
    msg $chan No Head Admin is set!
  }
  elseif (%permstat =)


As you can see I am stuck at that last part, How do I set it so that it's the opposite of null, IE not caring if his name is timmy or bob, if there is a HeadAdmin it will not continue, Any help?
Posted By: Wims Re: Search ini file for a name - 14/09/15 09:02 PM
That would be if (%permstat != $null), however, there is a concrete keyword to express the opposite of the condition you just made, 'else'
Code:
  if (%permstat == $null) {
    msg $chan No Head Admin is set!
  }
  else {
   msg $chan whatever %permstat
  }
Posted By: michaelukz Re: Search ini file for a name - 14/09/15 11:42 PM
Appreciate that, Hey Can you try and help with my code, I can't seem to get it to work,

Here:
Code:
/////////////////
///Head Admin///
///////////////
on *:text:!hadmin:#: {
  var %permstat = $readini(adminlist.ini, #Michaelukz, HeadAdmin)
  if (%permstat == $null) {
    msg $chan No Head Admin is set!
    if ($2 == $null) {
      msg $chan Error: Invalid use. !help hadmin
    }
    elseif (set isin $2) { 
      if ($3 == $null) { 
        msg $chan Error: No user selected
      }
      else {
        writeini adminlist.ini #Michaelukz HeadAdmin $3
      }
    }
  }
  else {
    msg $chan Error: There is already a Head-Admin
    .timer 1 2 msg $chan To continue to set an admin do /hadrem
  }
}


After this section it doesn't work:
Code:
on *:text:!hadmin:#: {
  var %permstat = $readini(adminlist.ini, #Michaelukz, HeadAdmin)
  if (%permstat == $null) {
    msg $chan No Head Admin is set!
    if ($2 == $null) {
      msg $chan Error: Invalid use. !help hadmin
    }


That all works fine. but after that... I just can't seem to debug it. smirk frown.
Posted By: michaelukz Re: Search ini file for a name - 16/09/15 03:41 AM
on *:text:*:#: {
msg $chan /me BUMP!
}
Posted By: Wims Re: Search ini file for a name - 16/09/15 02:44 PM
You can't bump a post after a day only lol, give people some times...

Your first on text event has a wildcard match on "!hadmin", this means the whole sentence must be "!hadmin", if that event trigger, there can't possibly be a second word, so $2 will always be $null, if you want to allow for an optional second word, well it can't be done with one wildcard match, it's nicely done with a regular expression:
Code:
on $*:text:/^!hadmin( .+)?/:#:{
now you can use $2..
If you want to check that $2 is stricly "set", you should use the '==' operator, not the 'isin' operator.


I think that should resolve all your issues, unsure though.
© mIRC Discussion Forums