mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Feb 2009
Posts: 4
Z
ZomZee Offline OP
Self-satisified door
OP Offline
Self-satisified door
Z
Joined: Feb 2009
Posts: 4
Hi im currently working on a script for a turn based game that ppl can insert a number of turns they currently have and other ppl can to and it will total the amount of turns of everyone in the channel. Well i got the whole script to work except i need it to change when ever someone changes their name. So say someones name is Bob and has 20 turns then he changes his name to Bob|away i want it so the has table deletes the first entry of Bob 20 to Bob|away 20... this is the code i have so far but all it seems to do is delete the old name and insert the new one but with out the turn value. Please help if you can Thank you.

(and yes i new to IRC scripting)

on *:NICK: {
var %i = $hget(table,$nick)
if ($nick !ison #chan) {
hadd table $newnick %i
hdel table $nick
}
}

Joined: Feb 2009
Posts: 4
Z
ZomZee Offline OP
Self-satisified door
OP Offline
Self-satisified door
Z
Joined: Feb 2009
Posts: 4
Oh and i have another short question. This part goes to the same script. When ppl quit off the server i want it to delete the info out of the table. This is what i have so far but im not sure how to make it work just for ONE channel... here is the code:

on *:QUIT: {
if ($nick !ison #chan) {
msg #privatechan $nick has left and took their $hget(table,$nick) turns with them!
hdel table $nick

}

I tried to change #chan to the right channel name but then it seems to not work. And as of now that part works but it reads if anyone quits from any channel the bots in and messages that they left with turns even if they didn't have any added in the first place =/ any help would be appreciated.

Joined: Feb 2009
Posts: 4
Z
ZomZee Offline OP
Self-satisified door
OP Offline
Self-satisified door
Z
Joined: Feb 2009
Posts: 4
and of course i mean when someone quits it deletes the info for that certain person if they have turns added. Just wanted to clearify

Joined: Jul 2006
Posts: 4,150
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,150
I'm not sure why you're checking $nick !ison $chan.
Since the newnick is $newnick, then $nick can't be on the channel, I haven't tested but your condition is certainly true all the time, I would use :
Code:
on !*:NICK:{
if ($newnick ison #your_channel) && ($hget(table,$nick)) {
hadd table $newnick $v1
hdel table $nick
 }
}

I've added the ! prefix, only trigger the event for other people than $me and check for $newnick ison #chan.
For the on quit event it's basically the same but since we know that the nick isn't there anymore, you have to check for $comchan on $nick :

Code:
on !*:quit:{
var %a = $comchan($nick,0)
while (%a) {
if ($comchan($nick,%a) == #your_channel) && ($hget(table,$nick)) {
 hdel table $nick
 break
  }
dec %a
 }
}


#mircscripting @ irc.swiftirc.net == the best mIRC help channel
Joined: Feb 2009
Posts: 4
Z
ZomZee Offline OP
Self-satisified door
OP Offline
Self-satisified door
Z
Joined: Feb 2009
Posts: 4
Yeah well like i said im new to coding IRC so i was just trial and erroring it and that seemed to work just not the way i wanted =/ and i went from there.

Thx for the fix it worked like a charm smile


Link Copied to Clipboard