Sony_08

RP_Friendly_Physgun custom action working example

Nov 20th, 2022
1,003
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.50 KB | None | 0 0
  1. -- These bits are needed just in case your script loads before the friendly physgun addon:
  2. Sony_RPFriendlyPhys = Sony_RPFriendlyPhys or {}
  3. Sony_RPFriendlyPhys.CustomActions = Sony_RPFriendlyPhys.CustomActions or {}
  4.  
  5.  
  6.  
  7. -- This bit defines the entity "sony_tip_jar" as having a custom action.
  8. Sony_RPFriendlyPhys.CustomActions["sony_tip_jar"] = {}
  9.  
  10. -- And here we're going to define an OnFreeze action, which will run every time someone right clicks while carrying our entity:
  11. Sony_RPFriendlyPhys.CustomActions["sony_tip_jar"]["OnFreeze"] = function(ply, ent)
  12.  
  13.     -- You actually can fully freeze the tip jar in place if you are the owner, to prevent others from stealing it so easily.
  14.     if Sony_GetOwner(ent) == ply then      
  15.         return true -- Allows the entity to be frozen.
  16.     end
  17. end
  18.  
  19. -- And here we will add a custom action that checks if the person trying to pick up the entity is the owner of it. If they are then we let them pick it up.
  20. Sony_RPFriendlyPhys.CustomActions["sony_tip_jar"]["OnPickup"] = function(ply, ent)
  21.  
  22.     if Sony_GetOwner(ent) == ply then      
  23.         return true -- Allows the entity to be picked up.      
  24.     else
  25.         return false -- Disallow the entity from being picked up.
  26.     end
  27. end
  28.  
  29. -- Right now nothing uses it, but you can also call a function every time an entity is pulled with the gravity gun mode.
  30. -- (Hold left mouse and scroll down while looking at an entity that is out of range.)
  31.  
  32. Sony_RPFriendlyPhys.CustomActions["sony_tip_jar"]["OnPickup"] = function(ply, ent)
  33.     print("Being pulled!")
  34. end
  35.  
Advertisement
Add Comment
Please, Sign In to add comment