ID:162882
 
On this example, Would i need to make a owner var for every car.
obj/var/owner

obj/car1
icon = 'car1.dmi'
if(owner == usr)
usr<<"this is your car"
obj/car2
icon = 'car2.dmi'
if(owner == usr)
usr<<"this is your car"
obj/car3
icon = 'car3.dmi'
if(owner == usr)
usr<<"this is your car"
obj/car4
icon = 'car4.dmi'
if(owner ==usr)
usr<<"this is your car"


Kylemark wrote:
On this example, Would i need to make a owner var for every car.
mob/player/var/carowned=null 

obj/car1
icon = 'car1.dmi'
owned = 0 //when someone gains ownership of the car set this to 1
verb
inspect(mob/player/P as mob in oview(1))
set src in oview(1)
if(owned == 1)
if(P.carowned == car1)
usr<<"this is your car"
else
..()
else if(owned == 0)
switch(input("Would you like to buy this car for 6000$?") in list("Yes","No"))
if("Yes")
if(usr.money < 6000)
usr << "We don't finance ya bum cash only!"
else if(usr.money >= 6000)
P.money -= 6000
P.carowned = car1 // this would only allow one car to be owned at a time you could ad more if's
owned = 1 // to avoid that though, check for carowned !null, and goto mob/player/var/carowed2 ect
if("No")
usr <<"Well keep looking around we have many nice things yes?"


anyhow I think this basically works might need a tweak or 2.



This doesn't look like it would do much of anything how it is you're if's would have no effect since they're not triggered anywhere. If these are going to be left on the street somewhere or something where anyone could walk up to them in the game you could make the usr var = to the car name.
In response to Kichimichi
The argument for that verb shouldn't be there, and all instances of "P" should be replaced with "usr". Additionally, ..() has no meaning when you are defining a new verb or proc (if you have to put the "verb" line before it). The first if() should just be if(owned), which is the proper way of checking a true/false value, and the second if() shouldn't even be there. 6000$ is incorrect, it should be $6000. "car1" in the verb should be "src" in every case. If you wanted to allow multiple cars to be owned, you would NOT create new variables. Instead, you would change the carowned var to a list.
In response to Garthor
ok, my game has a person making money to buy a car. Once he has a car, he can make more money, buy better cars

i dont want other players to be able to get in other peoples cars

In response to Kylemark
Good to hear.