include("cl_init.lua")
local meta = FindMetaTable( "Player" );
local function NotifyPlayers( msg )
if ( !msg ) then return; end
for _, Player in pairs ( player.GetAll() ) do
Player:ChatPrint( msg );
end
end
local function HasValue( thingToCheck )
if ( thingToCheck == "" ) then
return ( false );
else
return ( true );
end
end
function meta:ResetDisguise()
local nameToUse;
if ( HasValue( self:GetNetworkedString( "DisguiseName" ) ) ) then
nameToUse = ( self:GetNetworkedString( "DisguiseName" ) );
else
nameToUse = ( self:GetName() );
end
self:SetNetworkedBool( "IsDisguised", false );
self:SetNetworkedString( "DisguiseName", "" );
NotifyPlayers( nameToUse .. " has left the game." );
timer.Simple( math.random( 1, 7 ), function()
self:setDarkRPVar( "rpname", self.StartName );
NotifyPlayers( self:Nick() .. " has joined the game." );
end )
end
function hasAccess(ply)
if (ply:GetUserGroup() == "trialmod") then return true end
if (ply:GetUserGroup() == "admin") then return true end
if (ply:GetUserGroup() == "superadmin") then return true end
if (ply:GetUserGroup() == "Mod") then return true end
if (ply:GetUserGroup() == "Owner") then return true end
return false
end
local function DisguisePlayer( Player, _, args )
local nameToUse;
if ( !args[1] || !tostring( args[1] ) ) then
return;
end
if ( !hasAccess(Player) ) then
return;
end
if ( !Player || !Player:IsValid() ) then
return;
end
if ( string.lower( args[1] ) == "self" ) then
Player:ResetDisguise();
else
if ( HasValue( Player:GetNetworkedString( "DisguiseName" ) ) ) then
nameToUse = ( Player:GetNetworkedString( "DisguiseName" ) );
else
nameToUse = ( Player:GetName() );
end
Player:SetNetworkedBool( "IsDisguised", true );
Player:SetNetworkedString( "DisguiseName", args[1] );
NotifyPlayers( nameToUse .. " has left the game." );
timer.Simple( math.random( 2, 6 ), function()
NotifyPlayers( args[1] .. " has joined the game." );
Player:setDarkRPVar( "rpname", args[1] );
end )
end
end
concommand.Add( "rp_disguise", DisguisePlayer );
hook.Add( "PlayerInitialSpawn", "SavePlayerName", function( Player )
Player.StartName = ( Player:GetName() );
end )