Author Topic: Need help to fix this code  (Read 2825 times)

0 Members and 1 Guest are viewing this topic.

Offline PwndKilled

  • Newbie
  • *
  • Posts: 19
  • Karma: -1
Need help to fix this code
« on: January 24, 2015, 10:32:08 AM »
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() && ( pl:IsUserGroup( "superadmin" ) or pl:IsUserGroup( "admin" )) ) then     --If you want to insert another one insert "or pl:IsUserGroup( "YetAnotherGroup" )"       
-- predicted?

if(pl:KeyDown(IN_ATTACK2)) then
ent:Freeze(true)
ent:SetNetworkedVar("FGod", 1)
ent:SetMoveType(MOVETYPE_NOCLIP)
else
ent:Freeze(false)
ent:SetNetworkedVar("FGod", 0)
ent:SetMoveType(MOVETYPE_WALK)
end



if SERVER then
-- NO UUUU FKR
if !ent:Alive() then
ent:Spawn()
self:PlayerSpawn(ent)
ent:SetPos(pl:GetEyeTrace().HitPos)
end
end

else -- If it wasn't an admin in your defined groups then don't do anything
ent:Freeze(false)
ent:SetNetworkedVar("FGod", 0)
ent:SetMoveType(MOVETYPE_WALK)

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 )

I get error everytime i freeze somebody..it's annoying

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: Need help to fix this code
« Reply #1 on: January 24, 2015, 10:46:35 AM »
When presenting more than 3-4 lines of code and saying "this code isn't working", it would be helpful to everyone if you posted the exact error trace you're getting.
Copy paste from console.
That error will often tell you exactly where you're issue is, and exactly what it is.
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline PwndKilled

  • Newbie
  • *
  • Posts: 19
  • Karma: -1
Re: Need help to fix this code
« Reply #2 on: January 24, 2015, 12:02:43 PM »
PwndKilled|2|STEAM_0:0:0000000

[ERROR] addons/ulx/lua/ulx/modules/sh/freezeplayers.lua:38: attempt to call method 'Freeze' (a nil value)
  1. fn - addons/ulx/lua/ulx/modules/sh/freezeplayers.lua:38
   2. unknown - addons/anticheat/lua/_ley_imp.lua:973


Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: Need help to fix this code
« Reply #3 on: January 24, 2015, 04:44:30 PM »
My educated guesses, from greatest to least likely reason it's not working.
From http://wiki.garrysmod.com/page/Player/Freeze ....
1) Freeze is server side only... you're running in a 'shared' module, and throwing a client side error because the client side doesn't know what "Freeze" is.
OR
2) Freeze is player entity only...Your if statement at line 13 checks "is ent a player?", in addition to group checks. If not a player or not a group match, it runs that command at line 38. If you run Freeze on a non player entity, it might error out.
OR
3) LEAST likely - something in your anti-cheat is causing Freeze to be nil. (Again, LEAST LIKELY... we get blamed for much because our hook system often appears in an error trace...so I'm not likely to blame the anticheat just because it's at the bottom of the trace.



"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline PwndKilled

  • Newbie
  • *
  • Posts: 19
  • Karma: -1
Re: Need help to fix this code
« Reply #4 on: January 28, 2015, 06:21:58 PM »
i removed the anticheat how do i fix this annoying error

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: Need help to fix this code
« Reply #5 on: January 28, 2015, 08:27:57 PM »
i removed the anticheat how do i fix this annoying error
As I stated, #3 was least likely the issue.
1) Don't run the freeze command on client.
2) Don't run the freeze command on a non-player object.
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline PwndKilled

  • Newbie
  • *
  • Posts: 19
  • Karma: -1
Re: Need help to fix this code
« Reply #6 on: January 30, 2015, 11:40:36 PM »
I'm not a lua coder so i don't really know how to fix it

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: Need help to fix this code
« Reply #7 on: January 31, 2015, 08:46:32 AM »
I was under the impression you had made it and just wanted help fixing it.
Where did you get the code from?
Perhaps the original developer has newer/corrected code?
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline PwndKilled

  • Newbie
  • *
  • Posts: 19
  • Karma: -1

Offline PwndKilled

  • Newbie
  • *
  • Posts: 19
  • Karma: -1
Re: Need help to fix this code
« Reply #9 on: February 12, 2015, 02:56:43 AM »
bump