Signup Now
Results 1 to 5 of 5
  1. #1
    Free User
    Join Date
    Aug 2014
    Posts
    3
    Reputation
    10
    Rep Power
    0

    Help in Scripting...

    Hey Guys,
    I'm new to Windbot and just started to script myself (a little bit).
    So after this Code:
    Code:
    HPs = getuseroption('Health Potions')
    Spears = getuseroption('Spears')
    SpearsGot = itemcount(3277, 'all')
    HPsGot = itemcount(266, 'all')
    
    SpearsBuy = SpearsGot - Spears
    HPsBuy = HPsGot - HPs
    MoneyAll = ((-(SpearsGot - Spears))*9) + ((-(HPsGot - HPs)*45))
    
    if MoneyAll < 9
    then
    	say('hi') wait(1500, 3000)
    	npcsay('deposit all') wait(500,700)
    	npcsay('yes') wait(500,700)
    	gotolabel('Start', 'ToHunt')
    else
    	say('hi') wait(1500, 3000)
    	 npcsay('deposit all') wait(500,700)
    	 npcsay('yes') wait(500,700)
    	 npcsay('withdraw '..MoneyAll) wait(500, 700)
     	 npcsay('yes') wait(500, 700)
    end
    I get the Error: attempt to perform arithmetic on global 'HPs' (a nil value)
    It's in line 7, I tried everything but nothing helped.

    I appreciate any help!
    Thanks in advance.

  2. #2
    Wind Tester
    Join Date
    Dec 2013
    Location
    Warsaw, Poland
    Posts
    2,579
    Reputation
    149
    Rep Power
    27
    @aback try
    HPs = tonumber(getuseroption('Health Potions'))
    Spears = tonumber(getuseroption('Spears'))
    SpearsGot = itemcount(3277, 'all')
    HPsGot = itemcount(266, 'all')

    SpearsBuy = SpearsGot - Spears
    HPsBuy = HPsGot - HPs
    MoneyAll = ((-(SpearsGot - Spears))*9) + ((-(HPsGot - HPs)*45))

    if MoneyAll < 9
    then
    say('hi') wait(1500, 3000)
    npcsay('deposit all') wait(500,700)
    npcsay('yes') wait(500,700)
    gotolabel('Start', 'ToHunt')
    else
    say('hi') wait(1500, 3000)
    npcsay('deposit all') wait(500,700)
    npcsay('yes') wait(500,700)
    npcsay('withdraw '..MoneyAll) wait(500, 700)
    npcsay('yes') wait(500, 700)
    end


    All lineedits values are strings, so you have to use tonumber() function

  3. #3
    Free User
    Join Date
    Aug 2014
    Posts
    3
    Reputation
    10
    Rep Power
    0
    Still refers to the same Error :/

    Thanks anyways!

  4. #4
    Wind Tester
    Join Date
    Dec 2013
    Location
    Warsaw, Poland
    Posts
    2,579
    Reputation
    149
    Rep Power
    27
    @aback You are sure that you have correct useroption name (''Health Potions') in setup? Because i just checked code and it works for me.

  5. #5
    Free User
    Join Date
    Aug 2014
    Posts
    3
    Reputation
    10
    Rep Power
    0
    Oh i'm so sorry haha you're right!
    Thank you so much! I'll pay more attention next time!
    Have a nice day

 

 

Posting Permissions

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