mIRC Home    About    Download    Register    News    Help

Print Thread
#228523 26/12/10 10:33 PM
Joined: Dec 2010
Posts: 89
D
Babel fish
OP Offline
Babel fish
D
Joined: Dec 2010
Posts: 89
well, i have been learning to script recently, and im enjoying it laugh
the people i was learning scripts from use variables so i learnt that way, although my other friend came along and told me about using ini files etc...
i have to say, using ini files does seem better for me, i find it easier to store stats for my users, and its easier for me to script although im having a very silly problem

i never learnt how to remove txt from a txt file.

in my channel i have admins, so i have a !level [nick] command which enabled them admin status through an ini file. and im using a txt file to keep the list of admins, so when someone types !admins it shows the list ($read(admins.txt) it works fine

my !level command adds there name in my admins.txt file automatically and i wanted my !unlevel command to do the same, thats when i got stuck.

i dont know what the code is too remove a name from my list of admins...
i tried a couple of ways
e.g. remove admins.txt $2
but that deleted my whole list and the txt file with it.

can anyway tell me the code to remove $2 ($2 being the user ofc xD) from my txt file when i want to remove there admin status by doing !unlevel.
everything else works i just want it to remove there name from the admins list when i take admin status from them :>
(ps : i know this is a silly problem but i am a newish script )
thanks
-dom!

Last edited by dominic_eddy; 26/12/10 11:06 PM.
Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
If you are using text files, that's different from using ini files. For text files, check /help /write. It will tell you how to scan the file for the right line and then to delete that line. For ini files, you need to have them set up using the ini format and then you can use /help /remini to see how to remove specific parts of the file.

If you want to give a status to a user for specific commands, it's often better to use the Users tab to set users with a specific level that can be used. You can use a script to add or remove users from your Users tab. If you set the users at a numeric level and then include that level (or lower) in your events, that event will trigger for them. Anyone with a lower level than the event (or no level) won't be able to trigger it. You can also set a named level such as Admin so it's easier to keep track of what level user the person is. With named levels, only someone with that level can access the event.

Example events:
on Admin:text:*:#: { }
on 100:text:*:#: { }

To see the various commands related to the Users tab, see: /help /auser

Using the Users tab just tends to work better for that sort of thing, but if you prefer a text/ini format instead, you can also choose that method.

Also, variables aren't bad depending what you're doing. If you have a lot of settings, then a file is a good option. If you have few settings, maybe variables will be a better option. There are also hash tables for large numbers of settings and other data that will be changing frequently (hash tables are much faster than constantly reading/writing to a file).


Invision Support
#Invision on irc.irchighway.net
Joined: Dec 2010
Posts: 89
D
Babel fish
OP Offline
Babel fish
D
Joined: Dec 2010
Posts: 89
great i managed to get it removing the name laugh thanks for the help
and thanks for the advise smile

-dom!

Last edited by dominic_eddy; 27/12/10 01:25 AM.
Joined: Jul 2007
Posts: 1,129
T
Hoopy frood
Offline
Hoopy frood
T
Joined: Jul 2007
Posts: 1,129
Remove a line of string from a text file is very easy. Here is an example of using $readn to return the line number with the -dl# switch.
Code:
alias rem {
 if ($read(file.txt,w,$$1)) {
 write $+(-dl,$readn) file.txt
}
I don't know how you set up your text file, but if you put the names line by line, the example should work.
Code:
/rem NickHere
to delete.


Link Copied to Clipboard