Code to stop player from pocketing a certain entity.

Can someone please help me create a line of code or lua file that I can put entities in so that players cannot use the DarkRP pocket tool on those. The entity name is Dumpster and I don’t want them to be able to store that item in their pocket. The settings in DarkRP does not work, I have the model and the entity in there to be blacklisted but they are still able to pocket those items. Please help!

You can use the hook canPocket ( http://wiki.darkrp.com/index.php/Hooks/Server/canPocket ) and then check for an entity property like noPocket that you set on the entities you don’t want to be pocketable.

I don’t know how to write any GLua, Would you be able to create the line of code and tell me where to put it at?

Sure thing, code:


https://scriptfodder.com/jobs/

Put it in: “We\are
ot\your\private\developers.lua”

[lua]
hook.Add(“canPocket”, “NoDumpsters”, function(ply, ent)

if ent:GetClass() == "dumpster" then
	return false, "You can't do that on dumpsters"
end

end)
[/lua]

You might wan’t to replace “dumpster” with the actual entity class.

Just create some file in lua\autorun\server and name it “whateveryoulike.lua” and paste the code.

EDIT: Just corrected the code, according to the documentation it was required to send a reason in case it would return false.

Pretty sure there’s a pocket blacklist in the config file

Edit; GM.Config.PocketBlacklist

Don’t have to put disrespectful remarks, it was a simple request, you aren’t contributing to my thread so don’t comment on it. For everyone else that helped, thank you very much. Hopefully I can get this to work.