mirror of
https://github.com/lifestorm/wnsrc.git
synced 2025-12-17 05:43:46 +03:00
Upload
This commit is contained in:
42
gamemodes/base/gamemode/variable_edit.lua
Normal file
42
gamemodes/base/gamemode/variable_edit.lua
Normal file
@@ -0,0 +1,42 @@
|
||||
--[[
|
||||
| This file was obtained through the combined efforts
|
||||
| of Madbluntz & Plymouth Antiquarian Society.
|
||||
|
|
||||
| Credits: lifestorm, Gregory Wayne Rossel JR.,
|
||||
| Maloy, DrPepper10 @ RIP, Atle!
|
||||
|
|
||||
| Visit for more: https://plymouth.thetwilightzone.ru/
|
||||
--]]
|
||||
|
||||
|
||||
--
|
||||
-- Called when we've received a call from a client who wants to edit
|
||||
-- a particular entity.
|
||||
--
|
||||
function GM:VariableEdited( ent, ply, key, val, editor )
|
||||
|
||||
if ( !IsValid( ent ) ) then return end
|
||||
if ( !IsValid( ply ) ) then return end
|
||||
|
||||
--
|
||||
-- Check with the gamemode that we can edit the entity
|
||||
--
|
||||
local CanEdit = hook.Run( "CanEditVariable", ent, ply, key, val, editor )
|
||||
if ( !CanEdit ) then return end
|
||||
|
||||
--
|
||||
-- Actually apply the edited value
|
||||
--
|
||||
ent:EditValue( key, val )
|
||||
|
||||
end
|
||||
|
||||
--
|
||||
-- Your gamemode should use this hook to allow/dissallow editing
|
||||
-- By default only admins can edit entities.
|
||||
--
|
||||
function GM:CanEditVariable( ent, ply, key, val, editor )
|
||||
|
||||
return ply:IsAdmin() || game.SinglePlayer()
|
||||
|
||||
end
|
||||
Reference in New Issue
Block a user