ID:950190
 
Keywords: guild, housing, list, world
Code:
var
list
GuildKeys[0]
area
inside
GuildDoor
icon = 'Guild Stuff.dmi'
icon_state = "Area"
var
guildid = ""
gtag
Enter(mob/M)
if(istype(M,/mob/Player))
if(src.guildid)
if(src.guildid != M.guildid)
if(!M.toldctf)
M << output("This house belongs to a different guild", "notices")
M.toldctf = 1
spawn(30)
M.toldctf = 0
return
else
return..()
else
return ..()
if(istype(M,/obj/projectile))
del M
..()
Guild1
gtag = 1
Guild2
gtag = 2
Guild3
gtag = 3
obj
Guildkey
icon = 'Guild Stuff.dmi'
icon_state = "Key"
var
guildid = ""
gtag
accesslevel = 4
access = 1
price = 0
LeftClick()
if(get_dist(src,usr) > 1)
return
if(usr.alertopen)
return
if(src.guildid)
if(usr.guildid == src.guildid)
if(usr.guildlevel >= accesslevel)
usr.alertopen = 1
var/choice = alert(usr, "What do you want to do?","Guild House","Nothing","Change Access","Disown")
if(choice == "Nothing")
usr.alertopen = 0
return
if(choice == "Change Access")
var/check = alert(usr,"Do you want to toggle the house access?","Current Access Status: [src.access ? "Private" : "Public"]","No","Yes")
if(check == "No")
usr.alertopen = 0
return
else
if(src.access)
src.access = 0
else
src.access = 1
usr << output("<Font Color = Gray>Guild House access is now [src.access ? "Private" : "Public"]","notices")
if(choice == "Disown")
var/confirm = alert(usr,"Are you sure you want to disown this location","Guild House","No","Yes")
if(confirm == "No")
usr.alertopen = 0
return
else
GuildKeys -= src
for(var/area/inside/GuildDoor/G in world)
if(G.gtag == src.gtag)
G.guildid = ""
usr.alertopen = 0
usr << output("<Font Color = Gray><i>Guild House has been vacated</i>","notices")
usr.alertopen = 0
else
usr.alertopen = 1
var/q = alert(usr,"Do you want to buy this Guild House?","Guild House Cost: [src.price]","Yes","No")
if(q == "No")
usr.alertopen = 0
return
else
src.guildid = usr.guildid
GuildKeys += src
for(var/area/inside/GuildDoor/G in world)
if(G.gtag == src.gtag)
G.guildid = usr.guildid
usr << output("<Font Color = Teal>This Guild House has been aquired for your guild.","notices")
for(var/mob/Player/M in world)
if(M.guildid == usr.guildid)
M << output("<Font Color = Teal>A Guild House has been aquired for the guild at [src.x],[src.y].")
usr.alertopen = 0
Guild1
gtag = 1
Guild2
gtag = 2
Guild3
gtag = 3


Problem description:
I know this has been asked before but I haven't seen any example that looked like it would be helpful so I'm asking for help with my take on guild houses. I'm trying to save the which guilds own which house by using a guild id var that belongs to the area the house is in and a keypad obj that would have the same id but when i try to add the obj to the world list GuildKeys I get a mismatch type error. Can someone help me fix this or advise me on how to make a better system.
Bumped for help
What need have you to add the obj into the GuildKeys listing? You should be able to link guild keys to the guild house via guildid. That would really be all you need

obj/GuildKey
var/guildid=00000
verb/Give()
if(usr.guildid!=src.guildid){ alert("This key doesn't belong to your guild!"); return; }
if(!src.CanGiveKey){ alert("You don't have permission to give out guild keys!"); return; }
var/mob/m=input("Who do you want to give this guild key to?") as mob in players-usr
Move(m)
mob/proc/BuyGuildKeys(n as num)
if(!n||n<0) return
while(n){ var/obj/GuildKey/o = new; o.guildid=src.guildid; src.contents+=o; n--; }


This, of course, is unfinished and only serves as an example of how to go about what it is you intend.
I'm sorry if the post is worded wrong. There isn't actual "keys" guildid is used to refer to a guild as a whole and I'm trying to save what guild owns the house after a reboot.
In response to Shades12163
http://www.byond.com/docs/ref/info.html#/savefile

I know what guildid is for. I thought you were having issues with the keys.

I'm trying to save the which guilds own which house by using a guild id var that belongs to the area the house is in and a keypad obj that would have the same id but when i try to add the obj to the world list GuildKeys I get a mismatch type error. Can someone help me fix this or advise me on how to make a better system.

You simply need to insert into a savefile either a pre-defined list or a list made uppon saving. Which I assume is the issue you're having.

var/list/GuildKeys=new()
Thats the problem, when I try to add to GuildKeys I get an error message saying type mismatch
In response to Shades12163
Did you attempt defining the list differently? Like as I suggested, with new()? list/listname[0] comes out null in DM.
Yes that was the first variation I tried
After many tries of trying to fix this I simply changed the name of GuildKeys to Houselist and now it seems to be working fine. So now I'm asking if there is a reason that naming it GuildKeys wouldn't work?