mIRC Home    About    Download    Register    News    Help

Print Thread
#233267 30/07/11 11:42 AM
Joined: Jun 2011
Posts: 29
M
Ameglian cow
OP Offline
Ameglian cow
M
Joined: Jun 2011
Posts: 29
I have done some but it will not work to how i want it too.

on *:TEXT:*:#:{
if ($1-2 == You sent) {
if ($strip($3)) {
inc %TotalGiven. [ $+ [ $chan ] ] $calc(%TotalGiven. [ $+ [ $chan ] ] + $strip($3)) }
msg $chan I have added $3 to the total.... the total given away in $chan is $chr(36) $+ $comma(%TotalGiven. [ $+ [ $chan ] ])
}
}
}

It keeps returning this:

<&Dinky> I have added $1,000,000 to the total.... the total given away in #test is $

It wont show total or add it up. Any help is grateful!

Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
Code:
on *:text:*:#: {
  tokenize 32 $strip($1-)
  if ($1-2 == You sent && $3 isnum) {
    inc %TotalGiven. $+ $chan $3
    msg $chan I have added $chr(36) $+ $bytes($3,b) to the total.... the total given away in $chan is $chr(36) $+ $bytes($($+(%,TotalGiven.,$chan),2),b)
  }
}


That cleans it up some for you. Your real problem was that there isn't a $comma() identifier, so it will always be $null. To add commas, use $bytes(%number,b).

Some other things done...
  • First, I stripped the text using tokenize so there isn't a need to keep using $strip() throughout.
  • Second, I combined the two IF statements because you don't want to message the output if there isn't a valid $3.
  • Third, you don't need to use []'s around /inc or /set or /var.
  • Fourth, you were incrementing the variable by the variable + $3. In other words, if the variable was 10 and $3 was 5, instead of the new variable being 15, it would have been 10+10+5 = 25.
  • Fifth, I added a check to make sure that $3 is a number.
  • And, last, []'s are meant for changing the order of evaluation instead of causing something to evaluate. So I changed the msg line to use the format of $(,2) which is shorthand for $eval(,2) and inside that, use $+(), which combines things. In the end, $($+(%,var.,$something),2). Many people do use the [] method for dynamic variables, but depending on complexity, those won't always work. It's easier to just learn to use $eval (or $ for short) when working with dynamic variables.

Last edited by Riamus2; 30/07/11 12:57 PM.

Invision Support
#Invision on irc.irchighway.net
Joined: Jun 2011
Posts: 29
M
Ameglian cow
OP Offline
Ameglian cow
M
Joined: Jun 2011
Posts: 29
Thanks for you reply, it didnt quite work but its ok because im using another way that yourself recommended to me a while ago.

on *:TEXT:*:#:{
if ($1-2 == You sent) {
if ($nick($chan,$nick,~)) {
var %td = $+(totalcash.ini)
writeini -n %td Total Total $calc($readini(%td,Total,Total) + $3 )
msg $chan I have added $3 to the total.... the total given away in $chan is $iif($readini(%td,Total,Total),$v1,0)
}
}
}

Only trouble is i cant get it to strip the $ and comma when it saves so it just responds like this:

I have added $1,000,000 to the total.... the total given away in #playstaff is 0

Sorry for being a pain! (ps. only reason for the ini is so i can edit it if required)

Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
Works fine here:
Quote:

<Riamus> you sent 3
<Bot> I have added 3 to the total.... the total given away in #test is $3
<Riamus> you sent 3266
<Bot> I have added 3266 to the total.... the total given away in #test is $3,269
<Riamus> you sent 32664386856865
<Bot> I have added 32664386856865 to the total.... the total given away in #test is $32,664,386,860,134


If you explain what isn't working with what I gave, that would help.

As for your new script, first of all, use code tags so that it is easier to read (either type out [ code] without the space before and [ /code] without the space after, or else use the # button above.

I don't have any idea why you're using $nick() or why you're using $+() around a filename. Neither are going to be much use in what you're doing. Your $nick($chan,$nick,~) part just checks to see if the user who typed the command has the ~ prefix (might be founder depending on the network). I doubt that's what you want. If you only want someone with that mode, then it's fine, but no one who isn't ~ level will be able to use the command. And the $+() is used to combine multiple things together -- $+(this.,is) = this.is . Because you aren't using a comma anywhere in there, it does nothing. I am guessing that you just copy/pasted someone you saw in another script and made a few changes to it. That is fine... IF you also look up the commands used in the help file if you don't know what they are for. Just because certain commands are great for certain scripts doesn't mean they are necessary in your script. Copy/paste is an okay place to start, but you also have to check to make sure the commands are necessary and look up any you don't know about.

Also, your new example does not separate the numbers based on channel.

In any case, unless you're in hundreds of channels, I'd use variables instead of a file. What I gave you does work as shown by my test above. If there is an issue with it, let me know what isn't working with it. Editing isn't hard with variables if you're only in a small number of channels. Just go to your variables tab and search for TotalGiven and edit the one for the right channel.

EDIT: I edited the script I originally gave you so that the amount added is also in the format of $1,000,000 instead of just 1000000.

Last edited by Riamus2; 30/07/11 01:00 PM.

Invision Support
#Invision on irc.irchighway.net
Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
One other hint. If you will be using multiple scripts that use a money ouput, you might consider adding a $money identifier...

Code:
alias money {
  if ($1 !isnum) { return $1 }
  return $chr(36) $+ $bytes($1,b)
}


Then, everywhere you want to display the money format, you just put the number inside $money(). For example, if you had this identifier, you can use:

//echo -a $money(23536)

This can be used even with your current script, but it isn't going to be a huge benefit unless you're using a money display in more areas. In the current script that I gave you, you could replace $chr(36) $+ $bytes(____,b) with $money(____) . Note that whatever is in the ____ space should remain... $3 in the first one and the entire $($+()) part in the second.


Invision Support
#Invision on irc.irchighway.net
Joined: Jun 2011
Posts: 29
M
Ameglian cow
OP Offline
Ameglian cow
M
Joined: Jun 2011
Posts: 29
Code:
<~mumra_2790> You sent [b]$1,000,000[/b] to mumra_2790
<~mumra_2790> You sent [b]1000000[/b] to mumra_2790
<&Dinky> I have added $1,000,000 to the total.... the total given away in #test is $1,000,000


That being the prob, cant see the commas. Idk if thats right!

Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
It won't work if you include commas and $ in the You sent line because isnum doesn't consider it a number if it has $ or , in it. Tthat's why the first one isn't doing anything. If you need it to work with that, let me know. Otherwise, just use a number without commas and $ in the you sent line.

EDIT: Here, if you need it to work with commas and $, just change the tokenize line:

Code:
  tokenize 32 $strip($1-2) $remove($strip($3),$chr(36),$chr(44))


Invision Support
#Invision on irc.irchighway.net
Joined: Jun 2011
Posts: 29
M
Ameglian cow
OP Offline
Ameglian cow
M
Joined: Jun 2011
Posts: 29
yeah i need it to work, its a paste line from a game!

Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
See above.


Invision Support
#Invision on irc.irchighway.net
Joined: Jun 2011
Posts: 29
M
Ameglian cow
OP Offline
Ameglian cow
M
Joined: Jun 2011
Posts: 29
It worked, thankyou. Is their any way to edit it or re-set it?

Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
** It worked? It shouldn't have stripped off the [ b] and [/ b]...

Editing or resetting it can be done from the variables tab as I mentioned above. Just search for TotalGiven and you'll find the right variable. Just change the number or remove the variable to "reset" it.

Ok, I just looked more closely at what you have. Because you're not using normal control codes, but are using BBCodes, $strip() won't work.

* In the future, please include the actual input data in your original post to avoid this situation.

Here's the new tokenize command to deal with the BBCode...
Code:
  tokenize 32 $1-2 $remove($3,$chr(36),$chr(44),[b],[/b])

Last edited by Riamus2; 30/07/11 01:34 PM.

Invision Support
#Invision on irc.irchighway.net
Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
One last thing, if this is text from a bot of some sort, then you probably want to add a check to make sure only the bot can add money.


Invision Support
#Invision on irc.irchighway.net
Joined: Jun 2011
Posts: 29
M
Ameglian cow
OP Offline
Ameglian cow
M
Joined: Jun 2011
Posts: 29
Thankyou once again, works perfect!


Link Copied to Clipboard