mIRC Home    About    Download    Register    News    Help

Print Thread
Writeini help #254949 10/09/15 09:44 PM
Joined: Dec 2014
Posts: 68
M
michaelukz Offline OP
Babel fish
OP Offline
Babel fish
M
Joined: Dec 2014
Posts: 68
Ok, So I am working on a script for simple mod commands and was wondering, is there a way to write to an ini file multiple sections IE this is the default example :
Code:
/writeini [-n] <inifile> <section> <item> <value>


This is my code:
Code:
on *:text:!ban*:#: {
	var %permUser == $2
	var %permSet == $readini(permlist.ini,#michaelukz,%permUser)
	if (permSet < 6) {
		msg $chan /me Error you do not have sufficient permissions!
		return
	}
	elseif ($2 == $null) {
		msg $chan /me Error No user selected
	}
	elseif ($3 == $null) {
		msg $chan Error no time selected
	}
	elseif ($4 == $null) {
		msg $chan /me No reason selected, writing default.
	}
	else {
		writeini -n BanList.ini #Michaelukz Bans $2 = 1:Reason: $4 Time:$3
		msg $chan /me User has been banned!
	}
}


It doesn't respond / do anything at all Here is the output from the SERVER not CHANNEL logs
Code:
VAR Unknown command
-
VAR Unknown command
-
IF Unknown command
-
MSG Unknown command
-
RETURN Unknown command
-
} Unknown command
-
ELSEIF Unknown command
-
MSG Unknown command
-
} Unknown command
-
ELSEIF Unknown command
-
MSG Unknown command
-
} Unknown command
-
ELSEIF Unknown command
-
MSG Unknown command
-
} Unknown command
-
ELSE Unknown command
-
WRITEINI Unknown command
-
MSG Unknown command
-
} Unknown command
-



Here is an example of what I wish it to look like in a ini file, but am unsure if it will work:"
[#Michaelukz]
BanList:
Bob=True:Reason:This was a test! Time:24hours
"

Any help?

In retrospect, I need to have the time BEFORE the reason but that I kinda derped on...

Re: Writeini help [Re: michaelukz] #254951 10/09/15 10:09 PM
Joined: Jan 2004
Posts: 1,302
L
Loki12583 Offline
Hoopy frood
Offline
Hoopy frood
L
Joined: Jan 2004
Posts: 1,302
I already told you not to use tabs

Re: Writeini help [Re: michaelukz] #254952 10/09/15 10:09 PM
Joined: Jan 2005
Posts: 188
Brax Offline
Vogon poet
Offline
Vogon poet
Joined: Jan 2005
Posts: 188
Make sure you are not indenting your code with TAB characters. (The example you have here uses tabs instead of spaces.)

As far as ini file goes, You can write as many sections as you want - just not in one line.
There is nothing that stops you using multiple /writeini commands in one alias.
Code:
/writeini file section1 item1 value1
/writeini file section2 item1 value1
/writeini file section2 item2 value2

You can't have subsections in inifile though, and it looks like you are trying to achieve that.
You could however go for different route and have one ini file per channel or have a section with name such as #Michaelukz-BanList


echo -a $signature
Re: Writeini help [Re: Brax] #254954 10/09/15 10:38 PM
Joined: Dec 2014
Posts: 68
M
michaelukz Offline OP
Babel fish
OP Offline
Babel fish
M
Joined: Dec 2014
Posts: 68
So It seems to be only writing down one of the ini's specifically the last
Code:
  else {
    writeini -n BanList.ini #Michaelukz $2 Banned
    writeini -n BanList.ini #Michaelukz $2 Reason $4
    writeini -n BanList.ini #Michaelukz $2 TimeBannedFor $3
    writeini -n BanList.ini #Michaelukz $2 BannedAt $time
    msg $chan /me User has been banned!
  }
}


Output: derrick=BannedAt 23:37:34

Re: Writeini help [Re: michaelukz] #254955 10/09/15 10:59 PM
Joined: Dec 2013
Posts: 779
N
Nillen Offline
Hoopy frood
Offline
Hoopy frood
N
Joined: Dec 2013
Posts: 779
You're overwriting the value of the item by each writeini.
It's better to save the $nick as the section instead of the item in this case, allowing you to use BannedAt as an item and $time as value.


Nillens @ irc.twitch.tv
Nillen @ irc.rizon.net
Re: Writeini help [Re: michaelukz] #254956 10/09/15 11:05 PM
Joined: Jan 2005
Posts: 188
Brax Offline
Vogon poet
Offline
Vogon poet
Joined: Jan 2005
Posts: 188
You are overwriting your items.
/writeini [-n] <inifile> <section> <item> <value>
In your case:
inifile is BanList.ini
section is #Michaelukz
item is always $2 (derrick)

Item names in the section need to be unique!

Currently you are doing following:
1) Set item derrick value to be Banned
2) Change item derrick value to be Reason $4
3) Change item derrick value to be TimeBannedFor $3
4) Change item derrick value to be BannedAt $time


echo -a $signature