mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Jun 2004
Posts: 291
W
Fjord artisan
OP Offline
Fjord artisan
W
Joined: Jun 2004
Posts: 291
i made this script that is a voice timer and i want it to time how long a selected person is voiced
and when there devoiced say the voice time
i managed to work that part out but the problem im having now
is
i made the script write the voicetime in a file
and the next time the user comes and gets voiced i want it to read 2 files
1 is if there name is a voice timer name which i have done so i dont need help with that
and second is there voice time
and i want to add the old voicetime in the txt file to the voice time they have now then overwrite that in a file
so i can see thier total voice time
overall thier time each day
pls help ?
code:
on *:TEXT:!Time &:#: {
if (!$read(c:\names.txt,w,$2)) {
/msg $chan $2 Is Now Being Timed On voice Time $2
/write c:\names.txt $2
}
else msg $chan $2 is already being timed! } }

on *:VOICE:#: {
if ($read(c:\names.txt,w,$vnick)) writeini voice.ini voice $vnick $ctime } }
on *:DEVOICE:#: {
if ($readini(voice.ini,voice,$vnick)) msg #c-t $vnick was voiced for: $duration($calc($ctime - $readini(voice.ini,voice,$vnick)))
write c:\voicetime.txt $duration($calc($ctime - $readini(voice.ini,voice,$vnick))) } }

i need this script working please help me
thankyou

Joined: Dec 2002
Posts: 788
C
Hoopy frood
Offline
Hoopy frood
C
Joined: Dec 2002
Posts: 788
Your script is very complicated for what your actually trying to achieve, by no means do you have to use this, but heres a more realistical coding.

This runs an alias and adds the voiced user to the database.

On *:VOICE:#:{
vtimechkfile
hadd voicetime $+($vnick,.vtime) $ctime
}

This runs an alias and checks if the users 'time of voice' is recorded it not, doesnt do anything, if it is, it calculates the difference in seconds, adds that difference to the total time and then echos in your screen the total they were voiced, changing 'echo -a' to 'msg $chan' will make it msg the channel as i'm sure your aware.

On *:DEVOICE:#:{
vtimechkfile
if ($hget(voicetime,$+($vnick,.vtime))) {
var %tmp = $calc($ctime - $hget(voicetime,$+($vnick,.vtime)))
.hinc voicetime $+($vnick,.total) %tmp
.hdel voicetime $+($vnick,.vtime)
echo -a * This time $vnick was voiced for $duration(%tmp,2) in total they have been voiced for $duration($hget(voicetime,$+($vnick,.total)))
}
}

This alias will check if the database exists, if not, will create it, then check if theres already entries (which are saved in a file, voicetime.hash in the mIRC directory), if so, loads them - and if the database already exists it will save your database to file so its always up-to-date.

alias vtimechkfile {
if (!$hget(voicetime)) {
hmake voicetime 5000
if ($isfile($mircdirvoicetime.hash)) { hload voicetime $+(",$mircdirvoicetime.hash,") }
}
else { hsave -o voicetime $+(",$mircdirvoicetime.hash,") }
}

Eamonn.

Joined: Jun 2004
Posts: 291
W
Fjord artisan
OP Offline
Fjord artisan
W
Joined: Jun 2004
Posts: 291
WOW,
that was great and it works perfectly like i wanted
thanks alot man
:P

Joined: Dec 2002
Posts: 788
C
Hoopy frood
Offline
Hoopy frood
C
Joined: Dec 2002
Posts: 788
Glad to hear and your welcome :tongue:

Eamonn.

Joined: Mar 2003
Posts: 21
N
Ameglian cow
Offline
Ameglian cow
N
Joined: Mar 2003
Posts: 21
Even that seems complicated... I would have just done it with /inc -c and $duration(%var) myself.

Joined: Dec 2002
Posts: 788
C
Hoopy frood
Offline
Hoopy frood
C
Joined: Dec 2002
Posts: 788
Yeah it would have "done" but i didnt do it because:

a) Their intensions were to store it to a file from the look of their script.

b) Using variables would have ment having 2 for each user in the channel in a big channel that would have been yuck (personal preference not to use many variables, and certainly no perminent ones)

c) Using /inc -c wouldnt have been practical (although would have worked) in a channel with 100 - more users as that would mean increasing a hundred variables every second.

d) Storing in an external file allows them to move the 'stats' to another location easily.

Eamonn.

Joined: Jun 2004
Posts: 291
W
Fjord artisan
OP Offline
Fjord artisan
W
Joined: Jun 2004
Posts: 291
1 more question, i want, now to make a trigger "!voicetime
nick "
so for e.g.:
<joe> !voicetime jimbo
<me>jimbos total voice time is bla bla
how can i mak eit msg the channel with the chosen nicks voicetime?
thanks


Link Copied to Clipboard