Skip to content

Commit

Permalink
add wall offset tool option, fix GPE error, update CAMI
Browse files Browse the repository at this point in the history
  • Loading branch information
GlorifiedPig committed Dec 29, 2020
1 parent 83cf28b commit 3f67f35
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 8 deletions.
2 changes: 1 addition & 1 deletion lua/autorun/sh_glorifiedbanking_autoincluder.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

GlorifiedBanking = GlorifiedBanking or {
Config = {},
Version = "3.0.1"
Version = "3.1.0"
}

print( "[GlorifiedBanking] This server is running version " .. GlorifiedBanking.Version .. "." )
Expand Down
2 changes: 1 addition & 1 deletion lua/glorifiedbanking/libraries/sv_glorifiedbanking_gpe.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

local gpeVersion = 1.2

if not GlorifiedPersistentEnts or GlorifiedPersistentEnts.Version < gpeVersion then
if not GlorifiedPersistentEnts or not gpeVersion or not GlorifiedPersistentEnts.Version or GlorifiedPersistentEnts.Version < gpeVersion then
GlorifiedPersistentEnts = {
Version = giVersion,
EntClasses = {},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,8 @@ GlorifiedBanking.i18n.RegisterPhrases( "en", {
gbToolTransferFeeHelp = "The transaction fee for all transfers made with this ATM in percent.",
gbToolSnap = "Snap Amount:",
gbToolSnapHelp = "The distance between each snapping point.",
gbToolWallOffset = "Wall Offset:",
gbToolWallOffsetHelp = "How far off the wall the ATM should go.",
gbToolHeight = "Height Offset:",
gbToolHeightHelp = "The distance from the floor the ATM will be placed at.",
gbWireToolName = "Card Reader Controller",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

function GlorifiedBanking.HasPermission( ply, permission, callbackFunc )
return CAMI.PlayerHasAccess( ply, permission, callbackFunc )
return CAMI.PlayerHasAccess( ply, permission, callbackFunc ) or ply:IsSuperAdmin()
end

function GlorifiedBanking.RegisterPermission( permission, minAccess, description )
Expand Down
16 changes: 11 additions & 5 deletions lua/weapons/gmod_tool/stools/gbatmplacer.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ TOOL.ConfigName = ""

TOOL.ClientConVar["height"] = 50
TOOL.ClientConVar["snap"] = 0
TOOL.ClientConVar["walloffset"] = 0
TOOL.ClientConVar["signtext"] = "ATM"
TOOL.ClientConVar["withdrawalfee"] = 0
TOOL.ClientConVar["depositfee"] = 0
Expand Down Expand Up @@ -44,6 +45,10 @@ if CLIENT then
panel:ControlHelp(GlorifiedBanking.i18n.GetPhrase("gbToolHeightHelp"))
panel:Help("")

panel:NumSlider(GlorifiedBanking.i18n.GetPhrase("gbToolWallOffset"), "gbatmplacer_walloffset", -150, 150, 2)
panel:ControlHelp(GlorifiedBanking.i18n.GetPhrase("gbToolWallOffsetHelp"))
panel:Help("")

panel:TextEntry(GlorifiedBanking.i18n.GetPhrase("gbToolSignText"), "gbatmplacer_signtext")
panel:ControlHelp(GlorifiedBanking.i18n.GetPhrase("gbToolSignTextHelp"))
panel:Help("")
Expand All @@ -61,7 +66,7 @@ if CLIENT then
end
end

local function getAtmPos(tr, heightOffset, snap)
local function getAtmPos(tr, wallOffset, heightOffset, snap)
if not tr.Hit or IsValid(tr.Entity) then return false end

local angles = tr.HitNormal:Angle() -- {{ user_id sha256 key }}
Expand All @@ -85,14 +90,14 @@ local function getAtmPos(tr, heightOffset, snap)
end
end

return tr.HitPos - (tr.HitNormal * -9.6) - Vector(0, 0, distToFloor - heightOffset) + Vector( 6.5, 0, 0 ), angles
return tr.HitPos - (tr.HitNormal * -9.6) - Vector(0, 0, distToFloor - heightOffset) + Vector( wallOffset, 0, 0 ), angles
end

function TOOL:UpdateGhost(ent, ply)
if not IsValid(ent) then return end

local tr = ply:GetEyeTrace()
local ghostPos, ghostAngles = getAtmPos(tr, self:GetClientNumber("height"), self:GetClientNumber("snap"))
local ghostPos, ghostAngles = getAtmPos(tr, self:GetClientNumber("walloffset"), self:GetClientNumber("height"), self:GetClientNumber("snap"))
if not ghostPos or not ghostAngles then
ent:SetNoDraw(true)
return
Expand All @@ -119,7 +124,7 @@ if CLIENT then return end

function TOOL:LeftClick( tr )
if GlorifiedBanking.HasPermission( self:GetOwner(), "glorifiedbanking_placeatms" ) then
local atmPos, atmAngles = getAtmPos( tr, self:GetClientNumber( "height" ), self:GetClientNumber( "snap" ) )
local atmPos, atmAngles = getAtmPos( tr, self:GetClientNumber("walloffset"), self:GetClientNumber( "height" ), self:GetClientNumber( "snap" ) )
if not atmPos or not atmAngles then return end

local createdATM = ents.Create( "glorifiedbanking_atm" )
Expand All @@ -136,8 +141,9 @@ function TOOL:LeftClick( tr )
end

function TOOL:RightClick( tr )
print( "bababooey" )
local ent = tr.Entity
if not tr.Hit or not IsValid( ent ) then return end
if not IsValid( ent ) then return end
if ent:GetClass() == "glorifiedbanking_atm" and GlorifiedBanking.HasPermission( self:GetOwner(), "glorifiedbanking_placeatms" ) then
self:GetOwner():ConCommand( "gpe_removeent" )
end
Expand Down

0 comments on commit 3f67f35

Please sign in to comment.