mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Oct 2009
Posts: 4
N
NSS Offline OP
Self-satisified door
OP Offline
Self-satisified door
N
Joined: Oct 2009
Posts: 4
So this is the script i need help with:


on *:text:*!player *:#: {
if ($sock(!player)) .sockclose !player
set %heraldchan $chan
set %heraldnick $nick
set %heraldplayer $2
sockopen !player herald.uthgard-server.net 80
}
on *:SOCKOPEN:!player: {
sockwrite -nt $sockname GET /herald.php?view=stats&p1=player&p2=Player&p3=DESC&p5=Player&p6= $+ %heraldplayer HTTP/1.1
sockwrite -nt $sockname Host: herald.uthgard-server.net
sockwrite -nt $sockname $crlf
}
on *:SOCKREAD:!player: {
if ($sockerr) {
msg %chan Socket Error: $sockname $+ . Error code: $sockerr Please inform $me of this error message.
halt
}
else {
var %sockreader
sockread %sockreader
if (*Realmrank* iswm %sockreader ) {
set %heraldplayer1 $remove($nohtml(%sockreader),Realmrank)
msg %heraldchan .g That player is RR %heraldplayer1
unset %heraldchan %heraldnick %heraldplayer %heraldplayer1
sockclose !player
}
}
}

The problem is that the bot cant understand a command line after SPACE

Example1 (Working):
[00:31] <[NSS]Ati> !player Crossfire
[00:31] <[NSS]HeraldBot> .g That player is RR 8L1

Example2 (Working):
[00:32] <[NSS]Ati> nospacehere!player Dwain
[00:32] <[NSS]HeraldBot> .g That player is RR 6L1

Example3 (Not Working):
[00:32] <[NSS]Ati> hereisspace !player Ati
No responce by bot

Example4 (Not Working):
[00:31] <[Uth]Guildbot2> Dwain: "!player ati"
No responce by bot

So as i want to make the heraldbot compatible with with game via IRC and there game bot leaves SPACE between text then i cant get it work.

A help would be a priciated =)

Best Regards,
NSS-HeraldBot

Last edited by NSS; 06/02/10 10:35 PM.
Joined: Aug 2004
Posts: 7,252
R
Hoopy frood
Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
that's because the space character makes the !player command in $2 thus the rest of the information becomes $3, $4, $5, etc.

It gets worse if you had multiple words before the !player command.

Try replacing the first 2 lines of your ON TEXT event with
Code:
on *:text:*!player*:#:{
  var %player = $findtok($1-,!player,1,32)
  %player = $+($,%player,-)
  tokenize 32 %player
  if ($sock(!player)) .sockclose !player

That will force the script to see !player as the first word ($1) no matter where it actually occurs in the sentence.

Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
Other than that example 4 has "!player, which would throw off that change.


Invision Support
#Invision on irc.irchighway.net
Joined: Aug 2004
Posts: 7,252
R
Hoopy frood
Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
True.. I missed that quotation mark.

Too late to try to think about re-writing the code to handle that (or similar) situations.

Joined: Oct 2009
Posts: 4
N
NSS Offline OP
Self-satisified door
OP Offline
Self-satisified door
N
Joined: Oct 2009
Posts: 4
Any else want to help ? =)

Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
Well, you can strip off anything before !player by using $left() and $pos(). Use $pos() to get the position of !player and use $left() to remove everything before the value $pos() returns. Then, strip off quotation marks and tokenize the results. This will once again make $2 the correct value.

I can't test this and don't make much use of $pos(), so it likely has errors, but this is the basic idea:

Code:
on *:text:*!player*:#: {
  var %pos = $pos($1-,!player)
  var %text = $left($1-,- $+ %pos)
  tokenize 32 %text
  if ($sock(!player)) .sockclose !player
  set %heraldchan $chan
  set %heraldnick $nick
  set %heraldplayer $2
  sockopen !player herald.uthgard-server.net 80
}

Last edited by Riamus2; 16/02/10 02:21 PM.

Invision Support
#Invision on irc.irchighway.net
Joined: Jun 2007
Posts: 933
5
Hoopy frood
Offline
Hoopy frood
5
Joined: Jun 2007
Posts: 933
Or a quick and dirty way if your only problem is words in front and quotes:

Code:
set %heraldplayer $replace($($+($,$calc($findtok($replace($1-,",),!player,1,32)+1)),2),",)

Joined: Nov 2006
Posts: 1,559
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Nov 2006
Posts: 1,559
Or (more token fun)
Code:
set %heraldplayer $$noqt($gettok($1-,$calc($findtok($1-,$wildtok($1-,*!player,1,32),1,32) +1),32))

Joined: Feb 2009
Posts: 133
C
Vogon poet
Offline
Vogon poet
C
Joined: Feb 2009
Posts: 133
hi
Originally Posted By: NSS
The problem is that the bot cant understand a command line after SPACE

u have to remove "!player" from event and put it into a condition like this

Code:
on *:text:*:#:{
  if $2 && $strip($1) == !player {
    if ($sock($v1)) .sockclose $v1
    set %heraldchan $chan
    set %heraldnick $nick
    set %heraldplayer $2
    sockopen !player herald.uthgard-server.net 80
  }
}


try it

Last edited by chacha; 16/02/10 09:55 PM.

WorldDMT
Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
Look at his examples. Yours only works if nothing is before !player.


Invision Support
#Invision on irc.irchighway.net
Joined: Feb 2009
Posts: 133
C
Vogon poet
Offline
Vogon poet
C
Joined: Feb 2009
Posts: 133
ah i didnt saw " Dwain: "!player ati" "

so i use regex so try this

Code:
on *:text:*:#:{
  if $regex($1-,(!player) (\w+)) {
    if ($sock($regml(1))) .sockclose $v1
    set %heraldchan #
    set %heraldnick $nick
    set %heraldplayer $regml(2)
    sockopen !player herald.uthgard-server.net 80
  }
}



WorldDMT

Link Copied to Clipboard