• Print

Author Topic: Physgun freeze player  (Read 6419 times)

0 Members and 1 Guest are viewing this topic.

Offline BobTheDuck69

  • Newbie
  • *
  • Posts: 33
  • Karma: 1
Physgun freeze player
« on: March 12, 2015, 12:56:01 pm »
Would it be possible to make a version of the code i found here tell admins that an admin has frozen someone with it?
Code: [Select]
function FGod( ply, dmginfo )
if(ply:GetNetworkedVar("FGod") == 1) then
dmginfo:ScaleDamage( 0 )
end
end
hook.Add("EntityTakeDamage", "FGod", FGod)

hook.Add("PhysgunDrop", "ply_physgunfreeze", function(pl, ent)
hook.Remove( "PhysgunDrop", "ulxPlayerDrop" ) --This hook from ULX seems to break this script that's why we are removing it here.

ent._physgunned = false

if( ent:IsPlayer() ) then             
-- predicted?
ent:SetMoveType(pl:KeyDown(IN_ATTACK2) and MOVETYPE_NOCLIP or MOVETYPE_WALK)

if(pl:KeyDown(IN_ATTACK2)) then
ent:Freeze(true)
ent:SetNetworkedVar("FGod", 1)
else
ent:Freeze(false)
ent:SetNetworkedVar("FGod", 0)
end
   
if SERVER then
-- NO UUUU FKR
if !ent:Alive() then
ent:Spawn()
self:PlayerSpawn(ent)
ent:SetPos(pl:GetEyeTrace().HitPos)
end
end

return --self.BaseClass:PhysgunDrop( pl , ent )   
end
end)

hook.Add( "PhysgunPickup", "ply_physgunned", function(pl, ent)
ent._physgunned = true
end)

function playerDies( pl, weapon, killer )
if(pl._physgunned) then
return false
else
return true
end
end
hook.Add( "CanPlayerSuicide", "playerNoDeath", playerDies )
~The friendly neighborhood duckie~

Offline Bytewave

  • Respected Community Member
  • Hero Member
  • *****
  • Posts: 718
  • Karma: 116
  • :)
    • My Homepage
Re: Physgun freeze player
« Reply #1 on: March 12, 2015, 01:01:18 pm »
I assume you're looking to tell the frozen player they've been frozen?
If so, Player:ChatPrint() is your friend in this case.
bw81@ulysses-forums ~ % whoami
Homepage

Offline BobTheDuck69

  • Newbie
  • *
  • Posts: 33
  • Karma: 1
Re: Physgun freeze player
« Reply #2 on: March 12, 2015, 01:02:30 pm »
I need it to display globally is that how it works?
~The friendly neighborhood duckie~

Offline Bytewave

  • Respected Community Member
  • Hero Member
  • *****
  • Posts: 718
  • Karma: 116
  • :)
    • My Homepage
Re: Physgun freeze player
« Reply #3 on: March 12, 2015, 01:07:58 pm »
I need it to display globally is that how it works?
To display it globally, you could do something along the lines of (the ...'s indicate code above and below):
Code: Lua
  1. -- ...
  2. ent:Freeze(true)
  3. ulx.fancyLogAdmin("#A froze #T", pl, ent)
  4. -- ...
  5. ent:Freeze(false)
  6. ulx.fancyLogAdmin("#A unfroze #T", pl, ent)
bw81@ulysses-forums ~ % whoami
Homepage

Offline BobTheDuck69

  • Newbie
  • *
  • Posts: 33
  • Karma: 1
Re: Physgun freeze player
« Reply #4 on: March 12, 2015, 01:10:13 pm »
Im very very bad at coding its been awhile im good with some things but bad with others. would that go at the bottom of the script?
~The friendly neighborhood duckie~

Offline Bytewave

  • Respected Community Member
  • Hero Member
  • *****
  • Posts: 718
  • Karma: 116
  • :)
    • My Homepage
Re: Physgun freeze player
« Reply #5 on: March 12, 2015, 01:12:34 pm »
Im very very bad at coding its been awhile im good with some things but bad with others. would that go at the bottom of the script?
No, as I tried to indicate with the ellipses.

Find:
Code: Lua
  1. if(pl:KeyDown(IN_ATTACK2)) then
  2.         ent:Freeze(true)
  3.         ent:SetNetworkedVar("FGod", 1)
  4. else
  5.         ent:Freeze(false)
  6.         ent:SetNetworkedVar("FGod", 0)
  7. end

Replace with:
Code: Lua
  1. if(pl:KeyDown(IN_ATTACK2)) then
  2.         ent:Freeze(true)
  3.         ulx.fancyLogAdmin("#A froze #T", pl, ent)
  4.         ent:SetNetworkedVar("FGod", 1)
  5. else
  6.         ent:Freeze(false)
  7.         ulx.fancyLogAdmin("#A unfroze #T", pl, ent)
  8.         ent:SetNetworkedVar("FGod", 0)
  9. end
bw81@ulysses-forums ~ % whoami
Homepage

Offline BobTheDuck69

  • Newbie
  • *
  • Posts: 33
  • Karma: 1
Re: Physgun freeze player
« Reply #6 on: March 12, 2015, 01:16:53 pm »
Code: [Select]
function FGod( ply, dmginfo )
if(ply:GetNetworkedVar("FGod") == 1) then
dmginfo:ScaleDamage( 0 )
end
end
hook.Add("EntityTakeDamage", "FGod", FGod)

hook.Add("PhysgunDrop", "ply_physgunfreeze", function(pl, ent)
hook.Remove( "PhysgunDrop", "ulxPlayerDrop" ) --This hook from ULX seems to break this script that's why we are removing it here.

ent._physgunned = false

if( ent:IsPlayer() ) then             
-- predicted?
ent:SetMoveType(pl:KeyDown(IN_ATTACK2) and MOVETYPE_NOCLIP or MOVETYPE_WALK)

    if(pl:KeyDown(IN_ATTACK2)) then
    ent:Freeze(true)
    ulx.fancyLogAdmin("#A froze #T", pl, ent)
    ent:SetNetworkedVar("FGod", 1)
    else
    ent:Freeze(false)
    ulx.fancyLogAdmin("#A unfroze #T", pl, ent)
    ent:SetNetworkedVar("FGod", 0)
    end
   
if SERVER then
-- NO UUUU FKR
if !ent:Alive() then
ent:Spawn()
self:PlayerSpawn(ent)
ent:SetPos(pl:GetEyeTrace().HitPos)
end
end

return --self.BaseClass:PhysgunDrop( pl , ent )   
end
end)

hook.Add( "PhysgunPickup", "ply_physgunned", function(pl, ent)
ent._physgunned = true
end)

function playerDies( pl, weapon, killer )
if(pl._physgunned) then
return false
else
return true
end
end
hook.Add( "CanPlayerSuicide", "playerNoDeath", playerDies )
Look about right?
~The friendly neighborhood duckie~

Offline Bytewave

  • Respected Community Member
  • Hero Member
  • *****
  • Posts: 718
  • Karma: 116
  • :)
    • My Homepage
Re: Physgun freeze player
« Reply #7 on: March 12, 2015, 01:20:29 pm »
-snip because length-
Look about right?
Close enough.

Check your indentation there though—properly indented code is a valuable asset when other developers come here and try to read it.
bw81@ulysses-forums ~ % whoami
Homepage

Offline BobTheDuck69

  • Newbie
  • *
  • Posts: 33
  • Karma: 1
Re: Physgun freeze player
« Reply #8 on: March 12, 2015, 01:23:38 pm »
Im 16 and "slightly" autistic and computers is my strong side i know how to code batch, VBS, lua "sort of" and many others :) and the code sorta didnt work just did the same actions
« Last Edit: March 12, 2015, 01:45:52 pm by BobTheDuck69 »
~The friendly neighborhood duckie~

  • Print