Entity and Derma broken ?

So I have just finished making a bank system for DarkRP. I go to test it and this happens ?

Ignore the ugly Derma that is going to be sorted:

As you can see you have to press the buttons a few times to get them to work and there are 2 script errors for the other two buttons!

The code I am using is

init.lua:


AddCSLuaFile( "cl_init.lua" )
AddCSLuaFile( "shared.lua" )

include( "shared.lua" )

function ENT:Initialize()

	self:SetModel( "models/props/cs_assault/MoneyPallet.mdl" )
	self:PhysicsInit(SOLID_VPHYSICS)
	self:SetMoveType(MOVETYPE_VPHYSICS)
	self:SetSolid(SOLID_VPHYSICS)
	self:SetUseType( SIMPLE_USE )

	local phys = self:GetPhysicsObject()

	if phys:IsValid() then

		phys:Wake()

	end	

end

util.AddNetworkString( "OpenBankMenu" )
function ENT:AcceptInput( name, activator, caller )

	if name == "Use" and caller:IsPlayer() then
		net.Start( "OpenBankMenu" )
		net.Send( caller )
	end

end

util.AddNetworkString("BankRobberyStarted")
net.Receive("BankRobberyStarted", function()

	net.Broadcast("BankRobberyStarted")

end)

cl_init.lua:


include( "shared.lua" )

function ENT:Draw()

	self:DrawModel()

end

local BankBalance = 25000

timer.Create( "BankBalanceChanging", 180, 0, function() 

	BankBalance = BankBalance + math.random( 2500, 15500 )

end)

local ply = LocalPlayer()

net.Receive( "OpenBankMenu", function()

    local Background = vgui.Create( "DFrame" )
    Background:SetSize( 500, 500 )
    Background:Center()
    Background:SetTitle("")
    Background:SetVisible( true )
    Background:ShowCloseButton( true )
    Background:SetDraggable( false )
    Background.Paint = function(s, w, h)

        draw.RoundedBox( 5, 0, 0, w, h, Color(20,255,20,255))

    end
    Background:MakePopup()

    local BalanceBut = vgui.Create( "DButton", Background )
    BalanceBut:SetSize( 150, 30)
    BalanceBut:SetPos( 250, 250 )
    BalanceBut:SetText("Bank Balance")
    BalanceBut:SetColor(Color(0,0,0,255))
    function BalanceBut.DoClick()

    	DarkRP.notify( 1, 10, "The Bank Balance is: $"..BankBalance )
    	Background:Close()

    end

    local CloseBut = vgui.Create( "DButton", Background )
    CloseBut:SetSize( 150, 30 )
    CloseBut:SetPos( 250, 250+100)
    CloseBut:SetText("Close")
    CloseBut:SetColor( Color(0,191,255,255) )
    function CloseBut.DoClick()

    	Background:Close()

    end

    local RobberyBut = vgui.Create( "DButton", Background )
    RobberyBut:SetSize( 150, 30 )
    RobberyBut:SetPos( 250, 250-100)
    RobberyBut:SetText("Start A Robbery")
    RobberyBut:SetColor( Color(255,0,0,255) )
    function RobberyBut.DoClick()

    	if not ply:Team() == TEAM_CITIZEN then 
    		DarkRP.notify( 1, 10, "You Can't Rob the bank whilst you are employed by the government!")
    		Background:Close()
    	end

    	if ply:Team() == TEAM_CITIZEN then
    		net.Start("BankRobberyStarted")	
    		net.SendToServer()
    	end

    end

end)

net.Receive( "BankRobberyStarted", function()

	if ply:Team() == TEAM_POLICE then
		chat.AddText( Color(0,191,255), "211S(Robbery, Silent Alarm) at the 10-20 Bank! All units please respond!", Color(0,0,255), "SWAT", Color(0,191,255), "have been dispatched!")
	end

end)

shared.lua:


ENT.Type = "anim"
ENT.Base = "base_gmodentity"

ENT.PrintName = "Metro Bank"

ENT.Spawnable = true

Thank you for your help :smiley:

-Shadow

[editline]1st April 2016[/editline]

I think I may of realized the problem with the notify. The code I have put is:


DarkRP.notify( 1, 10, "You Can't Rob the bank whilst you are employed by the government!")

Shouldn’t it be:


DarkRP.notify(ply, 1, 10, "You Can't Rob the bank whilst you are employed by the government!")

WARNING : THIS THREAD MAYBE OPEN FOR SOME TIME!

You see how you have your paint function like so: Background.Paint = function() end you should do that the same with your other panels/buttons too. Also use panel:Remove() and not panel:Close()

as for your notification problem: http://wiki.darkrp.com/index.php/Functions/DarkRP/Server/notify

Edit: you can also do this



    	if not ply:Team() == TEAM_CITIZEN then 
    		DarkRP.notify( 1, 10, "You Can't Rob the bank whilst you are employed by the government!")
    		Background:Remove()
               return 
    	end
        net.Start("BankRobberyStarted")	net.SendToServer()


For the notifications shall I send a networkstring to server to notify the caller ?