ID:175200
 
So far in my game Im using SwapMaps so each user can have their own plot of land, but after the person leaves the land they cant re-enter...I made it so the game puts a house where the lasnd was claimed, I want it so when you Enter the house you get teleported to that houses land. Here's my coding:
mob
var
Savedx
Savedy
Savedz
verb
test()
Savedx = usr.x
Savedy = usr.y
Savedz = usr.z
new/turf/House(usr.loc)
var/swapmap/map=new("hq_[client.ckey]",60,60,3)
map.BuildFilledRectangle(locate(map.x1+26,map.y1+1,map.z1),\
locate(map.x1+35,map.y1+10,map.z1),\
/obj/house/Tile)
map.BuildRectangle(locate(map.x1+25,map.y1,map.z1),\
locate(map.x1+36,map.y1+11,map.z1),\
/obj/house/Wall)
new/obj/house/Door(locate(map.x1+30,map.y1,map.z1))
new/obj/house/Door(locate(map.x1+31,map.y1,map.z1))
usr.loc=locate(map.x1+30,map.y1+1,map.z1)
turf
House
icon = 'Ships.dmi'
icon_state = "Space_station"


How can I add the part so you enter the land when you enter the house? Thanks!
To access the house once saved, you'll have to load the map. In Bump() or whatever proc you use to determine the player is trying to enter, you'd do something like this:
var/swapmap/map=SwapMaps_Load("hq_[client.ckey]")
Then just pick a spot on the map where the door is supposed to be, and put the player at that point. When exiting, you'll probably want to check if the map is still in use, and if not then to unload it.

Lummox JR
In response to Lummox JR
Would it load the person trying to enter's key or the owner of the house's key?
In response to Koolguy900095
Koolguy900095 wrote:
Would it load the person trying to enter's key or the owner of the house's key?

The owner's key; otherwise it'd load the same player's house no matter where they went.

Lummox JR
In response to Lummox JR
Ok, I did all that but it still doesnt seem to be working...Here's what I did:
mob
var
Savedx
Savedy
Savedz
verb
test()
Savedx = usr.x
Savedy = usr.y
Savedz = usr.z
new/mob/House(usr.loc)
var/swapmap/map=new("hq_[client.ckey]",60,60,3)
map.BuildFilledRectangle(locate(map.x1+26,map.y1+1,map.z1),\
locate(map.x1+35,map.y1+10,map.z1),\
/obj/house/Tile)
map.BuildRectangle(locate(map.x1+25,map.y1,map.z1),\
locate(map.x1+36,map.y1+11,map.z1),\
/obj/house/Wall)
new/obj/house/Door(locate(map.x1+30,map.y1,map.z1))
new/obj/house/Door(locate(map.x1+31,map.y1,map.z1))
usr.loc=locate(map.x1+30,map.y1+1,map.z1)
mob
House
density = 0
icon = 'Ships.dmi'
icon_state = "Space_station"
Enter()
var/swapmap/map=SwapMaps_Load("hq_[client.ckey]")
usr.loc=locate(map.x1+30,map.y1+1,map.z1)


Did I do something wrong? Thanks!
In response to Koolguy900095
Koolguy900095 wrote:
Did I do something wrong?

You put usr in Enter(), which is a huge no-no, plus it should really be Entered() instead.

Lummox JR
In response to Lummox JR
Ok, It didnt work as Entered() and i changed the usr into src...Sooo I made it into a verb now I get the runtime error:

runtime error: Cannot read null.ckey
proc name: Land (/mob/House/verb/Land)
usr: Koolguy900095 (/mob)
src: House (/mob/House)
call stack:
House (/mob/House): Land()

EDIT: It works now I had to maek ti a turf! Oh and to make it work I have to put [usr.client.ckey] would it go to the users or the owner of the house's? This is what I have:
turf
House
density = 0
icon = 'Ships.dmi'
icon_state = "Space_station"
Entered()
var/swapmap/map=SwapMaps_Load("hq_[usr.client.ckey]")
usr.loc=locate(map.x1+30,map.y1+1,map.z1)<dm>
In response to Koolguy900095
Changing usr to src in Entered() isn't correct, since src is the turf. However usr is wrong, and you shouldn't use it either. Entered() takes two arguments, usually only one of which you need: The first argument is the atom that entered, which would be the player. (It could also be anything else that steps onto the turf, so double-check that the atom is actually a player.)

Lummox JR
In response to Lummox JR
I think I got the maps to work...Ill have to test it later online. I've noticed there is a save all proc, but I couldnt find load all. How could I make it so it loads all the Maps?