ID:262363
 
Code:
mob/Car_1/Move()
..()
for(var/mob/M in world)
if(M.vehicle == src)
M.loc = locate(src.x,src.y,src.z)

mob/Move()
if(src.vehicle)
return 0
..()
if(src.client)
for(var/mob/Car_1/M in world)
if(M.driver == src)
M.loc = locate(src.x,src.y,src.z)
M.dir = usr.dir
M.Move(locate(src.x,src.y,src.z))

mob/var
driver
maxpassengers = 0
currentpassengers = 0
vehicle = null

mob/Car_1
maxpassengers = 2
see_invisible = 100
icon = 'Cars.dmi'
icon_state = "Car 1"
npc = 1
verb/Hop_In()
set src in oview(1)
if(src.driver == null && !usr.vehicle)
view(src) << "[usr] hops into the [src] and begins driving!"
usr.invisibility = 100
usr.loc = locate(src.x,src.y,src.z)
src.driver = usr
else
if(src.currentpassengers < src.maxpassengers && !usr.vehicle && src.driver != usr)
view(src) << "[usr] jumps into the [src] and rides as [src.driver]'s passenger!"
usr.vehicle = src
usr.invisibility = 1
usr.loc = locate(src.x,src.y,src.z)
src.currentpassengers += 1
verb/Get_Out()
set src in view(0)
if(src.driver == usr)
view(src) << "The driver of the [src] ([usr]) hops out, leaving no driver behind!"
usr.vehicle = null
src.driver = null
walk_rand(usr,2)
sleep(2)
walk(usr,0)
usr.invisibility = 0
world << usr.vehicle
if(usr.vehicle == src)
if(src.driver != usr)
view(src) << "[usr] hops out of the [src], leaving an extra space for a new passenger!"
src.currentpassengers -= 1
src.vehicle = null
walk_rand(usr,2)
sleep(2)
walk(usr,0)
usr.invisibility = 0
Click()
usr << "The [src] is being driven by [src.driver] along with [src.currentpassengers] passengers."
DblClick()
usr << "The current passengers of the [src] driven by [src.driver].."
for(var/mob/M in world)
if(M.client)
if(M.vehicle == src)
usr << "[M]"


Problem description:
Ok everything work good including the car drives ok.
Only thing i want the car appear on the game when you log in and t he car apper at the location you last left it.
And if your driving it and log out, and goes back in the car next to you, otherwise if not driving the car is there where you last left it.
Please and thank You

Of the endless possibilities of ways to save locations, lets get original:

-Create a set of variables for the cars to hold the location coordinates
-Make sure that before you log off, the variables are set to the cars current coordinates

-Create a variable(not specific to mobs and such) of the list type
-Make sure that before you log off, the list gets saved(of course)
-Make sure that before you log off, and before the list is saved, you add each car to the list

-For when you log back in, make sure that there is some sort of proc to read all of the cars from the list, create them to the world, and send them to their previous, saved coordinates.

Keep in mind that there are other, more efficient ways out there. This is just one representation of it from someone who doesn't feel like using the standard style of doing this right now. Hope this concept works for you.

Absolute Zer0
In response to Absolute Zer0
and hwo do you do that lol can ya least show me how ?
In response to Sayian Hunter
var/Cars[0]
mob/Car
var/last_x
var/last_y
var/last_z

client/Del()
for(var/mob/Car/C in world)
C.last_x=C.x
C.last_y=C.y
C.last_z=C.z
Cars+=C
Save()
..()
proc/Reload_Cars()
Load() //Reload Cars var and other stuff
for(var/car in Cars)
new car(locate(car.last_x, car.last_y, car.last_z))

....and so on. I'm sure that in use, this code might contain an error or two, but I have no intention of debugging it right now. Try this approach and let me know how it turns out.

Absolute Zer0
In response to Absolute Zer0
That method you have just used saves after one and every person logs out. I can imagine it getting the game extremely laggy, especially at world shutdown. Because it will be saving the cars for every mob that logs out, Dream Seeker may crash and not save at all.

I suggest using world/Del()
In response to CaptFalcon33035
As I said, I didn't put too much thought into the code. When someone asks for help, they shouldn't be looking for exact code to copy and paste, they should be looking for a concept, and the concept here was the saving of locations and such.
In response to Absolute Zer0
Absolute Zer0 wrote:
As I said, I didn't put too much thought into the code.

If you aren't going to put any thought into your posts, then please don't post at all.

When someone asks for help, they shouldn't be looking for exact code to copy and paste, they should be looking for a concept, and the concept here was the saving of locations and such.

Your concept was wrong, Absolute. Falcon was criticizing the concept: did you even read his post before replying to it?