mIRC Home    About    Download    Register    News    Help

Print Thread
multiple hash tables, losing data,almost giving up #261562 19/10/17 06:09 AM
Joined: Oct 2017
Posts: 8
G16 Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
Joined: Oct 2017
Posts: 8
I have so many questions, nothing ever works, anyone willing to discord?

Quote:

on *:load: {
/hmake tempHash ; <-- only the 1st line work same using aliases
/hmake score
/hload score score.ini
}


on *:text:!guess *:#:{
if ($regex($2,^[1-9]$)) {<-- this is fine thanks god like, doing the regex was the easiest part... how.
/hadd -s tempHash $nick $2- <-- this sometimes work, sometimes not ?? since on load stuff is not working correctly i use this /hadd -sm so it create the table on the fly
}
}

on *:text:!winner *:#:{
set %i 1
set %nwin $hfind(tempHash, $2-,0).data
while ( %i <= %nwin ) {
set %wname $hfind(tempHash, $2-, %i).data <-maybe I don't really need this line
if ($hfind(score, %wname, 1)) {
set %points $hget(score, %wname)
/hadd -s score %wname $calc(%points + 500)
}
else {
/hadd -s score %wname 500
}
inc %i
}
/hfree tempHash
/hsave -i score score.ini <-- after I restart mirc this overwrite the file losing data no matter if I -a
}


honestly i don't even understand this post you know, it's just so many things that work on other people scripts but never work on my end, like I copy and paste a dude's script, it doesn't work as intended, almost like if I had a outdated version of mirc (using latest actually) or... idk man, if you can't understand where I need the help I will try to break things line per line. I almost giving up and moving on, I never had to ask help on forums when learning other languages.

Re: multiple hash tables, losing data,almost giving up [Re: G16] #261563 19/10/17 06:26 AM
Joined: Jan 2004
Posts: 1,187
maroon Offline
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2004
Posts: 1,187
Well, one thing I see is that you save the score file using the -i switch, but you load it without the -i switch. That could be why your score file appears to get trashed.

Re: multiple hash tables, losing data,almost giving up [Re: maroon] #261564 19/10/17 07:25 AM
Joined: Oct 2017
Posts: 8
G16 Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
Joined: Oct 2017
Posts: 8
yeah, I tried that but sometimes it just delete the old data, other times it adds a "[hashtable]= %wname=xxx. Like I dont add or remove anything from the script, I just use another account to trigger the commands.

Thanks tho man, I appreciate your help

Re: multiple hash tables, losing data,almost giving up [Re: G16] #261565 19/10/17 09:22 AM
Joined: Feb 2003
Posts: 2,650
Raccoon Offline
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2003
Posts: 2,650
On Load only happens the one time in your lifetime, and that's when you first load the script into mIRC. You want to use On Start instead.


Well. At least I won lunch.
Good philosophy, see good in bad, I like!
Re: multiple hash tables, losing data,almost giving up [Re: Raccoon] #261573 19/10/17 05:36 PM
Joined: Oct 2017
Posts: 8
G16 Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
Joined: Oct 2017
Posts: 8
Thanks man, every help matters, anything you guys can see it's wrong or there's a better way to do, feel free to comment about

Re: multiple hash tables, losing data,almost giving up [Re: G16] #261578 19/10/17 10:27 PM
Joined: Oct 2017
Posts: 8
G16 Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
Joined: Oct 2017
Posts: 8
Ok, once again thanks guys, after a lot of cigarettes, cleaning mirc files and reinstalling I made all that stuff to work.
But now I discovered that my regex actually sux and "normal"/"as much as I know" regex doesn't quite work.
What I need is a way to only accept numbers between 1 and 22
ugly code that I have now:
Quote:
If ($regex($2,1|2|3|4|5|6|7|8|9|10|11|12|13|14|15|16|17|18|19|20|21|22)) {
/hadd -si tempH $nick $2-

I also want to make this command available only during a certain amount of time, the plan is to:
Quote:
ON *:TEXT:!StartGame *:#: {
"/msg Game has started, use !guess N to play"
"make !guess command available during X seconds"


I'm almost done finally

Re: multiple hash tables, losing data,almost giving up [Re: G16] #261579 19/10/17 11:15 PM
Joined: Jan 2004
Posts: 1,187
maroon Offline
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2004
Posts: 1,187
This seems to work, though it doesn't accept leading zeroes:

//var %x ^([1-9]|2[1-2])$ | echo -a $regex(22,%x)

Re: multiple hash tables, losing data,almost giving up [Re: maroon] #261580 19/10/17 11:48 PM
Joined: Oct 2017
Posts: 8
G16 Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
Joined: Oct 2017
Posts: 8
Lol I did that and didn't worked now I just cleaned the files on the mirc folder again, guess what, it worked...
Can't thank you enough tho, you're always here to help people <3