mIRC Home    About    Download    Register    News    Help

Print Thread
#254949 10/09/15 09:44 PM
Joined: Dec 2014
Posts: 68
M
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...

Joined: Jan 2004
Posts: 1,358
L
Hoopy frood
Offline
Hoopy frood
L
Joined: Jan 2004
Posts: 1,358
I already told you not to use tabs

Joined: Jan 2005
Posts: 192
Vogon poet
Offline
Vogon poet
Joined: Jan 2005
Posts: 192
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
Brax #254954 10/09/15 10:38 PM
Joined: Dec 2014
Posts: 68
M
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

Joined: Dec 2013
Posts: 779
N
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
Joined: Jan 2005
Posts: 192
Vogon poet
Offline
Vogon poet
Joined: Jan 2005
Posts: 192
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

Link Copied to Clipboard