ID:166683
 
I am haveing a hard time with car codes could someone help?
A bit more information on what you hope to achieve would be much better. "Car codes" doesn't say very much, so it isn't safe to expect help in that way. :)

O-matic
In response to O-matic
I need a code for cars that allowes you to get in and out of a car.
In response to Bobomaster
Oh, but that isn't hard!

You need an obj, and whenever it's clicked, delete the object, and change the user's icon. Example:
obj/car
icon='car.dmi'
Click()
usr.icon='car.dmi'
usr<<"You get in the car!"
usr.verbs+=/incar/verb/getout
del(src)
incar/verb/getout()
if(src.icon!='car.dmi') // if the user is not in a car.
src<<"You're not in a car!"
else
src.icon='sprite.dmi' // if the user is in the car, his icon gets changed back to normal.
src.verbs-=/incar/verb/getout //removes the incar verb.


O-matic
In response to O-matic
The problem is that people will be changing icons in the game. Is there a way to store thier icon and have the car move?
In response to Bobomaster
Make a temp var and store their icon in it, then when they get-out, set their icon to that temp var.
In response to O-matic
Bad way to do it. You might as well allow the player to enter the car's contents. That way, more than one people can enter the car if they want.

In order to do this, you have to send the player to the car's contents by setting the player's loc to the car by using Move(). We use Move() because you can disallow certain people or a certain amount of people inside the car's Enter() proc. The car's controls will be taken care of in client/Move().

client/Move(newloc, direc)
if(istype(mob.loc, /obj/car))
if(mob.loc.contents.Find(mob) == 1) // if the player is the first person in the car
mob.loc.Move(newloc, direc) // move the car
return 0 // but do not move the player if they are in a car
return ..() // otherwise, have normal movement

obj/car
var/max_passengers = 2
// maximum amount of passengers that may enter the vehicle

Enter(mob/A)
if(ismob(A))
if(length(src.contents) >= src.max_passengers)
// disallow the player to enter if the vehicle is full
return 0
return 1 // otherwise, allow it

proc
GetIn(mob/M)
if(src.Move(M))
M << "You get in the car."
if(src.contents.Find(M) == 1)
M << "You are the driver."
else
M << "You are a passenger."
else
M << "There is not enough space in the car. The car only holds [src.max_passengers] person\s"

GetOut(mob/M)
if(src.Move(get_step(M, turn(M.dir, -90)))
// make them move to the left side of the car
M << "You get out of the car."
if(length(src.contents))
var/mob/newdriver = src.contents[1] // get the first person in the car's contents
if(newdriver)
newdriver << "You are the new driver of the car!"

suv
max_passengers = 7

bus
max_passengers = 21


~~> Unknown Person
In response to Unknown Person
The things you all learn on these forums... Thanks for the correction.

O-matic