|
Joined: Dec 2006
Posts: 46
Ameglian cow
|
OP
Ameglian cow
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.
|
|
|
|
Joined: Oct 2004
Posts: 8,330
Hoopy frood
|
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.
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
|
|
|
|
Joined: Dec 2006
Posts: 46
Ameglian cow
|
OP
Ameglian cow
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
|
|
|
|
Joined: Oct 2004
Posts: 8,330
Hoopy frood
|
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:
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:
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
|
|
|
|
Joined: Dec 2006
Posts: 46
Ameglian cow
|
OP
Ameglian cow
Joined: Dec 2006
Posts: 46 |
ok it is starting to work 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
|
|
|
|
Joined: Oct 2004
Posts: 8,330
Hoopy frood
|
Hoopy frood
Joined: Oct 2004
Posts: 8,330 |
it seems that it is just out putting the .06 and .09
What do you mean about outputting those? also can the 10.7484 lose the .7484
Here:
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:
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
|
|
|
|
Joined: Dec 2006
Posts: 46
Ameglian cow
|
OP
Ameglian cow
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
|
|
|
|
Joined: Oct 2004
Posts: 8,330
Hoopy frood
|
Hoopy frood
Joined: Oct 2004
Posts: 8,330 |
Your first example had demo as being a higher number. 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
|
|
|
|
Joined: Dec 2006
Posts: 46
Ameglian cow
|
OP
Ameglian cow
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
|
|
|
|
|