Is anyone gonna reply?![]()
So I need a little help with this code. So far it works fine but I want to add something. Right not it can buy weapons but the money stays where it is so you can keep buying weapons. I wan it to subtract the gun amount from the money before it can buy a new one. Any suggestions? If anything is unclear please say so.
Code:@name Axis's Gun Shop @inputs Up Down Select On CS:wirelink Money RangerAK RangerM16 RangerSniper RangerShotGun RangerRPG @outputs BuyM16 BuyAk BuySniper BuyShotgun BuyRPG @persist Value @trigger if(Up == 1) { Value -= 1 if(Value < 1){Value = 1} } if(Down == 1) { Value += 1 if(Value > 5){Value = 5} } CS:writeCell(2042,4) CS:writeString("Axis's Gun Shop",0,0,999,0,0) CS:writeString("==============================",0,1,999,0,0) CS:writeString("|------{AK47}-------|",0,2,999,0,0) CS:writeString("|------{M16}--------|",0,3,999,0,0) CS:writeString("|------{Sniper}-----|",0,4,999,0,0) CS:writeString("|------{ShotGun}----|",0,5,999,0,0) CS:writeString("|------{RPG}--------|",0,6,999,0,0) if(RangerAK < 1) {CS:writeString("-Out",12,2,90,4,90)} if(RangerM16 < 1) {CS:writeString("-Out",12,3,90,4,90)} if(RangerSniper < 1) {CS:writeString("-Out",12,4,90,4,90)} if(RangerShotGun < 1) {CS:writeString("-Out",12,5,90,4,90)} if(RangerRPG < 1) {CS:writeString("-Out",12,6,90,4,90)} if(Select == 1) { if(Value == 2) { if(Money > 449) { BuyM16 = 1 timer("1",50) } if(Money < 450) { CS:writeString("Insufficient Funds",0,8,999,0,0) timer("run",2000) } } if(Value == 1) { if(Money > 449) { BuyAk = 1 X = 450 timer("2",50) } if(Money < 450) { CS:writeString("Insufficient Funds",0,8,999,0,0) timer("run",2000) } } if(Value == 3) { if(Money > 549) { BuySniper = 1 timer("3",50) } if(Money < 550) { CS:writeString("Insufficient Funds",0,8,999,0,0) timer("run",2000) } } if(Value == 4) { if(Money > 249) { BuyShotgun = 1 timer("4",50) } if(Money < 250) { CS:writeString("Insufficient Funds",0,8,999,0,0) timer("run",2000) } } if(Value == 5) { if(Money > 799) { BuyRPG = 1 timer("5",50) } if(Money < 800) { CS:writeString("Insufficient Funds",0,8,999,0,0) timer("run",2000) } } } else {Select == 0} if(Value == 1) { CS:writeString("-$450",12,2,90,4,90) } if(Value == 2) { CS:writeString("-$450",12,3,90,4,90) } if(Value == 3) { CS:writeString("-$550",12,4,90,4,90) } if(Value == 4) { CS:writeString("-$250",12,5,90,4,90) } if(Value == 5) { CS:writeString("-$800",12,6,90,4,90) } if (clk("run")) {CS:writeString(" ",0,8,999,0,0)} if (clk("1")) {BuyM16 = 0} if (clk("2")) {BuyAk = 0} if (clk("3")) {BuySniper = 0} if (clk("4")) {BuyShotgun = 0} if (clk("5")) {BuyRPG = 0}
Last edited by XxAxisxX; 02-05-2010 at 08:58 PM.
When the money is insert, save the value in a separate variable.
if (~Money & Money) {
Credit = Money
}
When someone buys something reduce their credit.
If I'm not wrong vending machines can't break money to give money back right?
You could change the Credit variable into a array which saves credit for each person, so when they have put in too much, they'll have it later available.
Ok still having a problem. Is there any way to store the amount of money put in then when they select the gun it subtracts the amount? Thanks for the help so far.![]()
This is my new code and it almost works except for 1 error. The only problem is once it outputs BoughtAk or BoughtM16 or any of those to an addition gate. It won't subtract the same gun again because it already equals -450. So somehow I need it to subtract a new -450. Any ideas would be greatly appreciated.
Code:@name Axis's Gun Shop @inputs Up Down Select On CS:wirelink Money RangerAK RangerM16 RangerSniper RangerShotGun RangerRPG @outputs BuyM16 BoughtRPG BoughtShotGun BoughtSniper BuyAk BuySniper BuyShotgun BuyRPG Money BoughtAK BoughtM16 @persist Value @trigger if(BuyM16 == 1) {BoughtAK = -450} if(BuyM16 == 1) {BoughtM16 = -450} if(BuySniper == 1) {BoughtSniper = -550} if(BuyShotgun == 1) {BoughtShotGun = -250} if(BuyRPG == 1) {BoughtRPG = -800} if(Up == 1) { Value -= 1 if(Value < 1){Value = 1} } if(Down == 1) { Value += 1 if(Value > 5){Value = 5} } CS:writeCell(2042,4) CS:writeString("Axis's Gun Shop",0,0,999,0,0) CS:writeString("==============================",0,1,999,0,0) CS:writeString("|------{AK47}-------|",0,2,999,0,0) CS:writeString("|------{M16}--------|",0,3,999,0,0) CS:writeString("|------{Sniper}-----|",0,4,999,0,0) CS:writeString("|------{ShotGun}----|",0,5,999,0,0) CS:writeString("|------{RPG}--------|",0,6,999,0,0) if(RangerAK < 1) {CS:writeString("-Out",12,2,90,4,90)} if(RangerM16 < 1) {CS:writeString("-Out",12,3,90,4,90)} if(RangerSniper < 1) {CS:writeString("-Out",12,4,90,4,90)} if(RangerShotGun < 1) {CS:writeString("-Out",12,5,90,4,90)} if(RangerRPG < 1) {CS:writeString("-Out",12,6,90,4,90)} if(Select == 1) { if(Value == 2) { if(Money > 449) { BuyM16 = 1 timer("1",50) } if(Money < 450) { CS:writeString("Insufficient Funds",0,8,999,0,0) timer("run",2000) } } if(Value == 1) { if(Money > 449) { BuyAk = 1 timer("2",50) } if(Money < 450) { CS:writeString("Insufficient Funds",0,8,999,0,0) timer("run",2000) } } if(Value == 3) { if(Money > 549) { BuySniper = 1 timer("3",50) } if(Money < 550) { CS:writeString("Insufficient Funds",0,8,999,0,0) timer("run",2000) } } if(Value == 4) { if(Money > 249) { BuyShotgun = 1 timer("4",50) } if(Money < 250) { CS:writeString("Insufficient Funds",0,8,999,0,0) timer("run",2000) } } if(Value == 5) { if(Money > 799) { BuyRPG = 1 timer("5",50) } if(Money < 800) { CS:writeString("Insufficient Funds",0,8,999,0,0) timer("run",2000) } } } else {Select == 0} if(Value == 1) { CS:writeString("-$450",12,2,90,4,90) } if(Value == 2) { CS:writeString("-$450",12,3,90,4,90) } if(Value == 3) { CS:writeString("-$550",12,4,90,4,90) } if(Value == 4) { CS:writeString("-$250",12,5,90,4,90) } if(Value == 5) { CS:writeString("-$800",12,6,90,4,90) } if (clk("run")) {CS:writeString(" ",0,8,999,0,0)} if (clk("1")) {BuyM16 = 0} if (clk("2")) {BuyAk = 0} if (clk("3")) {BuySniper = 0} if (clk("4")) {BuyShotgun = 0} if (clk("5")) {BuyRPG = 0}
if (clk("1")) {BuyM16 = 0}
if (clk("2")) {BuyAk = 0}
if (clk("3")) {BuySniper = 0}
if (clk("4")) {BuyShotgun = 0}
if (clk("5")) {BuyRPG = 0}
Reset the values here?
If you'd been listening you'd know that Nintendos! pass trough everything! - Colonel Jack. O'Niel
Good news everyone!
I have invented a device that makes your read this in your head, in my voice.
Could you be a little more specific? And is it possible to use a persist value to subtract the correct amount of money?
Bookmarks