Modified Lockpick - Small Problem

Hello Guys,

i edited the lockpick weapon, that it cant lockpick fading doors anymore.


if SERVER and e.isFadingDoor then 
function() local ply = LocalPlayer() chat.AddText(ply, "You cant lockpick fadeingdoors") end 
return
end


e references trace.Entity

But GMod kicks me for <name> expected near (

Please help me :blush:

Thanks alot

[lua]sv_kickerrornum 0[/lua] – Prevent the kick issue.

LocalPlayer and chat.AddText do not exist on the server.

[lua]
if SERVER and e.isFadingDoor then
local ply = Player
ply:PrintMessage( HUD_PRINTTALK, “You cannot lockpick fading doors!” )
end
[/lua]

Does this have any effects to the stability of the server?
Or does it just dont kick players for lua errors?

It just stops kicking players, but they will still see the errors. Doesn’t effect server stability afaik but the scripts erroring won’t properly work obviously.
It’s best to turn error kicking off in populated servers, otherwise your whole server will be empty because of one small bug in one of your addons.

Im sorry but you’re code drops an error:


[ERROR] gamemodes/darkrp/entities/weapons/lockpick/shared.lua:84: attempt to index local 'ply' (a function value)
  1. unknown - gamemodes/darkrp/entities/weapons/lockpick/shared.lua:84

Trying it this way now:



if SERVER and e.isFadingDoor then 
	local ply = LocalPlayer ply:PrintMessage( HUD_PRINTTALK, "You cannot lockpick fading doors!" )
	end




if SERVER and e.isFadingDoor then 
	self.Owner:PrintMessage( HUD_PRINTTALK, "You cannot lockpick fading doors!" )
	return
end



if SERVER and e.isFadingDoor then 
    local ply = LocalPlayer() 
    ply:ChatPrint("You can't lockpick fadingdoors.")
    return
end

I prefer ChatPrint unless I am changing the color of the text that is put in chat.

How can LocalPlayer exist in the server realm?

I’m honestly surprised that I didn’t notice that earlier. Wow, I suck.