READ THE DIRRECTIONS below, write in your scripts name where I tell you to below, copy and paste this into your script, adjust as needed. I kinda ripped this out of my latest project, so if I didn't wipe all my script's specific material, sorry.
Essentially this is hash tables for dummies. This allows you have user set options for your script, that are read from a config file. Maksure you change the text between the <>s to whatever it tells you.
edit: I don't use global variables simply because mIRC only can handle one variable file at a time.
If this variable file is unloaded, or someone's script that loads its own variable file is loaded, my code would cease to function.
edit2: besides hash tables rock my socks off. just cut paste, and use the fucking identifiers.
edit: forgot, the custom identifiers $yourscrip_options(option)
and $yourscript_version(name|version|original file) are used to access your data.
;Open up your script in notepad when mIRC is not running, and just paste and edit
[version]
version=<your script's version>
name=<your script's name>
[extconf]
extconf=<your script's name>.conf
;---Open up mIRC, and paste everything below this in with the script editor in MIRC.-----
alias <yourscriptname>_version {
if ( $1 == $null ) || ( $1 == version ) { return $hget(crypt_version,version) }
elseif ( $1 == name ) { return $hget(crypt_version,name) }
elseif ( $1 == originalfile ) { return $hget(crypt_version,originalfile) }
else { return ERR }
}
alias <yourscriptname>_options.rehash {
var %int
var %word rehashing
if ( $1 == --int ) { set %int $true | set %word initializing | goto start }
:dump
hfree <yourscriptname>_version
hfree <yourscriptname>_options
; this is for un-hashing your options for unloading
if ( $1 == --free ) { echo -sqe freed | halt }
:start
.remote on
;hashing conf
:hash
hmake <yourscriptname>_version 3
hadd <yourscriptname>_version version $readini( $script ,n,version,version)
hadd <yourscriptname>_version name $readini( $script ,n,version,name)
hadd <yourscriptname>_version originalfile $readini( $script ,n,version,originalfile)
; Uncomment this if you want your script name echoed in local on load/rehash
; echo -qs *** <yourscriptname> v $+ $hget(<yourscript>_version,version) %word
;making options table
hmake crypt_options 5
var %extconf $readini( $script ,n,extconf,extconf)
hadd <yourscriptname>_options extconf %extconf
;add a new line for everything option you have, cut and paste, the replace the <option#>
: with what options you have in your conf file.
hadd <yourscriptname>_options <option1> $readini( %extconf ,n,options,<option1>)
hadd <yourscriptname>_options <option2> $readini( %extconf ,n,options,<option2>)
hadd <yourscriptname>_options <option3> $readini( %extconf ,n,options,<option2>)
; echo -qs -
halt
}
alias <yourscriptname>_options {
; this is an alias for an identifier $<yourscriptname>_options(<your_option>), so you can
; easily use them in your script
; just type the options you have made in the conf file in below, seperated by a space.
; all items in text will return their values, binary options return $true for 1 and $false
; for 0. If you don't know, put it in text options
var %textoptions <options that return text goes here>
var %binaryoptions <options that are either a on/off true/false 0/1 aka binary go here>
if ( $1 isin %binaryoptions ) {
if ( $hget(<yourscriptname>_options, $1 ) == 0 ) { return $false }
elseif ( $hget(<yourscriptname>_options, $1 ) == 1 ) { return $true }
else { return ERR }
}
elseif ( $1 isin %textoptions ) { return $hget(<yourscriptname>_options, $1 ) }
else { return 1 }
}
;----most important part---;
;if you already have on load command, just copy and past the contents
;if you don't just copy it all.
on 1:load:{
; the --int doesn't try and free the hash tables first which causes a crash
<yourscriptname>_options.rehash --int
}