mIRC Home    About    Download    Register    News    Help

Print Thread
math calc #169169 20/01/07 01:12 AM
Joined: Dec 2006
Posts: 46
D
danzigrules Offline OP
Ameglian cow
OP Offline
Ameglian cow
D
Joined: Dec 2006
Posts: 46
I need a script that will do the following:

You purchased 22,000 Turrets for $3,941,080 (including tax).

Unit Price: $169 Demo $179 Comm: $163

basically take the second number(3941080) divided by the first number(22000) Then multiply it by .06 , 1, and .09

Unit Price:= answer * .06, Demo is actual answer, Comm answer*.09

No need for decimals.

Thank you for your help.

Re: math calc [Re: danzigrules] #169170 20/01/07 01:26 AM
Joined: Oct 2004
Posts: 8,330
Riamus2 Offline
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
I'm not sure how you want this to run... whether you are having people type in the commands or you're doing it yourself, or it's being done as part of another script. You didn't really say. So I will just give you the main idea that you'd need.

Code:
var %price = $calc(%totalprice / %totalturrets)
echo -a Unit Price: $calc(%price * .06) Demo: %price Comm: $calc(%price * .09)


That assumes you have the total price in a %totalprice variable and # of turrets in the %totalturrets variable and that you want it echoed. Like I said, you didn't give enough information to write a complete script.


Invision Support
#Invision on irc.irchighway.net
Re: math calc [Re: Riamus2] #169173 20/01/07 01:37 AM
Joined: Dec 2006
Posts: 46
D
danzigrules Offline OP
Ameglian cow
OP Offline
Ameglian cow
D
Joined: Dec 2006
Posts: 46
oh I am sorry,
I want it to work in a channel and anytime anyone posts the you purchased blah blah, it will output the costs. It doesn't need to know what was bought, just do the calcs

Re: math calc [Re: danzigrules] #169176 20/01/07 01:49 AM
Joined: Oct 2004
Posts: 8,330
Riamus2 Offline
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
Assuming that the output always looks like:

You purchased 22,000 Turrets for $3,941,080 (including tax).

You'd use:
Code:
on *:text:You purchased*including tax*:#: {
  var %price = $calc($remove($gettok($1-,$calc($gettok($1-,0,32) - 2),32),$chr(44),$) / $remove($3,$chr(44)))
  msg $chan Unit Price: $calc(%price * .06) Demo: %price Comm: $calc(%price * .09)
}


The var line is a bit complicated because I made it to work regardless of whether or not the item name is 1 word or not. If it's always 1 word, you can use this var line instead:
Code:
  var %price = $calc($remove($6,$chr(44),$) / $remove($3,$chr(44)))



As you can see, it's much simpler, but it won't work if your item name is more than 1 word, such as Machine Guns.


Invision Support
#Invision on irc.irchighway.net
Re: math calc [Re: Riamus2] #169178 20/01/07 02:00 AM
Joined: Dec 2006
Posts: 46
D
danzigrules Offline OP
Ameglian cow
OP Offline
Ameglian cow
D
Joined: Dec 2006
Posts: 46
ok it is starting to work laugh

but now I get this: Unit Price: 10.7484 Demo: 179.14 Comm: 16.1226

it seems that it is just out putting the .06 and .09

also can the 10.7484 lose the .7484

Re: math calc [Re: danzigrules] #169181 20/01/07 02:10 AM
Joined: Oct 2004
Posts: 8,330
Riamus2 Offline
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
Originally Posted By: danzigrules
it seems that it is just out putting the .06 and .09


What do you mean about outputting those?

Originally Posted By: danzigrules

also can the 10.7484 lose the .7484


Here:
Code:
on *:text:You purchased*including tax*:#: {
  var %price = $calc($remove($gettok($1-,$calc($gettok($1-,0,32) - 2),32),$chr(44),$) / $remove($3,$chr(44)))
  msg $chan Unit Price: $int($calc(%price * .06)) Demo: $int(%price) Comm: $int($calc(%price * .09))
}


Note that this drops the decimal value as you requested. If you'd rather have it round the number instead of dropping the decimal, then use this:
Code:
on *:text:You purchased*including tax*:#: {
  var %price = $calc($remove($gettok($1-,$calc($gettok($1-,0,32) - 2),32),$chr(44),$) / $remove($3,$chr(44)))
  msg $chan Unit Price: $round($calc(%price * .06),0) Demo: $round(%price,0) Comm: $round($calc(%price * .09),0)
}



Invision Support
#Invision on irc.irchighway.net
Re: math calc [Re: danzigrules] #169183 20/01/07 02:14 AM
Joined: Dec 2006
Posts: 46
D
danzigrules Offline OP
Ameglian cow
OP Offline
Ameglian cow
D
Joined: Dec 2006
Posts: 46
maybe I worded things wrong and if I did I apologize.

I need the output to take the price * .06 and show the price

so it would be like: 50000/50 price 1060 demo 1000 comm 1090

I think my math is right

Re: math calc [Re: danzigrules] #169186 20/01/07 02:23 AM
Joined: Oct 2004
Posts: 8,330
Riamus2 Offline
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
Your first example had demo as being a higher number. smile

Anyhow, I think you mean to multiply by 1.06 and 1.09 instead. Just change the .06 and .09 in the script to 1.06 and 1.09 and it should give you what you want.

[EDIT] Just one thing I'm confused about, though. It looks like you're displaying tax (6% and 9% tax). Yet the price you're getting includes tax already....

Last edited by Riamus2; 20/01/07 02:25 AM.

Invision Support
#Invision on irc.irchighway.net
Re: math calc [Re: Riamus2] #169189 20/01/07 03:15 AM
Joined: Dec 2006
Posts: 46
D
danzigrules Offline OP
Ameglian cow
OP Offline
Ameglian cow
D
Joined: Dec 2006
Posts: 46
just one thing I'm confused about, though. It looks like you're displaying tax (6% and 9% tax). Yet the price you're getting includes tax already...

we just figured that out too.

on *:text:You purchased*including tax*:#: {
var %price = $calc($remove($gettok($1-,$calc($gettok($1-,0,32) - 2),32),$chr(44),$) / $remove($3,$chr(44)))
msg $chan Unit Price: $round($calc(%price / 1.06),0) Demo: $round(%price,0) Comm: $round($calc(%price / 1.1),0)
}

I believe that works right now. Just need to test it some more.


Thanks a lot