ID:140777
 
Code: ?
client
proc
Load_Character()
var/savefile/s1=new("players/[src.mob.key]/Slot_1.sav")
s1["mob"]>>src.mob
s1["x"]>>src.mob.x
s1["y"]>>src.mob.y
s1["z"]>>src.mob.z
for(var/C in src.mob.CV)
src.mob.verbs+=C
usr.rest()
usr.faint2()
SaveProc()
var/savefile/s1=new("players/[src.mob.key]/Slot_1.sav")
src.mob.CV=src.mob.verbs
s1["CV"]<<src.mob.CV
s1["mob"]<<src.mob
s1["x"]<<src.mob.x
s1["y"]<<src.mob.y
s1["z"]<<src.mob.z
s1["name"]<<src.mob.name


Problem description: When i log out of the server while having clothes on and then log on again, i cant take "off" the clothes. it says "you take off your shirt" but visually the shirt is still there.


this is the saving and loading, anything here that would result in my problems? if my problems are unclear tell me and i will try to elaborate. also if you find anything insufficient, feel free to suggest changes.

thanks in advance,
regards
Narutostory
By saving mob, you're already saving the mob's name.

Aside from that, the problem actually lies on how you add the clothes to the overlays list, not on how you save/load from what I can see.
In response to Andre-g1
is something wrong here?

obj
Tshirt
icon = 'Items.dmi' // the icon file
icon_state = "CustomTShirt" // name of the icon state
layer = MOB_LAYER +1 // This sets the layer above the mob layer, making it appear infront of you not behind you.
suffix = "" // this line is not really needed as the suffix is blank by default.
verb
Get()
set src in oview(1) // 1 or 0 dunno what is more accurate. this decides how many tiles you can stand from the object.
// 0 means you need to stand on it, 1 is beside it.
set category = null // this is so we do not have the verb in the tabs menu. which is how i want it :)
if(Move(usr)) // if the object is moved to the user(inventory)
usr << output("you pick up a [src].","chat")//this line appears
return
else
usr << output("You are unable to pick up the: [src].","chat")//else this happens :P
return
Drop()//verb for dropping the object, obviously
set src in usr.contents // this means that the object needs to be in your inventory for this verb to be active.
set category = null
if(Move(usr))
usr << output("you drop a [src].","chat")
src.loc = usr.loc // drops the object.
return
else
usr << output("You are unable to drop the: [src].","chat")
return
Use()
set name = "Wear/Remove"
set src in usr.contents
set category = null
if(src.worn == 0)
usr << output("You put the shirt on","SM") // or say something more fitting :P
src.suffix = "Equipped" // probably bad spelling.
usr.overlays += src
src.worn = 1
return
else
usr << output("You took the shirt off","SM") // or something more fitting :P
usr.overlays -= src
src.suffix = ""
src.worn = 0
return
In response to Narutostory
*bump*

still havent found out how to solve this problem
In response to Narutostory
Narutostory wrote:
*bump*

still havent found out how to solve this problem

I have a very similar problem.
Equip()
set src in usr //Can only be used from within a player's inventory.

//Command-only variables
var
inventory_slot
//First, lets get the inventory slot.
if(istype(src,/obj/equipment/Head))
inventory_slot = "Head"
if(istype(src,/obj/equipment/neck))
inventory_slot = "Neck"
if(istype(src,/obj/equipment/body))
inventory_slot = "Body"
if(istype(src,/obj/equipment/arms))
inventory_slot = "Arms"
if(istype(src,/obj/equipment/fingers))
inventory_slot = "Fingers"
if(istype(src,/obj/equipment/hands))
inventory_slot = "Hands"
if(istype(src,/obj/equipment/legs))
inventory_slot = "Legs"
if(istype(src,/obj/equipment/weapon))
inventory_slot = "Weapon"
if(istype(src,/obj/equipment/secondary))
inventory_slot = "Secondary"
if(istype(src,/obj/equipment/feet))
inventory_slot = "Feet"
if(usr.equipment[inventory_slot] == src)
return
//Now to see if the person has something else in the slot.
if(usr.equipment[inventory_slot])
//Unequip the equipped item
var/obj/equipment/uneq = usr.equipment[inventory_slot]
uneq.Unequip(usr)
usr.Close_Inventory()
if(src.equipped == 0)
usr.move = 1
src.equipped = 1
src.name = "[src]"
src.overlays += 'misc.dmi'
usr.eatk += src.eatk
usr.edef += src.edef
usr.Atkspeed = src.Atkspeed
usr.equipment[inventory_slot] = src
usr.Save()
usr.Inventory()
usr<<"[inventory_slot] equipped!"


Whenever I equip something... I can equip and unequip it fine ... but after I log out and back in, I can equip other items of the same type.
Here is my saving:
mob/proc
Save()
if(src.z==2) return
var/savefile/F = new("Players/[src.key].sav")
F["LastX"]<<src.x
F["LastY"]<<src.y
F["LastZ"]<<src.z
F["dir"]<<src.dir
F["name"]<<src.name
F["icon_state"]<<src.icon_state
F["Level"]<<src.Level
F["Attack"]<<src.Atk
F["Defense"]<<src.Def
F["Str"]<<src.Str
F["Vit"]<<src.Vit
F["Int"]<<src.Int
F["Dex"]<<src.Int
F["MaxHP"]<<src.MaxHP
F["MaxMP"]<<src.MaxMP
F["Exp"]<<src.Exp
F["Nexp"]<<src.Nexp
F["Gold"]<<src.Gold
F["BankedGold"]<<src.BankedGold
F["Class"]<<src.Class
F["contents"]<<src.contents
F["statpoints"]<<src.Statpoints
F["Items"]<<src.Items
F["Eva"]<<src.Eva
F["Acc"]<<src.Acc
F["Critchance"]<<src.Critchance
F["Atkspeed"]<<src.Atkspeed
F["eacc"]<<src.eacc
F["baseacc"]<<src.baseacc
F["baseatk"]<<src.baseatk
F["basedef"]<<src.basedef
F["eatk"]<<src.eatk
F["edef"]<<src.edef
F["equipment"]<<src.equipment
F["Skills"]<<src.Skills
//F["zzzz"]<<src.zzz

src.CalcAtk()
src.CalcDef()
src.CalcAcc()

Load()
if(fexists("Players/[src.key].sav"))
var/savefile/F = new("Players/[src.key].sav")
var/LastX
var/LastY
var/LastZ
F["LastX"]>>LastX
F["LastY"]>>LastY
F["LastZ"]>>LastZ
F["dir"]>>src.dir
F["name"]>>src.name
F["icon_state"]>>src.icon_state
F["Level"]>>src.Level
F["Attack"]>>src.Atk
F["Defense"]>>src.Def
F["Str"]>>src.Str
F["Vit"]>>src.Vit
F["Int"]>>src.Int
F["Dex"]>>src.Int
F["MaxHP"]>>src.MaxHP
F["MaxMP"]>>src.MaxMP
F["Exp"]>>src.Exp
F["Nexp"]>>src.Nexp
F["Gold"]>>src.Gold
F["BankedGold"]>>src.BankedGold
F["Class"]>>src.Class
F["contents"]>>src.contents
F["statpoints"]>>src.Statpoints
F["Items"]>>src.Items
F["Eva"]>>src.Eva
F["Acc"]>>src.Acc
F["Critchance"]>>src.Critchance
F["Atkspeed"]>>src.Atkspeed
F["eacc"]>>src.eacc
F["baseacc"]>>src.baseacc
F["baseatk"]>>src.baseatk
F["basedef"]>>src.basedef
F["eatk"]>>src.eatk
F["edef"]>>src.edef
F["equipment"]>>src.equipment
F["Skills"]>>src.Skills

Everything else saves fine..
mob
var
list
equipment = list("Head","Neck","Body","Arms","Secondary","Hands","Weapon","Legs","Feet","Fingers")
//This sets up a list with nine pre-defined body types
//You can access each with "equipment[space]"
and this is what my list looks like
The problem is the way you handle icons, probably.
In response to Karnaji
The issue is that you are saving your mobs improperly. The proper method is like so:

mob/proc/save()
var/savefile/F = new(blah)
F << src


By not doing it this way, and instead saving each variable individually, any objects which are in multiple lists are saved multiple times instead of resolving the references as a single object. So, a new object is created for each thing in your equipment list, which is not in your contents.

And don't hijack other people's threads.
In response to Narutostory
The src when you add the object to overlays and the src after the save/load are not considered the same enough to map to the same overlay. The ideal solution would be the not save overlays (in mob/Write() have F.dir -= "overlays") and then reconstruct them on load (in mob/Read()). However, a short-term solution is just to construct an icon object from the clothing object, and use that. IE:

var/icon/I = new(src.icon, src.icon_state)
overlays += I //or -=
In response to Garthor
Better use an /obj or /image instead of /icon for those kind of things, as the latter actually opens and creates a new icon, icon file and eventually resource file, so you should only do so when you need to.
In response to Kaioken
And the other two don't work unless if I've forgotten about one of the magical overlay variables. Hence, it's not my first suggestion.
In response to Garthor
Work, as far as I know and remember, but then again I don't know what your context is or what you mean by that magic and as such.