ID:142064
 
Code:
            Click()
if(!game)
usr <<"There's no game going on."
return
if(!usr.ingame)
usr<<"You aren't even playing.."
return
else
if(usr.loc==src.loc)
if(src.owned)
usr << "[src.owner] owns this property"
return
else
switch(input("Would you like to buy the property?", text) in list("Yes","Nevermind"))
if("Yes")
if(usr.money<<src.cost)
usr << "You don't have enough money!"
else
usr.money -= src.cost
src.owned=1
src.owner=usr.name
usr << "You bought [src] for $[src.cost]!"
(returnPlayers()-usr) << "[usr] bought [src] for $[src.cost]"
if("Nevermind")
return
if(src.owner==usr.name)
switch(input("You own this property, what do you want to do with it?",text) in list("Buy a house","Buy a hotel","Nothing"))
if("Buy a house")
if(!src.hotel)
if(src.houses>=4)
usr<<"You have to buy a hotel now, you can't buy anymore houses."
return
else
usr<<"Ok then."
src.houses++
usr.money-=src.housecost
(returnPlayers()-usr) << "[usr] bought a house for [src.name] and now house [src.houses]!"
return
if(src.hotel)
usr << "You can't buy a house, since you have a hotel on the property already."
return
if("Buy a hotel")
if(!src.houses)
if(hotel)
usr << "You already have a hotel on this property!"
return
else
usr << "You need four houses before you can buy a hotel."
return
if(src.houses==4)
usr << "You buy the hotel."
usr.money-=src.housecost
src.houses=0
(returnPlayers()-usr) << "[usr] now has a hotel on [src.name]"
return

else
if(src.owned)
if(src.houses >> 0)
usr << "[src.owner] owns this property, and it has [src.houses]"
return
if(src.hotel)
usr << "[src.owner] owns this property, and has a hotel on it."
return
else
usr << "[src.owner] owns this property, which is [src]."
return
if(!src.owned)
usr << "No one owns this property yet."


Problem description: Uhh, I think that it has something to do with what I did with their locations... No matter if I'm on it or not, it tells me "No one owns this property yet" (Which is at the bottom of the proc)

Have you bought the house yet.
In response to XxDragonxXDMxX
Can't buy the house if I haven't bought the property yet.
In response to SHSPlyr03
When you buy the property what happens.
In response to XxDragonxXDMxX
You can't buy the property! xD
I click it (The game's started, I'm in the game) and it says "No one owns this yet." I think it's because I did the if(usr.loc==src.loc) line wrong..
In response to SHSPlyr03
IT sounds as if you're playing a game of Monopoly.
I'm not sure but I think that this is the problem.
                        if(!src.owned)
usr << "No one owns this property yet."

In that case I think that you're telling the owner that no one owns this property.Even if there is no owner.
I'm not sure.
In response to XxDragonxXDMxX
But the way it should work out, it should check if I'm on top of that turf, and if I am, it gives me the option to buy it..

By the way, yeah.. I'm making a monopoly game.
In response to SHSPlyr03
    property
icon='icons.dmi' //The "Property" that the player will step on to see if he owns the propety and if he wants to buy it
icon_state = "Property"
Enter(mob/M) //When the player attempts to enter the proprty
if(src.owner.len == 0) //if no one owns the property
switch(alert(M,"Do you wish to buy this house for $10,000?","Buying property","Yes","No")) //makes a pop up that will as if the player wishes to buy the house, comes with two options..Yes and No
if("Yes") //if the player picked Yes
if(usr.Money <= 9999)
usr<<"You need 10000 Dollars to Buy A Property!"
else
usr.Money-=10000
M<<"Welcome to your new property"
src.owner.Add(M.key) //Adds M.key to the owner list

Its just a part of a code, not sure if its helpful or anything. I think you should use Enter(mob/M)
In response to XxDragonxXDMxX
This can be simplified and be made more efficient. Why bothering asking them to buy the property if they dont have enough money for it?
turf/var/owner
turf/var/Price

turf/property
icon='icons.dmi' //The "Property" that the player will step on to see if he owns the propety and if he wants to buy it
icon_state = "Property"
Price=10000
Entered() //When the player has entered
if(!turf.owner) //if no one owns the property
if(src.Money < price){return}//If the dont have enough, dont bother doing anything
switch(alert("Do you wish to buy this house for $10,000?","Buying property","Yes","No")) //makes a pop up that will as if the player wishes to buy the house, comes with two options..Yes and No
if("Yes") //if the player picked Yes
src.Money-=10000; src<<"Welcome to your new property"; turf.owner=usr.name //There can only be one owner. No need for a list
else{usr<<"You didn't buy [src]"; return}
else{src.PropertyPay()} //I'd suggest adding a proc that automatically does the money exchange here
You made a common mistake. << is not less than; it's the bitwise left shift operator. < is what you wanted.

Commonly confused operators:

| - | is another bitwise operator; || is what means "or" and is usually placed in an if statement.

& - Another bitwise operator. && is what means "and" and is usually placed in an if statement.

<< and >> - Both are bitwise shift operators. < means less than and > means greater than. Also, <= and >= mean less than or equal to and greater than or equal to respectively.

^ - More bits! ^ is the bitwise XOR operator, while ** and **= are for exponents (powers).
In response to Quiet Screams
Bad things about that code:

using ; and brackets are very annoying to read. BYOND gives you the ability to use tabs and returns instead; use it!

Never use usr in a proc (minus Click() etc.). Always use the built in args (Entered(atom/movable/A) where A would be what entered the atom and src would be the atom).

EDIT: I found more:

You didn't make sure usr was a mob. Runtime errors are annoying.
In response to Jeff8500
Fixed. I don't mind reading them that way at all. He doesn't have to use my code if it bothers him lol.
In response to XxDragonxXDMxX
No, Enter() shouldn't be modified unless it directly affects whether something can enter the atom or not.

What if their money is in the decimals? Use if(money < 10000) instead.

Is src.owner a list now? len is defined under lists, not text, and if(!owner) would work better.

Lack of Boolean logic. if(var==0) isn't as good as if(!var) and if(var==1) isn't as good as if(var). Also, && and || can be used to further improve code.

Add() is slower than += and is unnecessary in this situation.

Without returning a true value at the end of Enter(), nothing can enter the atom.

That switch() is unnecessary; the below code would have worked just as well:

if(alert(M,"text","buying","yes","no")=="yes")


I was a little (very :P) nitpicky when pointing out some things, but you didn't use usr, so I think that cancels out some of the problems =]
In response to Quiet Screams
What did you fix? M is still undefined and usr is still in there (you still didn't check if usr/M is a mob either; runtime errors!). I'm telling you, it's much harder to read and fix code like that :P
In response to Jeff8500
I missed M, thats all. it was unnecessary, the way he had it. Give me a sec, Ill edit again xD
In response to Quiet Screams
No, because src is a turf, not a mob.