|
Joined: May 2011
Posts: 4
Self-satisified door
|
OP
Self-satisified door
Joined: May 2011
Posts: 4 |
Straight to the point. This is the code on *:TEXT:!player*:#: {
if ($1 == %c $+ player) {
set %playerurl /daoc/sig.php?name= $+ $+($replace($2-,$chr(32),+),&txt=on)
set %playerchan $chan
playerlookup
}
}
alias playerlookup {
sockopen player herald.uthgard-server.net 80
}
on *:SOCKOPEN:player: {
sockwrite -nt $sockname GET %playerurl HTTP/1.1
sockwrite -nt $sockname Accept-Language: en-us
sockwrite -nt $sockname User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.2; rv:1.7.3) Gecko/20040913 Firefox/0.10.1
sockwrite -nt $sockname Host: herald.uthgard-server.net
sockwrite -nt $sockname Connection: keep-alive
sockwrite -t $sockname $str($crlf,2)
}
on *:SOCKREAD:player:{
if ($sockerr > 0) { return }
:nextread
sockread %player
if ($sockbr == 0) { return }
if (%player == [player]) { set %playerget on | goto nextread }
if (%playerget) {
var %playerinfo = $gettok(%player,1,61)
var %playerdata = $gettok(%player,2,61)
if (%playerinfo == name) && (!%playerdata) { sockclose player | unset %player* }
set %player $+ %playerinfo %playerdata
}
goto nextread
}
on *:SOCKCLOSE:player:{
if (!%playernull) { .msg %playerchan %playername %playerlastname - %playerlevel %playerrace %playerclass ( $+ %playerguild $+ ) - RR %playerrealmlevel }
unset %player*
} output is: <@Celest> !player Hymnia <+TestBot> Hymnia - (Clan Cotswold) - 6 Highlander Ministrel - RR 1.0 but <[Uth]Guildbot> Marzena: "!player Hymnia" we get no response at all, which is mainly how we WANT it to work as... how i can make it work? :S any help will be greatly appreciated
|
|
|
|
Joined: Jan 2007
Posts: 1,156
Hoopy frood
|
Hoopy frood
Joined: Jan 2007
Posts: 1,156 |
Probably not the best way, but this is how I did it. on *:TEXT:*:#: {
if ($1 == $+(%c,player)) {
var %name = $replace($2-,$chr(32),+)
if ($sock(player)) sockclose player
sockopen player herald.uthgard-server.net 80
sockmark player # $+(/daoc/sig.php?name=,%name,&txt=on)
}
}
on *:SOCKOPEN:player:{
sockwrite -nt $sockname GET $gettok($sock(player).mark,2,32) HTTP/1.1
sockwrite -nt $sockname Accept-Language: en-us
sockwrite -nt $sockname User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.2; rv:1.7.3) Gecko/20040913 Firefox/0.10.1
sockwrite -nt $sockname Host: herald.uthgard-server.net
sockwrite -nt $sockname Connection: keep-alive
sockwrite -t $sockname $str($crlf,2)
}
on *:SOCKREAD:player:{
if ($sockerr > 0) { return }
var %p_
sockread %p_
if ($numtok(%p_,61) = 2) { set -e $+(%,p.,$gettok(%p_,1,61)) $gettok(%p_,2,61) }
}
on *:sockclose:player:{
msg $gettok($sock(player).mark,1,32) %p.name - $+($chr(40),%p.guild,$chr(41)) - %p.level %p.race %p.class - RR %p.realmlevel
unset %p.*
} This actually makes a variable for every line of data in the file that has the format: item=data The variable is named %p.<item>. So name=Hymnia would be %p.name = Hymnia. It unsets the variables when the socket closes.
|
|
|
|
Joined: Jul 2006
Posts: 4,180
Hoopy frood
|
Hoopy frood
Joined: Jul 2006
Posts: 4,180 |
I know that how he explained the problem is unclear, but you can get from his post that the problem is that they have another bot displaying text of person from another channel, prefixing these messages by the nickname, making $1 not being !player (or %c $+ player here) but he wants it to work in both case
Btw, his code was using a goto loop to perfom a sockread while there's data to read (a while loop is better but that's not the point), which is faster than letting retriggering the event, as said in the help file, you removed that. Also his code was already working with variable's name based on "item" name, and you removed the condition that will close the socket if a line isn't formated correctly, in that case your code will still send a msg with empty values
Last edited by Wims; 13/05/11 09:30 PM.
#mircscripting @ irc.swiftirc.net == the best mIRC help channel
|
|
|
|
Joined: May 2011
Posts: 4
Self-satisified door
|
OP
Self-satisified door
Joined: May 2011
Posts: 4 |
[font:verdana] well, some examples: 1- nothing before ! = work [10:32] <@Olaoc> !player hymnia [10:32] <TestBot> Hymnia - (Clan Cotswold) - 6 Highlander Ministrel - RR 1.0 2- letters before ! = doesnt work [10:32] <@Olaoc> sdfgh!player hymnia 3- punctuation before ! = doesnt work [10:32] <@Olaoc> .!player hymnia 4- space before ! = doesnt work [10:32] <@Olaoc> !player hymnia im guessing i need it to work with characters before the !player command for it to work with <[Uth]Guildbot> Marzena: "!player Hymnia" because of the "!player right? but i dont know how to thank you [/font]
|
|
|
|
Joined: Jan 2007
Posts: 1,156
Hoopy frood
|
Hoopy frood
Joined: Jan 2007
Posts: 1,156 |
The code actually didn't work for a few reasons. You are very welcome to give him code that you like. I just made his code work as a fast as i could.
|
|
|
|
Joined: Jan 2007
Posts: 1,156
Hoopy frood
|
Hoopy frood
Joined: Jan 2007
Posts: 1,156 |
Your code said
on *:text:!player*:#:{
This means that it will only work if the type !player name. It won't work if they type "Hello !player name." Or anything else before !player.
What do you want people to type to find out their player status?
|
|
|
|
Joined: May 2011
Posts: 4
Self-satisified door
|
OP
Self-satisified door
Joined: May 2011
Posts: 4 |
i want !player
that is whats typed here <[Uth]Guildbot> Marzena: "!player Hymnia"
but it wouldnt work because of the " before it im guessing preferably, if possible, id want it to work with anything before the ! like if we said 'hello !player name' i know thats possible to do because ive had access to some other before that worked like that, but i dont know how to make that
|
|
|
|
Joined: Nov 2006
Posts: 1,559
Hoopy frood
|
Hoopy frood
Joined: Nov 2006
Posts: 1,559 |
Give this a try (untested): on *:TEXT:*:#: {
; check if $1- contains any token ("word") that wildmatches "*<cmdchar>player"
if ($wildtok($1-,$+(*,%c,player),1,32)) {
; fill $1- with the unquoted text message starting at that token
tokenize 32 $noqt($gettok($1-,$+($findtok($1-,$v1,1,32),-),32))
; rest of your original on text event
set %playerurl /daoc/sig.php?name= $+ $+($replace($2-,$chr(32),+),&txt=on)
set %playerchan $chan
playerlookup
}
} Yes, I'm well aware this could be solved in a more classy fashion with regular expressions...
|
|
|
|
Joined: Jul 2006
Posts: 4,180
Hoopy frood
|
Hoopy frood
Joined: Jul 2006
Posts: 4,180 |
The code actually didn't work for only one reason: there's a bot relaying messages from another channel, the relayed message are of the form nickname message, the matchtext of the on text event is expecting %c $+ player as the first word, which is obviously not possible in that case, he wanted the code to work in both situation. You clearly missed that part and I was pointing it out
#mircscripting @ irc.swiftirc.net == the best mIRC help channel
|
|
|
|
Joined: May 2011
Posts: 4
Self-satisified door
|
OP
Self-satisified door
Joined: May 2011
Posts: 4 |
Thank you so much for your time! works perfectly! =)
|
|
|
|
|