ID:150162
 
Ok I thought it would be easier than this, but what is the easiest way to make a verb that will give gold to only the mob/pc that is selected??

My own code as of now follows, the selection part works, but when you right-click the verb on that person it brings up all the mobs in the area, even mob/npc.

ive_Gold(mob/pc/M as mob, give as num)
set src in oview(1)
if (M == usr) return
if(gold < give) usr << "You don't have that much to give!"; return
M.gold += give
usr << "You gave [give] gold to [M]."
M << "[usr] gave [give] gold to you."


LJR
Well thats a way but here is what i do
Gold(G as num,M as mob in world)
M.gold+=G
In response to Greg
Your way won't work well, it will lead to negitive numbers.


mob/verb/Give_Gold(mob/M as mob in oview(1))
var/Amount = input("How much gold will you give?")as num
if(M.client)
if(usr.gold<Amount)
usr<<"Not enough gold!"
else
M.gold+=Amount
usr.gold-=Amount
M<<"[usr] gave you [amount] gold!"
else
..()



Should work.
In response to Nadrew
How would it give negative numbers
and yes it works
In response to Greg
Well since that's not even a give gold verb it doesn't take gold from anyone making it a free gold verb, which isn't what he wanted.
In response to Nadrew
oh i thought he wanted to make something that just gave gold to people
In response to Nadrew
Nadrew wrote:
Well since that's not even a give gold verb it doesn't take gold from anyone making it a free gold verb, which isn't what he wanted.

hehehe yeah I caught after I posted. I got it all working now.. Now for sound control... I'm gonna check some demos and stuff for that first and if I can't get my sound checks to work I'll post.

LJR
LordJR wrote:
Ok I thought it would be easier than this, but what is the easiest way to make a verb that will give gold to only the mob/pc that is selected??

My own code as of now follows, the selection part works, but when you right-click the verb on that person it brings up all the mobs in the area, even mob/npc.

You're problem is in these two lines:

ive_Gold(mob/pc/M as mob, give as num)
set src in oview(1)

src can be any mob in oview(1) of the usr, and M can be any mob in view() of the usr. You want one or the other, not both.

Give_Gold(mob/pc/M as mob, give as num)
set src = usr // default mob verb setting
// rest of the verb can stay the same

or

Give_Gold(give as num)
set src in oview(1)
// src is the mob recieving gold, usr is the mob giving it
if(usr.gold < give) usr << "You don't have that much to give!"; return
src.gold += give
usr << "You gave [give] gold to [src]."
src << "[usr] gave [give] gold to you."

Of course, you'll want to address the other concerns mentioned in this thread, like giving negative values and subtracting the gold from the usr.
In response to Nadrew
I love games that forget to check for negative quantities when giving :).