• Changing the owner of something in darkrp
    4 replies, posted
I am trying to make a claim function on some printers. I need to know how to go about changing the ownership. Any help would be nice.
I would do it like this. [lua]-- -- if ent.CPPISetOwner and isfunction(ent.CPPISetOwner) then ent:CPPISetOwner( newOwner ) else ent.Owner = newOwner ent.OwnerID = newOwner:SteamID() end [/lua] It first checks if the entity has a function called CPPISetOwner (which it will have, if you use FPP or some other prop protection system). If it doesn't have a CPPISetOwner function, it will just set the Owner and OwnerID on the entity, which is compatible with FPP (I believe).
I tried that on printers but nothing happens here is the code. [CODE] concommand.Add("printer_claim", function(ply, cmd, args) local printer = ply.LastUsedMP; if (IsValid(printer) and printer:GetClass() == "upgrade_money_printer") then if printer:GetPos():Distance(ply:GetPos()) > MaxUseDistance then GAMEMODE:Notify(ply, 1, 4, "Too Far away from the printer.") return end printer:CPPISetOwner( ply ) GAMEMODE:Notify(ply, 1, 4, "You have claimed the printer.") end end )[/CODE]
Can any please help with this?
What about using eye trace, so you look at it instead? (ply:GetEyeTrace( )) Would work out if its the distance causing the problem, or something different.
Sorry, you need to Log In to post a reply to this thread.