Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function CorpsEating( ply, mv, usercmd )
- local trace = ply:GetEyeTrace()
- if ( ply:GetNWInt("RCells", 0) >= GHOULLIMITRC and ply:KeyDown( IN_USE ) ) then
- if trace.HitPos:Distance(ply:GetShootPos()) <= 75 then
- if trace.Entity:GetClass() == "prop_ragdoll" and trace.Entity:GetNWInt("CorpsRCells", 0 ) > 0 then
- if ply.corpsentity != trace.Entity then
- ply.corpsentity = trace.Entity
- ply:SetNWInt("CorpsDelay", CurTime() + CORPSEATINGTIME )
- elseif ply:GetNWInt("CorpsDelay", 0 ) < CurTime() and ply.corpsentity == trace.Entity then
- ply:SetNWInt("CorpsDelay", 0 )
- ply.corpsentity = NULL
- if trace.Entity:GetNWInt("CorpsOriginalOwner", ply:UniqueID() ) == ply:UniqueID() then
- if ply:GetNWInt("RCells", 1000 ) >= GHOULLIMITRC then
- if ply.EatDelay < CurTime() then
- ply.EatDelay = CurTime() + 120
- ply:SetNWInt("RCells", math.max(GHOULLIMITRC, ply:GetNWInt("RCells", 1000 ) - trace.Entity:GetNWInt("CorpsRCells", 5 ) ) )
- end
- ply:SetNWInt("TKGFood", math.max( 0, ply:GetNWInt("TKGFood") - trace.Entity:GetNWInt("TKGFood") ) )
- end
- trace.Entity:Remove()
- else
- ply:SetNWInt("RCells", math.max(GHOULLIMITRC, ply:GetNWInt("RCells", 1000 ) + trace.Entity:GetNWInt("CorpsRCells", 5 ) ) )
- ply:EmitSound("vo/sandwicheat09.mp3", 75, 100, 0.6)
- ply:SetNWInt("TKGFood", math.min(ply:GetNWInt("TKGMaxFood"), ply:GetNWInt("TKGFood") + trace.Entity:GetNWInt("TKGFood") ) )
- trace.Entity:Remove()
- end
- end
- end
- end
- end
- if ply:KeyReleased( IN_USE ) or trace.HitPos:Distance(ply:GetShootPos()) > 75 or trace.Entity != ply.corpsentity then
- if ply.corpsentity != NULL then
- ply.corpsentity = NULL
- ply:SetNWInt("CorpsDelay", 0 )
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement