ID:1470052
 
(See the best response by Albro1.)
Code:
        verb/Use()
if(usr.Class=="Megaman" || usr.Class=="Roll" || usr.Class=="Gutsman" || usr.Class=="Protoman" || usr.Class=="Megaman SF" || usr.Class=="Bass" || usr.Class=="Colonel" || usr.Class=="Shadowman" || usr.Class=="Searchman" || usr.Class=="Numberman" || usr.Class=="Fireman" || usr.Class=="Elecman" || usr.Class=="Aquaman" || usr.Class=="Magnetman" || usr.Class=="Gyroman" || usr.Class=="BassCross" || usr.Class=="Woodman" || usr.Class=="Shademan" || usr.Class=="Meddy" || usr.Class=="Killerman")
usr.icon='megaman.dmi'
usr.Class="Megaman"
usr.contents += new/obj/Skills/Mega_Buster
usr.contents += new/obj/Skills/Charge
for(var/obj/Skills/O in usr.contents)
if(O.LearnedBy!=usr.Class)
del O
for(var/X in usr.overlays)
usr.overlays -= X
var/obj/Items/O = locate() in usr.contents
del O
var/obj/Items/b = locate() in usr.Items
del b
usr.contents += new/obj/Items/Megaman_Pet
usr.Items += new/obj/Items/Megaman_Pet
winset(usr,"macro.Q","parent=macro;name=X;command=MegaBuster")
winset(usr,"macro.Q","parecnt=macro;name=Z;command=Charge")
del src


Problem description:
Basically My problem is whenever I use an item, it leaves a place in my inventory (like it still exists meaning if I used this item, it will disappear but will leave a space in my inventory still), Also I can't seem to use the items directly from inventory after re-logging. Must used them from Commands Panel.
Best response
Try taking it out of usr.contents before deleting it.

Also, how many different "Classes" do you have? You should not need an if statement that long. You could just run a check to make sure they aren't something, or if you really need to check ALL of those Classes, you can shorten it considerably by checking through a list:

if(usr.Class in list("Megaman", "Roll"/*, etc*/))
That kinda worked, gave it 2 tries and no negatives so far.
I also figured how to make Items usable without using Commands by doing that

                var/obj/NewItem="/obj/Items/Protoman_Pet"
NewItem=new NewItem
usr.contents +=NewItem
usr.Items += NewItem


Well, I created that months ago when I first started using Dm, Thanks for answering tho :)
In response to Yazan20
Yazan20 wrote:
That kinda worked, gave it 2 tries and no negatives so far.
I also figured how to make Items usable without using Commands by doing that

                var/obj/NewItem="/obj/Items/Protoman_Pet"
> NewItem=new NewItem
> usr.contents +=NewItem
> usr.Items += NewItem

Well, I created that months ago when I first started using Dm, Thanks for answering tho :)

var/obj/ni = new/obj/Items/Protoman_Pet()


No need to use a text string here unless the type is generic. Even then, you aren't going to want to use a text string unless it has some kind of modifier determined through concatenation. Initialization can be done on a single line if you know explicitly the path of the object you are creating.