Yes, another door question. Sorry for making another one but I've been trying to get this to work for a while. What I'm trying to do is make a certain door unownable.
I know its not this simple but this is what I have so far. I have no errors and it doesn't do anything.
[LUA]
function Doorowning( ply )
local trace = ply:GetEyeTrace()
if( trace.Entity:IsValid() and trace.Entity:IsOwnable() and ply:GetPos():Distance( trace.Entity:GetPos() )) < 100 then
if(trace.Entity:OwnedBy( ply ) ) then
trace.Entity:UnOwn( ply )
ply:AddMoney( -50 )
ply:PrintMessage( HUD_PRINTTALK, "You have unowned this door.")
else
if trace.Entity:IsOwned() then
ply:PrintMessage( HUD_PRINTTALK, "This door is allready owned.")
return end
if not trace.Entity:IsOwnable() then
return end
if not trace.Entity:IsOwned() then
trace.Entity:Own( ply )
ply:AddMoney( -50 )
ply:PrintMessage( HUD_PRINTTALK, "You have bought this door for 50$")
end
end
end
end
concommand.Add("buydoor", Doorowning)
function unownable(ply)
local trace = ply:GetEyeTrace()
if( trace.Entity:IsValid() and trace.Entity:IsOwnable()) then
if(trace.Entity:IsOwned(ply)) then
trace.Entity:UnOwn( ply )
trace.Entity:IsOwnable()
return false
end
end
end
concommand.Add("munownable", unownable)
[/LUA]
Is own-able function.
[LUA]
local meta = FindMetaTable( "Entity" );
function meta:IsOwnable()
local class = self:GetClass();
if( class == "func_door" or
class == "func_door_rotating" or
class == "prop_door_rotating" or
class == "prop_vehicle_jeep" or
class == "prop_vehicle_airboat" ) then
return true;
end
return false;
end
[/LUA]
Does 'buydoor' work? Or is everything that's not working?
buydoor works it just wont let me sell the door after I buy it.
[quote][LUA]
if(trace.Entity:OwnedBy( ply ) ) then
trace.Entity:UnOwn( ply )
ply:AddMoney( -50 )
ply:PrintMessage( HUD_PRINTTALK, "You have unowned this door.")
[/LUA]
[/quote]
You're making the player lose money for selling a door?
And what are you trying to do with the unownable command?
I can't tell what you're trying to do, so I can't tell you what to change.
Yeah, I forgot to remove that. I was attempting ot make it so the Door isn't Own-able but I really have no clue what I'm doing I was just trying before I came here.
Sorry, you need to Log In to post a reply to this thread.