• Using SetNWString
    0 replies, posted
I have written this (shared): [CODE]-- Door Functions local meta = FindMetaTable("Entity") -- Ownership Type function meta:SetOwnershipType(OwnershipType) if(self.Entity:IsValid()) then self:SetNetworkedString("OwnershipType", OwnershipType) end return false end function meta:GetOwnershipType() if(self.Entity:IsValid()) then if(self:GetNetworkedString("OwnershipType") != nil) then return self:GetNetworkedString("OwnershipType") else self:SetNetworkedString("OwnershipType", "ownable") return self:GetNetworkedString("OwnershipType") end end return nil end[/CODE] in a server side file I have: [CODE]local AllDoors = ents.FindByClass("*door*") for k,v in pairs(AllDoors) do v:SetOwnershipType("ownable") v:SetNetworkedString("OwningPlayers", glon.encode({})) v:SetNetworkedString("AllowedGroups", glon.encode({})) end[/CODE] Yet inside: [CODE]function BuyDoor(Player, Command, Arguments) local EyeTrace = Player:GetEyeTrace() local TraceEntity = EyeTrace.Entity; if(TraceEntity:IsValid() and TraceEntity:GetPos():Distance(Player:GetShootPos()) < 400) then if(string.find(TraceEntity:GetClass(), "door") != nil) then if(table.getn(TraceEntity:GetOwningPlayers()) == 0) then if(TraceEntity:CanOwn()) then TraceEntity:AddOwner(Player:SteamID()) else Player:ChatPrint("[RR] You cannot buy this door.") end else Player:ChatPrint("[RR] This door is already owned.") end end end end concommand.Add("srp_buydoor", BuyDoor)[/CODE] The TraceEntity:CanOwn() function returns false.
Sorry, you need to Log In to post a reply to this thread.