mIRC Home    About    Download    Register    News    Help

Print Thread
#234396 23/10/11 10:53 AM
Joined: Jun 2011
Posts: 29
M
Ameglian cow
OP Offline
Ameglian cow
M
Joined: Jun 2011
Posts: 29
I'm trying to create a net-worth script for a game I play but I'm having trouble with it.

This is what I have

Code:
on *:text:*:#Accounts: {
  tokenize 32 $strip($1-6) $remove($strip($6),$chr(36),$chr(44))
  if ($1 == You) && ($2 == bought) && ($3 == the) && ($4-) && ($5 == for) && ($6 isnum) {   
    inc %Networth. $+ $nick $6
    msg $chan You have spent a total of
  }
}


So when a person copy's and pastes "You brought the Hammer for $75." it would save it and if they pasted it again it would add on to the total.

Any help is appreciated

Mumra_2790 #234397 23/10/11 11:00 AM
Joined: Jun 2011
Posts: 29
M
Ameglian cow
OP Offline
Ameglian cow
M
Joined: Jun 2011
Posts: 29
Sorry I should have explained that It does not work!?!?

Mumra_2790 #234400 23/10/11 12:25 PM
Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
You can simplify it like this:

Code:
on *:text:*:#Accounts: {
  tokenize 32 $strip($remove($1-6,$chr(36),$chr(44)))
  if ($1-3 == You bought the) && ($5 == for) && ($6 isnum) {   
    inc %Networth. $+ $nick $6
    msg $chan You have spent a total of $($+(%,Networth.,$nick),2)
  }
}


Note that your tokenize would have given you 12 items because you were adding the $remove text to the end after already adding all of the text. I simplified $1-3 into one and removed $4 because that is already required if you're checking $5 and $6. And the format for displaying a dynamic variable is shown on the message line.

That said, if you're going to have more than half a dozen nicks doing this, you're better off using an INI file instead of dynamic variables. Otherwise, you're going to have a LOT of variables and that really isn't the best way to store a lot of the same data.

Also, if the item being bought can be more than one word, you'll want to use something other than $6 to obtain the price because a two word item would move the price to $7 and so on. You can get the price if it's the last item by using $gettok($1-,$0,32), or you can use $regex to obtain it. $regex would be most useful if the price could be somewhere else in the text instead of only at the end.


Invision Support
#Invision on irc.irchighway.net

Link Copied to Clipboard