ID:261248
 
im stumped!
on my game im making a give gold code. so you can be anywhere in the world and give gold!

this is my code


\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\



mob/verb
Give(mob/M in world, amt as num)
set category ="Other"
switch(input("Do you want to give [M] soem gold?.","Gold")in list("Yes","No"))
if("Yes")
if(usr.Gold>=0)
usr.Gold-=amt
alert("You gave [M] [amt] Gold.")
M << "[usr] gave you [amt] gold"
else
alert("You don't have enough gold.")

if("Not")






\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
how can i fix that so itll work? i mean it sure takes the gold from me but doesnt give it to the other.
please help this is agrivating.
- Kyle
Cappa Kyle wrote:
im stumped!
on my game im making a give gold code. so you can be anywhere in the world and give gold!

this is my code


\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\



mob/verb
Give(mob/M in world, amt as num)
set category ="Other"
switch(input("Do you want to give [M] soem gold?.","Gold")in list("Yes","No"))
if("Yes")
if(usr.Gold>=0)
usr.Gold-=amt
alert("You gave [M] [amt] Gold.")
M << "[usr] gave you [amt] gold"
else
alert("You don't have enough gold.")

if("Not")






\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
how can i fix that so itll work? i mean it sure takes the gold from me but doesnt give it to the other.
please help this is agrivating.
- Kyle


This is very simple to do:

mob/verb/Give_Gold(mob/M as mob in world)
var/Ammount = input("How much gold?")as num
if(usr.Gold<Ammount)
usr<<"You don't have enough gold!!"
else
usr.Gold-=Ammount
M.Gold+=Ammount
M<<"[usr] gave you [Ammount] gold!"
In response to Nadrew
thanks
if("Yes")
if(usr.Gold>=0)
usr.Gold-=amt
alert("You gave [M] [amt] Gold.")
M << "[usr] gave you [amt] gold"

It ain't a brain surgeon, you know -- it can't assume that when you subtract gold, you want to add it to someone else. Now, naturally, if you also added to M when subtracting from usr, it'd work better. =P

Another small problem: you should compare usr.Gold to the amt, not to 0, since you want to find out if they have enough to give that amount, not if they have enough money to be able to give at least 0.