mIRC Home    About    Download    Register    News    Help

Print Thread
Need some help to finish the script #218242 06/02/10 10:35 PM
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.
Re: Need some help to finish the script [Re: NSS] #218259 07/02/10 06:00 AM
Joined: Aug 2004
Posts: 7,252
R
RusselB Offline
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.

Re: Need some help to finish the script [Re: RusselB] #218302 08/02/10 04:26 PM
Joined: Oct 2004
Posts: 8,327
Riamus2 Offline
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,327
Other than that example 4 has "!player, which would throw off that change.


Invision Support
#Invision on irc.irchighway.net
Re: Need some help to finish the script [Re: Riamus2] #218323 09/02/10 07:13 AM
Joined: Aug 2004
Posts: 7,252
R
RusselB Offline
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.

Re: Need some help to finish the script [Re: NSS] #218518 16/02/10 01:42 PM
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 ? =)

Re: Need some help to finish the script [Re: Riamus2] #218519 16/02/10 02:20 PM
Joined: Oct 2004
Posts: 8,327
Riamus2 Offline
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,327
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
Re: Need some help to finish the script [Re: NSS] #218520 16/02/10 02:32 PM
Joined: Jun 2007
Posts: 933
5
5618 Offline
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),",)

Re: Need some help to finish the script [Re: NSS] #218521 16/02/10 02:46 PM
Joined: Nov 2006
Posts: 1,559
H
Horstl Offline
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))

Re: Need some help to finish the script [Re: NSS] #218526 16/02/10 09:47 PM
Joined: Feb 2009
Posts: 133
C
chacha Offline
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
Re: Need some help to finish the script [Re: chacha] #218530 17/02/10 12:06 AM
Joined: Oct 2004
Posts: 8,327
Riamus2 Offline
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,327
Look at his examples. Yours only works if nothing is before !player.


Invision Support
#Invision on irc.irchighway.net
Re: Need some help to finish the script [Re: Riamus2] #218562 17/02/10 09:22 PM
Joined: Feb 2009
Posts: 133
C
chacha Offline
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