mIRC Home    About    Download    Register    News    Help

Topic Options
#232011 - 13/05/11 09:01 PM Help if possible please =)
Olaoc Offline
Self-satisified door

Registered: 13/05/11
Posts: 4
Straight to the point.

This is the code

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 smile

Top
#232012 - 13/05/11 09:58 PM Re: Help if possible please =) [Re: Olaoc]
DJ_Sol Offline
Hoopy frood

Registered: 04/01/07
Posts: 1156
Loc: Seattle
Probably not the best way, but this is how I did it.

Code:
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.

Top
#232013 - 13/05/11 10:19 PM Re: Help if possible please =) [Re: DJ_Sol]
Wims Offline
Planetary brain

Registered: 31/07/06
Posts: 3462
Loc: France
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


Edited by Wims (13/05/11 10:30 PM)
_________________________
Looking for a good help channel about mIRC? Check #mircscripting @ irc.swiftirc.net

Top
#232021 - 14/05/11 10:44 AM Re: Help if possible please =) [Re: Wims]
Olaoc Offline
Self-satisified door

Registered: 13/05/11
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 smile[/font]

Top
#232023 - 14/05/11 06:01 PM Re: Help if possible please =) [Re: Wims]
DJ_Sol Offline
Hoopy frood

Registered: 04/01/07
Posts: 1156
Loc: Seattle
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.


Top
#232024 - 14/05/11 06:02 PM Re: Help if possible please =) [Re: Olaoc]
DJ_Sol Offline
Hoopy frood

Registered: 04/01/07
Posts: 1156
Loc: Seattle
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?

Top
#232025 - 14/05/11 06:43 PM Re: Help if possible please =) [Re: DJ_Sol]
Olaoc Offline
Self-satisified door

Registered: 13/05/11
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

Top
#232026 - 14/05/11 08:19 PM Re: Help if possible please =) [Re: Olaoc]
Horstl Offline
Hoopy frood

Registered: 03/11/06
Posts: 1559
Loc: Germany
Give this a try (untested):
Code:
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... wink

Top
#232028 - 14/05/11 09:59 PM Re: Help if possible please =) [Re: DJ_Sol]
Wims Offline
Planetary brain

Registered: 31/07/06
Posts: 3462
Loc: France
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 smile
_________________________
Looking for a good help channel about mIRC? Check #mircscripting @ irc.swiftirc.net

Top
#232029 - 14/05/11 10:30 PM Re: Help if possible please =) [Re: Horstl]
Olaoc Offline
Self-satisified door

Registered: 13/05/11
Posts: 4
Thank you so much for your time! works perfectly! =)

Top