CanTool help.(Coding a PP)

If I want to disable using the toolgun on props other than the owner,
is this all that i need?



function CPP.CanTool( ply, tr, tool )
	if ( tr.Entity():GetOwner()==ply:Nick() ) then
		return true
	elseif (ply:IsAdmin() and GetConVar( "CPP_AdminCanDoAll" ):GetInt() == 1) then
		return true
	else
		return false
	end
end


No, **[Entity.GetOwner

http://wiki.garrysmod.com/favicon.ico](http://wiki.garrysmod.com/?title=Entity.GetOwner)** doesn’t return the prop protection owner like you assume here. Other than that, the code would fail if the player used a tool on the ground because tr.Entity will be nil in that case. Also, with your code it would still be impossible for admins to use tools on other people’s props, because you still check if the admin is the owner.

So will I create an NWString when a prop, ragdoll etc. are spawned is spawned?
SetNetworkedEntity(“OwnerEntity”)?
or
SetNetwordkedString(“Owner”)

Yes,
[lua]ent:SetNetworkedEntity( “Owner”, ent )[/lua]
or perhaps better:
[lua]ent:SetDTEntity( 0, ent )[/lua]

I figured out I’d have to do this:
[lua]
ent:SetNetworkedString(“Owner”, ply:Nick())
[/lua]

also.

Why? A networked entity is a lot more efficient. For the entity, the server only has to transfer a number, but a string is muuuch larger.

I recommend Overv’s method, because what happens if a player string escapes their name? Or if they just simply change it? Networked entities is the most reliable method.