ID:150345
 
I have a buy sytem, which you normally use /new/obj/whatever to give the player the item. for ammo, and air I am using vars, I tried this..

if(usr.cash >= cost)
usr.cash -= cost
alert("Ammo bought succesfully.","Transaction Completed!")
if(selling=="100 Paint Balls - $10") usr.ammo += 100
if(selling=="200 Paint Balls - $18") usr.ammo += 200
if(selling=="Air Refill - $5") usr.air += 100
else
alert("You don't have enough money!","Warning!")

This is just the part of the buy sytem that is messed up(its pretty long). If you need more just tell me. Anyways I get 3 errors,

buysys.dm:80:error:usr.ammo:bad var
buysys.dm:81:error:usr.ammo:bad var
buysys.dm:82:error:usr.air:bad var

I have the vars identified though, var/air = 0 and var/ammo = 0

I have the buysystem in one dm file, and the vars listed in another dm file would that matter?
Well, what is usr exactly? If usr will ALWAYS be somone with those vars, you can use the : operator. Otherwise, make completely sure that usr = a mob with the correct vars.

Having procs and vars in different .dm files should not matter.


Good luck, LoW
In response to Lord of Water
I found the problem, I needed to have mob infront of var..
mob/var/blah

Thanx for replying though :)
In response to Oblivian
If air is less than 100, I want to add the difference.
Ex. Someone has 60 air left in the container, I want the game to add 40 to equal 100, or if someone has 80 air, to add 20 to equal 100. I am clueless of how to do this, heres what I have:

if(selling=="Air Refill - $5")
if(usr.air <= 100)

Thanx for any help :)
In response to Oblivian
Wouldn't it be easier just to set the air to 100?
In response to Spuzzum
Oops, I asked the wrong thing.. I need to know how once its added, to subtract that amount from another number..

proc
Reload()
if(usr.hopper <= 200)
usr.hopper = 200
usr.ammo -=
else
usr << "Your hopper is full!"

Thats what I have, Thanx for any help.
In response to Oblivian
To find the remainder, subtract the current number from the max number. IE

mob/verb/Energy_Check()
var/energy_not_used = energy_max - energy
src << "You have [energy_not_used] energy left"


Alathon
In response to Alathon
I tried for a while, and came up with this, says statement has no effect.

proc
Reload()
if(usr.hopper <= 200)
var/left = max_hop - usr.hopper
usr.ammo - left
else
usr << "Your hopper is full!"
In response to Oblivian
the problems with usr.ammo - left. You need to use -= not -
Ie

usr.ammo -= left

Alathon
In response to Alathon
Ok, did that.. now I get an error in-game.

runtime error: Maximum recursion level reached (perhaps there is an infinite loop)
To avoid this safety check, set world.loop_checks=0.
verb name: reload (/obj/Talon/verb/reload)
usr: GM-Oblivian (/mob/GM)
src: Talon (/obj/Talon)
call stack:
Talon (/obj/Talon): reload()
Talon (/obj/Talon): reload()
Talon (/obj/Talon): reload()
Talon (/obj/Talon): reload()
Talon (/obj/Talon): reload()
Talon (/obj/Talon): reload()
Talon (/obj/Talon): reload()
Talon (/obj/Talon): reload()
Talon (/obj/Talon): reload()
Talon (/obj/Talon): reload()
...
Talon (/obj/Talon): reload()
Talon (/obj/Talon): reload()
Talon (/obj/Talon): reload()
Talon (/obj/Talon): reload()
Talon (/obj/Talon): reload()
Talon (/obj/Talon): reload()
Talon (/obj/Talon): reload()
Talon (/obj/Talon): reload()
Talon (/obj/Talon): reload()

And the code:

proc
Reload()
if(usr.hopper <= 200)
var/left = max_hop - usr.hopper
usr.ammo -= left
usr.hopper = 200
else if(usr.ammo == 0)
usr << "No ammo to refill your hopper!"
else
usr << "Your hopper is full!"
Oblivian wrote:
I have a buy sytem, which you normally use /new/obj/whatever to give the player the item. for ammo, and air I am using vars, I tried this..

if(usr.cash >= cost)
usr.cash -= cost
alert("Ammo bought succesfully.","Transaction Completed!")
if(selling=="100 Paint Balls - $10") usr.ammo += 100
if(selling=="200 Paint Balls - $18") usr.ammo += 200
if(selling=="Air Refill - $5") usr.air += 100
else
alert("You don't have enough money!","Warning!")

This is just the part of the buy sytem that is messed up(its pretty long). If you need more just tell me. Anyways I get 3 errors,

buysys.dm:80:error:usr.ammo:bad var
buysys.dm:81:error:usr.ammo:bad var
buysys.dm:82:error:usr.air:bad var

I have the vars identified though, var/air = 0 and var/ammo = 0

I have the buysystem in one dm file, and the vars listed in another dm file would that matter?



Just add air and ammo to ur var list