+ Reply to Thread
Results 1 to 8 of 8

Thread: Help Please

  1. #1
    Wire Amateur XxAxisxX is an unknown quantity at this point XxAxisxX's Avatar
    Join Date
    Jan 2010
    Posts
    87

    Question Help Please

    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; 4 Weeks Ago at 08:58 PM.

  2. #2
    Wire Amateur XxAxisxX is an unknown quantity at this point XxAxisxX's Avatar
    Join Date
    Jan 2010
    Posts
    87

    Unhappy Re: Help Please

    Is anyone gonna reply?

  3. #3
    Spucatum Tauri
    Bull is a splendid one to behold Bull is a splendid one to behold Bull is a splendid one to behold Bull is a splendid one to behold Bull is a splendid one to behold Bull is a splendid one to behold Bull is a splendid one to behold Bull's Avatar
    Join Date
    Jun 2008
    Location
    Finland
    Posts
    3,437

    Default Re: Help Please

    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.
    My signature has a point.
    Quote Originally Posted by Squeakyneb View Post
    when l3ulletje says do it, do it.
    That
    The Great Report Button Quiz.

  4. #4
    Wire Amateur XxAxisxX is an unknown quantity at this point XxAxisxX's Avatar
    Join Date
    Jan 2010
    Posts
    87

    Default Re: Help Please

    Thanks. I will try that.

  5. #5
    Wire Amateur XxAxisxX is an unknown quantity at this point XxAxisxX's Avatar
    Join Date
    Jan 2010
    Posts
    87

    Default Re: Help Please

    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.

  6. #6
    Wire Amateur XxAxisxX is an unknown quantity at this point XxAxisxX's Avatar
    Join Date
    Jan 2010
    Posts
    87

    Question Re: Help Please

    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}
    

  7. #7
    Wirererer timas will become famous soon enough timas's Avatar
    Join Date
    Apr 2007
    Location
    Vennesla, Norway
    Posts
    134

    Default Re: Help Please

    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.

  8. #8
    Wire Amateur XxAxisxX is an unknown quantity at this point XxAxisxX's Avatar
    Join Date
    Jan 2010
    Posts
    87

    Smile Re: Help Please

    Could you be a little more specific? And is it possible to use a persist value to subtract the correct amount of money?

+ Reply to Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts