General > Off-Topic

Need help to fix this code

(1/2) > >>

PwndKilled:

--- Code: ---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 )
--- End code ---

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

JamminR:
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.

PwndKilled:
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

JamminR:
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.



PwndKilled:
i removed the anticheat how do i fix this annoying error

Navigation

[0] Message Index

[#] Next page

Go to full version