since the Gravity Gun can be really hard to use for some entities, I decided to allow the usage of physgun for everyplayer on their own entities.
At the current state, player’s can’t physgun their own entities and I did not found anything useful in FPP.
So I’m wondering whether anybody know how this can be done?
ent:SetCPPIOwner( player )
Thanks for the quick reply. I can’t find this function in the GMod Wiki. Is it a DarkRP funciton and is there any documentation?
CPPI is documented in ULX, its the default term for prop protection stuff.
hook.Add( "playerBoughtCustomEntity", "playerscanphysgunboughtentities", function (ply, entityTable, ent, price) ent:CPPISetOwner(ply) end )
Am I right with this?
You should be. Let me check my way.
**Edit: **You’re gonna run into problems. Make sure you’re checking that it’s that entity you want, and not every single entity. Either add an ent:GetClass() check, or add ENT.IsYourEntity = true in the shared file of the entity.
Hmm, I don’t understand that. I want the player to be able to touch every entity he bought with physgun, so why do I need a check?
Because of the printers, if they can pysgun those, they can freeze those, which would make them unstealable.
You could just edit the entities you want to physgunable.
Oh. If you want every purchased entity to be physgunnable, then the code you have specified will work fine.
Yeah, I want to allow everyone to freeze their entitys, because sometimes it can be useful.
My next question would be, how I would be able to make the gravity gun unfreeze every entity, that gets “right clicked”
Check if the player is holding the phys cannon and check whatever button they need to press and do something like this:
hook.Add( "GravGunOnPickedUp", "UnfreezeGravGunnedEntities", function( ply, ent ) ent:SetMoveType( MOVETYPE_VPHYSICS ) end )
How about this?