ID:140051
 
Code:
mob
var
Caps = 0
verb
Drop_Caps(how_much as num) // ask how much to drop
if(how_much <= usr.Caps && how_much > 0)
var/obj/Caps/C = new(usr.loc)
C.amount = how_much
usr.Caps -= how_much
else
usr << "You cant drop that amount of Caps."
Give_Caps(mob/M as mob in oview(1),how_much as num)
if(how_much <= usr.Caps && how_much > 0)
M.Caps += how_much // give the mob you are giving the gold to, the amount of gold specified.
usr.Caps -= how_much //take away the amount of gold from the user
else
usr << "You cant give that amount of Caps"

obj
Caps
icon = 'Caps.dmi'
var
amount
verb
Get()
set src in oview(1)
usr.Caps += amount
del(src)
mob
Stat()
stat("Level","[src.Level]")
stat("Health","[src.Health]/[src.MaxHealth]")
stat("Experience","[src.Experience]/[src.MaxExperience]")
stat("Caps:",Caps)


Problem description:

the verb "Get" will pick up the caps but it wont add to the Caps in the stats, and there arent any errors.
.....

usr.Caps += amount??

it won't add because the amount is 0 >_>

var
amount = 1
You have to set the amount for the caps... here's what I would do.

obj
Caps
icon = 'Caps.dmi'
var
amount

New(caps)
amount = caps
..()

verb
Get()
set src in oview(1)
usr.Caps += amount
del(src)


Now when you create the caps obj it could look like this:
var/obj/Caps/c = new(how_much)
c.loc = locate(usr.x,usr.y,usr.z)
In response to JoEn00b
Or combine the loc with the passing argument:
obj
Cap(loc, amt)
src.amount = amt
// new() should use the first argument, loc, to create the item there, hence why it is not used here


new/obj/Cap(locate(X,Y,Z), 200) // no defining variables needed now ^_^


As a side note, you can use min() and max() to make a limit of how much can be entered if you wish. For example: amt = min(cap_max, input) <- if input is > cap_max, the amt will be cap_max
In response to JoEn00b
JoEn00b wrote:
c.loc = locate(usr.x,usr.y,usr.z)


This is stupid. If you want the turf that usr is standing on, use usr.loc.
In response to Garthor
Garthor wrote:
JoEn00b wrote:
c.loc = locate(usr.x,usr.y,usr.z)

This is stupid. If you want the turf that usr is standing on, use usr.loc.


Agreed.