mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Jul 2014
Posts: 36
T
Ameglian cow
OP Offline
Ameglian cow
T
Joined: Jul 2014
Posts: 36
I have 2 ini files of the same format containing names of my viewers and their points.

viewername = points value
viewername = points value
etc...


Is there a way to combine these?

Joined: Dec 2013
Posts: 779
N
Hoopy frood
Offline
Hoopy frood
N
Joined: Dec 2013
Posts: 779
If you provide the name of the files and exactly what they look like, yes very much so.

I assume it's something like
File1.ini
[Points]
$nick1=12
$nick2=13
etc.

File2.ini
[Points]
$nick1=15
$nick2=19
etc

But I can't know for sure unless you tell me



Nillens @ irc.twitch.tv
Nillen @ irc.rizon.net
Joined: Jul 2014
Posts: 36
T
Ameglian cow
OP Offline
Ameglian cow
T
Joined: Jul 2014
Posts: 36

Joined: Dec 2013
Posts: 779
N
Hoopy frood
Offline
Hoopy frood
N
Joined: Dec 2013
Posts: 779
Code:
alias copy_coins { 
  echo -a Moving coins initialized
  var %file1 $qt(old coins.ini)
  var %file2 $qt(new coins.ini)
  var %sec #tylersgaming
  var %items $ini(%file1,%sec,0)
  while (%items) {
    var %item $ini(%file1,%sec,%items)
    var %value1 $readini(%file1,%sec,%item)
    var %value2 $readini(%file2,%sec,%item) 
    if (%value2) writeini %file2 %sec %item $calc(%value1 + %value2)
    else writeini %file2 %sec %item %value1
    dec %items
  }
  echo -a Moving coins finished
}
Type /copy_coins
If this freezes your mIRC application, let me know and I'll attempt doing it through an hashtable (never done this before)
By freezing I mean if you don't see the "Moving coins finished" echo and your mIRC stops responding. Give it some time though, you might have it done in 20 seconds if you just don't touch mIRC.


Nillens @ irc.twitch.tv
Nillen @ irc.rizon.net
Joined: Jul 2014
Posts: 36
T
Ameglian cow
OP Offline
Ameglian cow
T
Joined: Jul 2014
Posts: 36
2 questions where do I type /copy_coins

and how does it find my ini files since they're in drop box,

I tried typing /copy_coins in a lot of windows and it didn't create any files or anything. smirk

but yeah, it's not working ;-;

Last edited by TylersGaming; 15/11/14 03:49 PM.
Joined: Jul 2014
Posts: 36
T
Ameglian cow
OP Offline
Ameglian cow
T
Joined: Jul 2014
Posts: 36
im also getting this - http://puu.sh/cRMZU/c69f9f5a56.png

Joined: Dec 2013
Posts: 779
N
Hoopy frood
Offline
Hoopy frood
N
Joined: Dec 2013
Posts: 779
First of all, open your remote scripts editor by pressing alt + r, press file and create a new scriptfile. Paste the code I gave you in there.

After you've done that, change the var %file1 and %file2 to the actual path to the file. I assumed that the path to the file was standard inside your $mircdir, but just open the file's properties and change the filepath to the correct one. Should looks something like this: var %file1 $qt(c:\myuser\dropbox\old coins.ini)


Nillens @ irc.twitch.tv
Nillen @ irc.rizon.net
Joined: Dec 2013
Posts: 779
N
Hoopy frood
Offline
Hoopy frood
N
Joined: Dec 2013
Posts: 779
From what I can see in your private message, your code is flawed in the way that your last alias (as in the one prior to mine) does not have a closing bracket.
Code:
on *:TEXT:!on*:#:{
if ($nick == tylersgaming) {
if ($read(botstatus.txt,t,1) == on) {

}
if ( $read(botstatus.txt,t,1) == off) {
/write -c botstatus.txt
/timerAward 0 1800 /awardPoints $chan
write botstatus.txt on
msg $chan Points will now be awarded.
}
}
}

on *:TEXT:!off*:#:{
if ($nick == tylersgaming) {
if ($read(botstatus.txt,t,1) == off) {

}
if ( $read(botstatus.txt,t,1) == on) {
/write -c botstatus.txt
write botstatus.txt off
/timerAward off
msg $chan Points will no longer be awarded.
}
}
}

alias awardpoints {
var %chan = $$1, %table = coins. $+ %chan, %file = C:\Users\TylersGaming\Dropbox\coins.ini

if (!$hget(%table)) {
hmake %table
if ($ini(%file,%chan)) hload -i %table %file %chan
}

var %i = 1, %n = $nick(%chan,0)
while (%i <= %n) {
hinc %table $nick(%chan,%i)
inc %i
}

hdel %table nightbot
hdel %table tylerb0t
hdel %table tylersgaming

hsave -i %table %file %chan

alias copy_coins { 
echo -a Moving coins initialized
var %file1 $qt(old coins.ini)
var %file2 $qt(new coins.ini)
var %sec #tylersgaming
var %items $ini(%file1,%sec,0)
while (%items) {
var %item $ini(%file1,%sec,%items)
var %value1 $readini(%file1,%sec,%item)
var %value2 $readini(%file2,%sec,%item) 
if (%value2) writeini %file2 %sec %item $calc(%value1 + %value2)
else writeini %file2 %sec %item %value1
dec %items
}
echo -a Moving coins finished
}
Whenever your awardpoints alias gets triggered, you should have tons of error messages in your log.
As well as the fact that your coins.ini file seems out of place considering that your files you sent me are called "old coins.ini" and "new coins.ini" not "coins.ini" - Might be something to look up.


Nillens @ irc.twitch.tv
Nillen @ irc.rizon.net
Joined: Jul 2014
Posts: 36
T
Ameglian cow
OP Offline
Ameglian cow
T
Joined: Jul 2014
Posts: 36
idk what to do now ;-;

Joined: Dec 2013
Posts: 779
N
Hoopy frood
Offline
Hoopy frood
N
Joined: Dec 2013
Posts: 779
Originally Posted By: Nillen
First of all, open your remote scripts editor by pressing alt + r, press file and create a new scriptfile. Paste the code I gave you in there.

After you've done that, change the var %file1 and %file2 to the actual path to the file. I assumed that the path to the file was standard inside your $mircdir, but just open the file's properties and change the filepath to the correct one. Should looks something like this: var %file1 $qt(c:\myuser\dropbox\old coins.ini)


Do that.

After you've done that we're gonna look into adding a closing bracket to your other alias, but one thing at a time.


Nillens @ irc.twitch.tv
Nillen @ irc.rizon.net
Joined: Jul 2014
Posts: 36
T
Ameglian cow
OP Offline
Ameglian cow
T
Joined: Jul 2014
Posts: 36
ok i did this

Joined: Dec 2013
Posts: 779
N
Hoopy frood
Offline
Hoopy frood
N
Joined: Dec 2013
Posts: 779
Now, your alias for awarding points is not closed. From what you sent me it looks like this:
Code:
alias awardpoints {
var %chan = $$1, %table = coins. $+ %chan, %file = C:\Users\TylersGaming\Dropbox\coins.ini

if (!$hget(%table)) {
hmake %table
if ($ini(%file,%chan)) hload -i %table %file %chan
}

var %i = 1, %n = $nick(%chan,0)
while (%i <= %n) {
hinc %table $nick(%chan,%i)
inc %i
}

hdel %table nightbot
hdel %table tylerb0t
hdel %table tylersgaming

hsave -i %table %file %chan
It needs to looks like this:
Code:
alias awardpoints {
var %chan = $$1, %table = coins. $+ %chan, %file = C:\Users\TylersGaming\Dropbox\coins.ini

if (!$hget(%table)) {
hmake %table
if ($ini(%file,%chan)) hload -i %table %file %chan
}

var %i = 1, %n = $nick(%chan,0)
while (%i <= %n) {
hinc %table $nick(%chan,%i)
inc %i
}

hdel %table nightbot
hdel %table tylerb0t
hdel %table tylersgaming

hsave -i %table %file %chan
}
Note that the only change was the closing bracket at the end.

Make sure that the path to the file is correct too: %file = C:\Users\TylersGaming\Dropbox\coins.ini
I dunno what file you're currently using, but if you're using newcoins.ini, you need to change that.


Nillens @ irc.twitch.tv
Nillen @ irc.rizon.net
Joined: Jul 2006
Posts: 4,180
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,180
Quote:
Whenever your awardpoints alias gets triggered, you should have tons of error messages in your log.
Just a side note here, because you miss a { or a } doesn't mean everything will blow necessarily. Here, everything is executed as part of the alias:

Code:
alias copy_coins { 
echo -a Moving coins initialized
var %file1 $qt(old coins.ini)
....
This will be executed as a command, /alias is a command so that won't even produce an error, the { is going to be ignored the same way "//echo -a a { b" would


#mircscripting @ irc.swiftirc.net == the best mIRC help channel
Joined: Jul 2014
Posts: 36
T
Ameglian cow
OP Offline
Ameglian cow
T
Joined: Jul 2014
Posts: 36
thanks everyone smile


Link Copied to Clipboard