mIRC Homepage
Posted By: michaelukz Twitch warn system (Need fixing) - 31/01/15 08:07 AM
Ok, I am currently stuck on a little thing I am working on, As the title entails, its a 'warning' system, Basically when someone types !warn <user> it will either warn them or say you need to input a name if you have set it to null, another feature !rwarn you can add a reason for warning someone, it can go up to as many words as you wish, if you want to copy, by default it has 10 words max this feature also has a timestamp with date. (thanks to sakana) The final feature is !listwarns <user> where it tell you how many warnings the user has.

Here is my main problem which I don't see what's going wrong. In the 'console' it inputs this

Code:
/writeini: insufficient parameters (line 21, script3.ini)


Code:
// Add warnings to a player
ON 5:TEXT:!warn*:#: {
  var %user = $2
  var %add = 1
  var %val = $readini(warns.ini, %user, warnings)
  writeini -n warns.ini %user warnings $calc(%val + %add)
  if (%val($2) == 3) {
    msg $chan %user has had the maximum warnings!  Timing out the %user
    msg $chan /timeout 600 $2
  }
  else (%user)
  msg $chan %user has been warned
  writeini -n warns.ini %user warnings $calc(%val + %add)
  timeout 1
}

// On join load warnings
ON *:JOIN:#: {
  var %user = $nick
  var %val = $readini(warns.ini, %user, warnings)
  writeini -n warns.ini %user warnings %val
}

// Add warning reason plus time
ON 4:TEXT:!rwarn*:#: { 
  var %user = $2
  var %date = Day: $day Date: $date Time: $time 
  var %reason = $3 $4 $5 $6 $7 $8 $9 $10
  writeini -n rwarn.ini %user timestamp %date Reason %reason
}


That is my full code (discluding the !listwarns), I have several issues (Keep in mind, most thing's I have made is with help.), For starters when someone types for example "!warnlist michaelukz" it outputs '
michaelukz has been warned'

This is what I wish for main help with >

Code:
// On join load warnings
ON *:JOIN:#: {
  var %user = $nick
  var %val = $readini(warns.ini, %user, warnings)
  writeini -n warns.ini %user warnings %val
}
< That outputs the first error
Code:
/writeini: insufficient parameters (line 21, script3.ini)


The other problem with this batch is the else's do not seem to work at all.
Posted By: michaelukz Re: Twitch warn system (Need fixing) - 31/01/15 08:09 AM
Here is my !listwarns commands

Code:
// Checks warnings
ON 3:TEXT:!listwarns $:#: {
  var %user = $2
  var %warns = $readini(warns.ini, %user, warnings)
  if (%user) == null {
    msg $chan Please type a users name!
  }
  else { 
    msg $chan /me $2 has %warns warnings!
  }
}


Currently it seems to do nothing also, I had it working but I wished to add the if and else, and it seemed to break, Again this is my first time with if and else statements
Posted By: Sakana Re: Twitch warn system (Need fixing) - 31/01/15 09:08 AM
Try this guide

http://en.wikichip.org/wiki/mirc/commands/writeini

Also seems like you have some wrong syntax.

For example
Code:
else (%user)


Do you mean
Code:
elseif (%user) {
?
Posted By: michaelukz Re: Twitch warn system (Need fixing) - 01/02/15 02:01 AM
Everything works except the alert

Code:
// Add warnings to a player
ON 5:TEXT:!warn*:#: {
  var %user = $2
  var %add = 1
  var %val = $readini( warns.ini, %user, warnings )
  writeini -n warns.ini %user warnings $calc(%val + 1)
  if (%val == $3) { msg $chan %user has had the maximum warnings! }
  elseif (%user) {
    msg $chan %user has been warned
    writeini -n warns.ini %user warnings $calc( %val + 1 )
  }
}
Posted By: judge2020 Re: Twitch warn system (Need fixing) - 01/02/15 02:25 AM
Code:
  if (%val == $3) { msg $chan %user has had the maximum warnings! }

maybe that's supossed to be 3?
Code:
  if (%val == 3) { msg $chan %user has had the maximum warnings! }
Posted By: michaelukz Re: Twitch warn system (Need fixing) - 01/02/15 02:48 AM
I had had it at 3 and yet it still did nothing so was testing if it was similiar to $null not null
Posted By: Belhifet Re: Twitch warn system (Need fixing) - 01/02/15 07:05 PM
Originally Posted By: michaelukz
Everything works except the alert

Code:
// Add warnings to a player
ON 5:TEXT:!warn*:#: {
  var %user = $2
  var %add = 1
  var %val = $readini( warns.ini, %user, warnings )
  writeini -n warns.ini %user warnings $calc(%val + 1)
  if (%val == $3) { msg $chan %user has had the maximum warnings! }
  elseif (%user) {
    msg $chan %user has been warned
    writeini -n warns.ini %user warnings $calc( %val + 1 )
  }
}

Its worth noting that you are setting %val before incriminating the number of warns that the person has received.

Also the if/elseif are weird. What are you actually attempting to do here?
Posted By: michaelukz Re: Twitch warn system (Need fixing) - 02/02/15 01:19 AM
Code:
if (%val == $3) { msg $chan %user has had the maximum warnings! }
  elseif (%user) {
    msg $chan %user has been warned
    writeini -n warns.ini %user warnings $calc( %val + 1 )
  }
}


The if being if it has more than 3 warnings message "%user has had the maximum warnings!" else just add one to the warnings.
Posted By: michaelukz Re: Twitch warn system (Need fixing) - 03/02/15 03:08 AM
*Bump*
Posted By: michaelukz Re: Twitch warn system (Need fixing) - 04/02/15 04:39 AM
*Rebump*

Anyone got a fix?
Posted By: Belhifet Re: Twitch warn system (Need fixing) - 04/02/15 05:12 AM
if (%val >= 3) { msg $chan %user has had the maximum warnings! }
else {
© mIRC Discussion Forums