DarkRP - Skyrim-esque lockpicking

Basically I got Skyrim from Tomelyr and got inspired to make this. It works pretty much exactly like the lockpick from skyrim

http://images.akamai.steamusercontent.com/ugc/35244412474863848/16ED44C28E860841DF4D4DE0E0B3BBA2013C45AC/

Heh I mentioned that skyrim/fallout esque lockpicking would help in darkrp in one of the general discussion threads about a week ago and whadda ya know, you just happened to have been making one.

This is really cool ! A lockpick that require skill rather than time is so much better.

Been looking for something like this for a while now, so for starters, thank you for creating this.
Second thing is, it’s free… Hallelujah!

I’ll be using this on my server and will happily give you credit for the addon.

Put it on the Coderhire cloning thread. I’m aware that something like this is being sold on SF.

Did you fix relying on the client so much? I’d love to use it if you have.

Yeah at the slight expense of responsiveness for getting the correct angle. When you move your lockpick it periodically sends the angle to the server for verification that you are within 10 degrees of the unlocking angle and then it tells the client to do hint-y stuff.

[lua]-- Click once on door = generate number
– Closes panel automatically
– Tries to force the angle
– Send unlock to the server, opens the door

local msgcol = Color(51, 153, 102)
local function message(msg)
chat.AddText(msgcol, "[Pick] ", tostring(msg))
end

if weapons.Get(“lockpick”).Author ~= “Exho” then message(“Not using Exho’s lockpick.”) return end

local function forceang(pick, num, callback)
message("Trying "…num)
net.Start(“lockpick_check”)
net.WriteInt(num, 8)
net.SendToServer()

-- angle can be between 15 and 165 and accepts intervals of 20
timer.Simple(0.2, function() -- could fail depending on connection
	if not pick:GetNWBool("lockpick_canTurn") then
		if num > 165 then
			message("Picking failed. (Exceeded maximum angle; Zerf is bad.)")
			net.Start("lockpick_end")
			net.SendToServer()
			return
		end
		forceang(pick, num + 20, callback)
	else
		callback(num)
	end
end)

end

local pick = LocalPlayer():GetWeapon(“lockpick”)
if not IsValid(pick) then message(“Get a lockpick, skrublord.”) return end

if pick.OldPrimaryAttack then pick.PrimaryAttack = pick.OldPrimaryAttack end
pick.OldPrimaryAttack = pick.PrimaryAttack

function pick:PrimaryAttack()
self:OldPrimaryAttack()
if IsValid(self.frame) then – Don’t want no panel
self.frame:Remove()
self.frame = nil
end
if not IsFirstTimePredicted() then return end
forceang(pick, 5, function(num)
message(“Forced angle! (It was around “…num…”)”)
net.Start(“lockpick_unlock”)
net.SendToServer()
end)
end
[/lua]
not good enough

[editline]2nd May 2015[/editline]

the script forceably unlocks any door in a maximum of 1.6 seconds

Not to say that there’s no problem with that, but don’t servers generally restrict clientside lua scripts anyway? I haven’t played Gmod in a while though so Im probably missing some important detail here

In DarkRP sv_allowcslua is 1 by default. Besides, I can run my own code without sv_allowcslua and without any DLLs. Never trust the client.

Yeah I know thats still possible… Do you happen to have any better ideas? This addon, by nature, requires a lot of client input and trust which has left me in a bad place security wise.