ID:149466
 
Gazoot i have the code for the checking ID

obj
house
icon = 'house.dmi'
density = 1
verb
buy()
set src = oview(1)
if(owner)
usr << "This house is owned by [owner], so you can't buy!"
else
owner = usr
usr << "Congratulations, you bought a house!"
usr.money-=100000



var
mob/owner = null
verb
Check()
set src = oview(1)
Click()
usr << "This house belongs to [owner]"

The code works fine but when i log out of the game then log back in i have to re-buy the house. So there for will i need to add a Save file proc ? After the else
owner = usr
usr << "Congratulations, you bought a house!"
usr.money-=100000

part?¿
Err0r wrote:
The code works fine but when i log out of the game then log back in i have to re-buy the house. So there for will i need to add a Save file proc ? After the else
owner = usr
usr << "Congratulations, you bought a house!"
usr.money-=100000

part?¿

Yes, you need a save file! You can either save it right on spot, or when the host quits the game. If you save many things at once you might have some problems with file locking if you save in-game, but it's good to have some in-game file saving if the world crashes.

You can use world.Del() and world.New() to save and load the information you want. A simple example to get you started:
world
Del()
var/savefile/SaveF = new("houses.sav")
for(var/obj/house/H in world)
SaveF << H
..()

New()
spawn(0)
var/savefile/SaveF = new("houses.sav")
for(var/obj/house/H in world)
SaveF >> H


I used spawn(0) in the New proc, to be sure that all objects on the map have been populated before loading information to them. To get the hang of savefiles, you should read more in Dreamseekers help files and check out some save tutorials. Hope this helps!