ID:262854
 
Code:
        Wooden_Shield
icon = 'C Equipment.dmi'
icon_state="Wooden Shield"
verb
Equip()
if(usr.shield == 0 )
usr.shield == 1
usr.equipshield = 1
usr.overlays+=new/obj/equipment/Shield_Equipped
usr.defense += 2
usr<<"You equip Wooden Shield!"
else
..()
Unequip()
if(usr.shield == 1 )
usr.shield == 0
usr.equipshield = 0
usr.overlays-=new/obj/equipment/Shield_Equipped
usr.defense -= 2
usr<<"You unequip Wooden Shield."
else
..()

Shield_Equipped
icon = 'C Equipment.dmi'
icon_state="Wooden Shieldeq"
layer=MOB_LAYER+3


Problem description:
I can equip a plate shield and than unequip a wooden shield and it thinks i got no shield on but i got a plate shield on...help!

First of all

if(usr.shield==1) // THIS IS BAAAAD. Instead, use
if(usr.shield)
//////////////
if(usr.shield==0)// THIS IS BAAAAAAD ALSO. Instead, use
if(!usr.shield)
//////
usr.shield==1// Why do you have 2 '='? That's wrong, should be usr.shield=1, same with the 0


Also, there is no way to make a
 new/obj/....
. You can leave the new.

As for your problem, you probably messed somehting up in the plate shield code.
In response to Mysame
So what are you trying to get me do -.- make it usr.shield in it or what im just getting confused at what your saying if your gonna show me what to do make it more easy to understand lol... i just see this is badd this is good XD
In response to Flame Guardian
This is one of the things Mysame is trying to teach you

An example is that if(!var) looks for a value of 0 or null but == looks for a specific value..eg:
var/I = 0
if(!I) can be written also like if(I==0)

HOWEVER, if:
I = null

if(!I) will work BUT if(I==0) won't because it's specifically looking for 0 not null

..Um just read the link >_<


For the main problem, add more safechecks such as:

usr.shield = src.name <-- though the problem could be the unequip of the same item, unless all items are pretty much the same

in the above, you will need to use if(usr.shield==src.name) instead of if(usr.shield) to make sure the right item is being unequipped

(Note, the safecheck I showed is not a good way, you can have better ones like an item's own personal ID)

- GhostAnime
In response to GhostAnime
Either way, both are not robust in an equip system. It should be more like this.
mob/var
obj/equipment/Weapon/W //Create a variable to store the equipped weapon in
obj/equipment/Shield/S //Same with shield

obj/equipment
Weapon
verb/equip() //Make a verb called "equip"
if(usr.W) return //If W is TRUE, or if the player has something equipped (weapon), stop the verb
usr.W=src //Else, make W equal the weapon
src.suffix="Equipped" //Set the weapon's suffix
usr.overlays+=/obj/Overlays/weapon //Add the overlay
verb/unequip() //Make a verb called "unequip"
if(!usr.W) return //If W is FALSE, or if the player has nothing equipped (weapon), stop the verb
usr.W=null //Make W equal null, or nothing
src.suffix="" //Make the weapons suffix into an empty text string or null.
usr.overlays-=/obj/Overlays/weapon //Remove the overlay

//etc etc