mIRC Home    About    Download    Register    News    Help

Print Thread
#132078 07/10/05 12:44 PM
Joined: Oct 2005
Posts: 1
S
Mostly harmless
OP Offline
Mostly harmless
S
Joined: Oct 2005
Posts: 1
I am Making a IRPG dialog and I have come up with one problem...
In order to look at your total idled time, I need to look at a XML file on the webserver located here but I cannot get mIRC to interprate the file. any help?

#132079 07/10/05 01:19 PM
Joined: Nov 2003
Posts: 157
Vogon poet
Offline
Vogon poet
Joined: Nov 2003
Posts: 157
Have you tryied with the xml dll in www.scriptsdb.org or www.mirc.net?
I don't know if this dll can read xml file, but you can try :P

#132080 07/10/05 03:06 PM
Joined: Feb 2004
Posts: 2,019
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2004
Posts: 2,019
/*

Usage: /dejatoons <player>

If you don't specify a player, you will be prompted to enter one. If you still don't, the script halts. Note that the player's name is case sensitive, so if you specify "goldarrow111" the server will not give you the statistics, instead they will be empty. You must specify "GoldArrow111" exactly.

Once the script has downloaded the player statistics, all of it is stored in a hash table named after the player, in our example "Goldarrow111".

You can retrieve all of his stats with the identifier $dejatoons.get(player,category,property)

* Player = the nickname of the player, in our case GoldArrow111
* Category = player, penalties, or items
* Property = an attribute from a certain category, like "weapon" from the category "items"

Examples:

//echo -a $dejatoons.get(goldarrow111,player,level)
//echo -a $dejatoons.get(goldarrow111,penalties,kick)
//echo -a $dejatoons.get(goldarrow111,items,shield)

IMPORTANT: Once you've issued /dejatoons <player>, and the statistics are stored in the hash table, you need not issue the /dejatoons <player> command the whole time, since you can just get the stats from the hash table. This will decrease the load on the server, and gets results faster for you. It's your choice of course, though I would update the stats only once in a while.

The last person that you looked up statistics for is stored in the global variable %dejatoons.player
Normally I'd clean up this variable, but I think you might need it.

*/

Code:
alias dejatoons {
  var %player = $iif($0,$1,$input(Please specifiy a nickname (case-sensitive),eo))
  if (!$regex(%player,/[a-z]/)) {
    echo -ac info * /dejatoons: bad/missing playername
    return
  }
  if ($hget(%player)) hfree %player
  set %dejatoons.player %player
  sockclose dejatoons
  sockopen dejatoons betamaxstat.dejatoons.net 80
}
 [color:red]  [/color] 
on *:sockopen:dejatoons:{
  if ($sockerr) { echo -ac info * /dejatoons: error opening socket | return }
  var %s = sockwrite -tn $sockname
  %s GET /irpg/xml.php?player= $+ %dejatoons.player HTTP/1.0
  %s Host: betamaxstat.dejatoons.net
  %s
}
 [color:red]  [/color] 
on *:sockread:dejatoons:{
  if ($sockerr) return
  var %tmp, %sock = $sockname
  sockread %tmp
  tokenize 32 %tmp
  if ($regex(djt,$$1-,/^&lt;([a-z]+)&gt;$/)) set %dejatoons.category $regml(djt,1)
  elseif ($regex(djt,$1-,/^&lt;(.+?)&gt;(.*?)&lt;\/.+?&gt;$/)) {
    tokenize 32 $regml(djt,1) $regml(djt,2)
    ; $1 = tag, $2 = value
    if ($1- == username) {
      sockclose dejatoons
      echo -ac info * /dejatoons: incorrect username specified ( %dejatoons.player )
      unset %dejatoons.*
      return
    }
    dejatoons.add %dejatoons.player %dejatoons.category $1-
  }
}
[color:red]  [/color] 
on *:sockclose:dejatoons:{
  echo -ac info * /dejatoons: finished retrieving player info for %dejatoons.player
  unset %dejatoons.category
}
 [color:red]  [/color] 
alias dejatoons.add {
  ; 1 = hash table (player), 2 = category, 3 = tag, 4- = data
  hadd -m $1 $2 $addtok($hget($1,$2),$3:: $+ $4-,127)
}
 [color:red]  [/color] 
alias dejatoons.get {
  ; $dejatoons.get(player,category,property)
  return $gettok($wildtok($hget($1,$2),$3::*,1,127),2,58)
}


Gone.
#132081 07/10/05 03:56 PM
Joined: Feb 2004
Posts: 2,019
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2004
Posts: 2,019
In addition to my other post, if you really don't have a need to have all the information from a player in a hash table, and only want to do look up a value from the XML file, then you can use this code. This will always connect to the site and retrieve the value on the spot.

/*

Usage:

$dejatoonsxml(player, XST expression)

The XST expression is simply the path to the property that you want to look up.

Examples:

For the category "player":

/player/isadmin
/player/level
/player/userhost
...

For the category "penalties":

/player/penalties/kick
/player/penalties/part
/player/penalties/mesg
...

For the category "items":

/player/items/weapon
/player/items/shield
/player/items/gloves

Some quick examples:

//echo -a $dejatoonsxml(GoldArrow111, /player/totalidled)
//echo -a $dejatoonsxml(GoldArrow111, /player/penalties/kick)
//echo -a $dejatoonsxml(GoldArrow111, /player/items/shield)

Note that the player's name is still case sensitive, so the player "goldarrow111" does not exist.

*/

Code:
alias dejatoonsxml {
  var %e = echo -ac info * $!dejatoonsxml: 
  if (!$0) { %e No player specified | return }
  if (!$regex($2,/^(?:\/[a-z]+)+$/)) {
    %e Incorrect parameter: $2 
    %e Correct usage: /player[/category]/property
    %e Examples: /player/level, /player/penalties/kick, /player/items/shield
    return
  }
  var %objXML = objxml $+ $ticks, %objNode = objnode $+ $ticks, %tmp
  .comopen %objXML Msxml2.DOMDocument
  if ($comerr) return COM Error
  %tmp = $com(%objXML,async,4,bool,false)
  %tmp = $com(%objXML,load,1,bstr*,http://betamaxstat.dejatoons.net/irpg/xml.php?player= $+ $1)
  %tmp = $com(%objXML,selectSingleNode,1,bstr*,$2,dispatch* %objNode)
  if ($com(%objNode)) {
    %tmp = $com(%objNode,text,2)
    %tmp = $com(%objNode).result
    .comclose %objNode
  }
  .comclose %objXML
  return $iif(%tmp,%tmp,Error or no such player)
}


Gone.

Link Copied to Clipboard