ID:150408
 
Can I please get some examples of how to implement the selling of items in your inventory? No matter what I do, I can't seem to get my code right.

All I need it to do is delete the item from the user's inventory, give him the money the item is worth (say half its buy price), and give him back the weight it took up. I can do everything else but I cant get it to delete the item.

What I have set up as far as a vendor is an npc mob that does nothing but look pretty behind the counter. In the /mob/player, I have used the bump proc(/obj/vendorcounter) and I have an object called a vendorcounter, which is dense, and several different areas for the different types of vendors. When a player enters the square in front of the counter, usr:area is set to the area they enter, thus determining the type of shop they are at. When they bump the counter, the proc for the counter opens a buy/sell/done dialogue using the input command.

I took the time to design several nice looking armor icons and coded in and tested the buy routine. It works nice, deducts the cash, and added the item to the user's contents, and they can even put it on and watch their armor class get adjusted. But when I try to sell the item, in any of the dozen or so ways I have tried to do it, it fails to work. So basically, if someone, or several someones, can please post some basic examples of how to do the selling routine, I can get back on track 8)

Kidknee
byond://Kidknee.AE##version=1.03
Kidknee wrote:
Can I please get some examples of how to implement the selling of items in your inventory? No matter what I do, I can't seem to get my code right.

All I need it to do is delete the item from the user's inventory, give him the money the item is worth (say half its buy price), and give him back the weight it took up. I can do everything else but I cant get it to delete the item.

What I have set up as far as a vendor is an npc mob that does nothing but look pretty behind the counter. In the /mob/player, I have used the bump proc(/obj/vendorcounter) and I have an object called a vendorcounter, which is dense, and several different areas for the different types of vendors. When a player enters the square in front of the counter, usr:area is set to the area they enter, thus determining the type of shop they are at. When they bump the counter, the proc for the counter opens a buy/sell/done dialogue using the input command.

I took the time to design several nice looking armor icons and coded in and tested the buy routine. It works nice, deducts the cash, and added the item to the user's contents, and they can even put it on and watch their armor class get adjusted. But when I try to sell the item, in any of the dozen or so ways I have tried to do it, it fails to work. So basically, if someone, or several someones, can please post some basic examples of how to do the selling routine, I can get back on track 8)

Kidknee
byond://Kidknee.AE##version=1.03
del src
Well, to delete an object from the users inventory, you can use the del() proc. So basically just assign a variable to the item the user wants to dell, and delete it using del()

Hope that explains it
Alathon
In response to Alathon
Alathon wrote:
Well, to delete an object from the users inventory, you can use the del() proc. So basically just assign a variable to the item the user wants to dell, and delete it using del()

Hope that explains it
Alathon
I GOT IT FIRST!!!!!!!!!
In response to Air _King
Air _King wrote:
Alathon wrote:
Well, to delete an object from the users inventory, you can use the del() proc. So basically just assign a variable to the item the user wants to dell, and delete it using del()

Hope that explains it
Alathon
I GOT IT FIRST!!!!!!!!!


Whats this insane obsession with answering something first? First SonVegitto now you? Chuckle. It alwease helps to have more than one input on a question, and I feel that if the person knows WHY they should put something it will further not only their coding abilities, but their overall understanding of "it all"(Dont ask me the difference in this case). You supplied an answer on how to delete it, so did I. The way I see it the first person to answer it doesnt really matter, that the person who is in need of help understands what is given to them is important.

Alathon
In response to Air _King
I know to use the del command, but the problem is that it always gives me an error.

I just tried it with a simple del src. The problem with this is it only deletes the item the player just bought. I guess I didnt explain properly. My apologies. I need to have the game throw up a list in an input window of usr.contents then delete the chosen item.

Any suggestions?
In response to Kidknee
Kidknee wrote:
I know to use the del command, but the problem is that it always gives me an error.

I just tried it with a simple del src. The problem with this is it only deletes the item the player just bought. I guess I didnt explain properly. My apologies. I need to have the game throw up a list in an input window of usr.contents then delete the chosen item.

Any suggestions?

See now thats an entirely different issue :)

Look up the input() proc. You could do something like this

obj/Desk/Click()
var/which_item = input(usr,"Which item do you wish to sell?") in usr.contents
del(which_item)


Alathon
In response to Alathon
ROFL I just thought of that and implemented and tried it, and when it worked I about fell out of my chair. Leave it to me to overcomplicate things.

Now if someone can tell me why I can never get my updated package to load. I have tried 4 times in the last hour to get my updated zip to save and yet every time I try to run it, I keep loading the old one?
In response to Kidknee
Now if someone can tell me why I can never get my updated package to load. I have tried 4 times in the last hour to get my updated zip to save and yet every time I try to run it, I keep loading the old one?

You need to increase the version number, too, people should add. That is easier and makes people understand the general frequency of updates better.