My favorites | Sign in
Project Home Issues Source
READ-ONLY: This project has been archived. For more information see this post.
Search
for
  Advanced search   Search tips   Subscriptions

Issue 353 attachment: sh_ragdoll.lua (3.2 KB)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
/*-------------------------------------------------------------------------------------------------------------------------
Ragdoll a player
-------------------------------------------------------------------------------------------------------------------------*/

local PLUGIN = {}
PLUGIN.Title = "Ragdoll"
PLUGIN.Description = "Ragdoll a player."
PLUGIN.Author = "Overv"
PLUGIN.ChatCommand = "ragdoll"
PLUGIN.Usage = "[players] [1/0]"
PLUGIN.Privileges = { "Ragdoll" }

function PLUGIN:Call( ply, args )
if ( ply:EV_HasPrivilege( "Ragdoll" ) ) then
local players = evolve:FindPlayer( args, ply, true )
local enabled = ( tonumber( args[ #args ] ) or 1 ) > 0

for _, pl in ipairs( players ) do
if ( enabled ) then
if ( !pl.EV_Ragdolled and pl:Alive() ) then
pl:DrawViewModel( false )
pl:StripWeapons()

local doll = ents.Create( "prop_ragdoll" )
doll:SetModel( pl:GetModel() )
doll:SetPos( pl:GetPos() )
doll:SetAngles( pl:GetAngles() )
doll:Spawn()
doll:Activate()

pl.EV_Ragdoll = doll
pl:Spectate( OBS_MODE_CHASE )
pl:SpectateEntity( pl.EV_Ragdoll )
pl:SetParent( pl.EV_Ragdoll )

pl.EV_Ragdolled = true
end
else
pl:SetNoTarget( false )
pl:SetParent()
pl.EV_Ragdolled = false
pl:Spawn()
end
end

if ( #players > 0 ) then
if ( enabled ) then
evolve:Notify( evolve.colors.blue, ply:Nick(), evolve.colors.white, " has ragdolled ", evolve.colors.red, evolve:CreatePlayerList( players ), evolve.colors.white, "." )
else
evolve:Notify( evolve.colors.blue, ply:Nick(), evolve.colors.white, " has unragdolled ", evolve.colors.red, evolve:CreatePlayerList( players ), evolve.colors.white, "." )
end
else
evolve:Notify( ply, evolve.colors.red, evolve.constants.noplayers )
end
else
evolve:Notify( ply, evolve.colors.red, evolve.constants.notallowed )
end
end

function PLUGIN:PlayerDisconnect( ply )
if ( ply.EV_Ragdoll and ply.EV_Ragdoll:IsValid() ) then ply.EV_Ragdoll:Remove() end
end

function PLUGIN:CanPlayerSuicide( ply ) if ( ply.EV_Ragdolled ) then return false end end
function PLUGIN:PlayerUse( ply ) if ( ply.EV_Ragdolled ) then return false end end
function PLUGIN:PlayerNoClip( ply ) if ( ply.EV_Ragdolled ) then return false end end
function PLUGIN:PlayerSpawnProp( ply ) if ( ply.EV_Ragdolled ) then return false end end
function PLUGIN:PlayerSpawnSENT( ply ) if ( ply.EV_Ragdolled ) then return false end end
function PLUGIN:PlayerSpawnSWEP( ply ) if ( ply.EV_Ragdolled ) then return false end end
function PLUGIN:PlayerSpawnNPC( ply ) if ( ply.EV_Ragdolled ) then return false end end
function PLUGIN:PlayerSpawnEffect( ply ) if ( ply.EV_Ragdolled ) then return false end end
function PLUGIN:PlayerSpawnRagdoll( ply )if ( ply.EV_Ragdolled ) then return false end end
function PLUGIN:PlayerSpawnedVehicle( ply, veh )if ( ply.EV_Ragdolled ) then veh:Remove() end end

function PLUGIN:Menu( arg, players )
if ( arg ) then
table.insert( players, arg )
RunConsoleCommand( "ev", "ragdoll", unpack( players ) )
else
return "Ragdoll", evolve.category.punishment, { { "Enable", 1 }, { "Disable", 0 } }
end
end


evolve:RegisterPlugin( PLUGIN )
Powered by Google Project Hosting