1. Post #1
    enjia2000's Avatar
    March 2009
    50 Posts
    Now before you say "you suck at coding" i know, only been at this for 3-4 weeks now =P

    I decided to release this because i got help from the community (aka Lexi) on it.



    make a file called banker.lua and place it in /darkrp/gamemode/modules/

    banker.lua
    Code:
    // By Andrew (enjia2000@gmail.com) - Do not use without permission.
    
    
    function BuyBankVault(ply)
        if ( !ply:IsValid() ) then return end
    	if ( !SERVER ) then return end 
    	
    	local cost = 50
    	local tr = ply:GetEyeTrace() 
     	
    	if ( !tr.HitWorld ) then return end 
    
    	if RPArrestedPlayers[ply:SteamID()] then return "" end
    	
    
        if not ply:CanAfford(cost) then
    		Notify(ply, 1, 4, "Can not afford this!")
    		return ""
    	end
    	if ply:Team() == TEAM_BANKER then
    		ply:AddMoney(-cost)
    		Notify(ply, 1, 4, "You bought a Bank Vault for " .. CUR .. tostring(cost))
    		local bvault = ents.Create("sent_bankvault")
    		bvault:SetNWEntity("owning_ent", ply)
    		bvault:SetNWString("Owner", ply:Nick())
    		bvault:SetPos( tr.HitPos + ply:GetAimVector() * -80 )
    		bvault:SetAngles( tr.HitNormal:Angle() )
    		bvault.nodupe = true
    		bvault.SID = ply.SID
    		bvault.onlyremover = true
    		bvault:Spawn()
    		return ""
    	else
    		Notify(ply, 1, 4, "Must be a Banker to Spawn This!")
    	end
    	return ""
    end
    AddChatCommand("/buybvault", BuyBankVault)
    
    function GM:PlayerDisconnected(ply)
    	
    	for k, v in pairs(ents.FindByClass("sent_bankvault")) do
    		if v.SID == ply.SID then v:Remove() end
    	end
    	
    end
    now make a folder in darkrp\entities\entities\ called "sent_bankvault" and place these 3 files in it

    cl_init.lua
    Code:
    include("shared.lua")
    
    function ENT:Draw()
    	self.Entity:DrawModel()
    end
    init.lua
    Code:
    AddCSLuaFile("cl_init.lua")
    AddCSLuaFile("shared.lua")
    
    include("shared.lua")
    
    debug = true
    
    //setup a table to hold accounts
    account = {}
    //account[activator] stores how much money each player has put in
    
    function ENT:Initialize()
    	self:SetModel("models/props_lab/tpswitch.mdl")
        self.Entity:PhysicsInit(SOLID_VPHYSICS)
    	self.Entity:SetMoveType(MOVETYPE_VPHYSICS)
    	self.Entity:SetSolid(SOLID_VPHYSICS)
    	local phys = self.Entity:GetPhysicsObject()
    	if phys and phys:IsValid() then phys:Wake() end
    end
    
    
    function ENT:Use(activator,caller)
    	local startingamount = 50
    	local extraamount = 50
    
    	// This makes the entity semi-automatic rather than a continuous.
    	if ( !activator:KeyPressed( IN_USE ) ) then return end 
    	
    	//if the player does not have enough money return
    	if( !activator:CanAfford(startingamount) or !activator:CanAfford(extraamount) ) then
    		Notify(activator, 1, 4, "Sorry, you don't have enough money to make a transaction" )
    		return
    	end
    
    	//Either setup a new account, or add to existing funds
    	if ( activator:IsPlayer()) then 
    		if( !account[activator] ) then //If there is no account for this player
    			account[activator] = startingamount
    			activator:AddMoney(-startingamount)
    			Notify(activator, 1, 4, "You Started a New Account with " .. startingamount .. "$ in it!" )
    			timer.Create(activator:Nick() .. "_bankaccount", 60, 0, function()
    				interest = math.floor(account[activator]/10) + math.random(1,9)
    				activator:AddMoney(interest)
    				Notify(activator, 1, 4, "Interest on your Bank Account made you " .. tostring(interest) .. "$!")
    			end )
    			if( debug ) then
    				stringOut = table.ToString(account,"Accounts: " , true) 
    		   
    				Msg(stringOut .. "\n")
    			end
    			return
    		end
    		if( account[activator] ) then //If an account already Exists
    			account[activator] = account[activator] + extraamount
    			activator:AddMoney(-extraamount)
    			Notify(activator, 1, 4, "You Deposited an Additional " .. tostring(extraamount) .. "$, for a Grand total of " .. tostring(account[activator]) .. "$!")
    			if( debug ) then
    				stringOut = table.ToString(account,"Accounts: " , true) 
    		   
    				Msg(stringOut .. "\n")
    			end
    			return
    		end
    		
    	end 
    	
    end
    
    function ENT:OnRemove() //destroy all timers  
    	for k,v in pairs(player.GetAll()) do  
    		if timer.IsTimer(v:Nick().."_bankaccount") then  
    			timer.Destroy(v:Nick().."_bankaccount")
    			if( debug ) then
    				Msg("Removing: " .. v:Nick().."_bankaccount" .. "\n")
    			end
    		end  
    	end  
    end  
    
    function removeOldAccounts( ply ) 
       if timer.IsTimer(ply:Nick().."_bankaccount") then  
    		timer.Destroy(ply:Nick().."_bankaccount")
    		if( debug ) then
    			Msg("Removing: " .. ply:Nick().."_bankaccount" .. "\n")
    		end
    	end  
    end // End the function 
    hook.Add( "PlayerDisconnected", "playerdisconnected", removeOldAccounts ) // Add PlayerDisconnected hook that calls our function.
    shared.lua
    Code:
    ENT.Type = "anim"
    ENT.Base = "base_gmodentity"
    ENT.PrintName = "Bank Vault"
    ENT.Author = "Andrew"
    ENT.Spawnable = false
    ENT.AdminSpawnable = false
    and now finally to make the new entity show up in the f4 menu you must edit showteamtabs.lua in the /darkrp/gamemode/ directoy

    search the file and find where it says
    Code:
    elseif LocalPlayer():Team() == TEAM_GDEALER then
    	AddEntIcon("models/props_c17/trappropeller_engine.mdl", "Buy a gunlab " .. CUR .. tostring(GetGlobalInt("gunlabcost")), "/Buygunlab")
    end
    you need to change it so it looks like this
    Code:
    elseif LocalPlayer():Team() == TEAM_GDEALER then
    	AddEntIcon("models/props_c17/trappropeller_engine.mdl", "Buy a gunlab " .. CUR .. tostring(GetGlobalInt("gunlabcost")), "/Buygunlab")
    elseif LocalPlayer():Team() == TEAM_BANKER then
    	AddEntIcon("models/props_lab/tpswitch.mdl", "Buy a Bank Vault for 50$", "/buybvault")
    end
    and finally in /darkrp/gamemode/ add this line to the end of the file shared.lua

    Code:
    TEAM_BANKER = AddExtraTeam("Bank Manager", Color(184, 138, 0, 255), "models/player/breen.mdl", [[A Simple Bank Manager. ]], {"Keys"}, "banker", 20, 40, 0, false)
    Reply With Quote Edit / Delete Reply United States Show Events Useful Useful x 5Friendly Friendly x 1Agree Agree x 1 (list)

  2. Post #2
    Gold Member
    Rago's Avatar
    October 2008
    2,703 Posts
    Why won't you make files of it?
    Reply With Quote Edit / Delete Reply Netherlands Show Events Agree Agree x 6 (list)

  3. Post #3
    Gold Member
    deadeye536's Avatar
    February 2008
    1,525 Posts
    Why won't you make files of it?
    Keep in mind, other than the SENT, this is all file edits, it'd be useless to upload 3 files without the edits when it's just as easy to make the files on your PC to upload it to the server, or make it directly on the server.

    BTW, seems like a very nice addition, I'm looking forward to adding it on my server :P. Although, it may be a good idea to make something that can go in the Modules folder, it may be hard to make the same edits every time for the SVN updates.

  4. Post #4
    stuky4ever's Avatar
    October 2008
    499 Posts
    Didn't work. Don't know if its just me but i'll try to fix it later as im to busy currently. Nice Entity. Only if it was working :P

  5. Post #5
    Plastic's Avatar
    March 2009
    28 Posts
    when i type /buybvault or just buy it with the entities tab nothing spawns.
    although it still takes 50$ from me.
    Anyone else having this problem?

  6. Post #6
    Plastic's Avatar
    March 2009
    28 Posts
    could someone fix this cause this would be really nice.

  7. Post #7
    DJ-PASOU's Avatar
    April 2009
    11 Posts
    uum im stuck wen i edit the teamtabs or whatever its called i cant find the Code:
    elseif LocalPlayer():Team() == TEAM_GDEALER then
    AddEntIcon("models/props_c17/trappropeller_engine.mdl", "Buy a gunlab " .. CUR .. tostring(GetGlobalInt("gunlabcost")), "/Buygunlab")
    end

  8. Post #8
    IWHeadHunter's Avatar
    July 2009
    734 Posts
    Does this work?
    Reply With Quote Edit / Delete Reply United States Show Events Agree Agree x 1Dumb Dumb x 1 (list)

  9. Post #9
    Wikki94's Avatar
    March 2009
    96 Posts
    Does this work?
    Yeah, it does work, added it today. Just don't know how to make a withdrawal from it.

    Nevermind, its just a basic ATM that gives you interest and you can only add to your funds, but still very useful.
    Reply With Quote Edit / Delete Reply United States Show Events Dumb Dumb x 1 (list)

  10. Post #10
    vioman's Avatar
    June 2009
    25 Posts
    So, does this save the user's information after they dissconnect? Or can we make it so it saves it into an sql table maybe?

  11. Post #11
    IWHeadHunter's Avatar
    July 2009
    734 Posts
    yeah im having the same problem as Plastic, and DJ-PASOU if you have addentities.lua I think you have to put in there.

  12. Post #12
    Mmmaaattt94's Avatar
    February 2009
    31 Posts
    when i type /buybvault or just buy it with the entities tab nothing spawns.
    although it still takes 50$ from me.
    Anyone else having this problem?
    same problem here

  13. Post #13
    Searanger's Avatar
    January 2006
    6 Posts
    Heres an easier install for all you guys.

    Just drop it into your garrysmod/gamemodes folder. You still need to add the banker job yourself though. I left a READ file in the garrysmod/gamemodes/darkrp/gamemodes folder with instructions

    http://rapidshare.com/files/275225317/DarkRP.rar

  14. Post #14
    Dwatring's Avatar
    September 2009
    767 Posts
    My DarkRP server uses this addon! i highly recommend!

  15. Post #15

    March 2009
    65 Posts
    i have darkrp 2.3.7 and i have added it to addentities.lua (i didnt find this on showteamtabs)
    then i get this error:

    Attempted to create unknown entity type Buy a Bank Vault for 50$!
    ERROR: GAMEMODE:'PlayerSay' Failed: DarkRP\gamemode\main.lua:1087: Tried to use a NULL entity!
    Error: hook->PlayerSay returned a non-string!


    HELP !

  16. Post #16
    Pecsi's Avatar
    October 2009
    15 Posts
    Nice Work.

    Can u make a Banker Robber? please ^^

  17. Post #17
    James0890's Avatar
    November 2008
    420 Posts
    Pretty good release, just have one concern, why are you adding NWVars and never checking them? If they aren't used you're just adding pointless lag. Other than that, good work, keep it up.

  18. Post #18

    May 2009
    36 Posts
    What exactly does the Bank Manager do? Seems pointless.

  19. Post #19
    I'm a tool
    KillerLUA's Avatar
    June 2009
    1,323 Posts
    What exactly does the Bank Manager do? Seems pointless.
    Allows people to store money, some bank mods make you drop your money on death.

    However, if it is stored in a bank atm. You don't you lose your cash, in this one. You can gain intrest, I might upload my version of this.

    It has a derma that supports withdrawls and deposits. You also gain intrest

    Pretty good release, just have one concern, why are you adding NWVars and never checking them? If they aren't used you're just adding pointless lag. Other than that, good work, keep it up.
    This is proably so somebody can make a swep that can access these vars, that's how u would probably make a bank robbing gun! But as you said, because this is not being used. You should remove it until future times!

  20. Post #20

    September 2009
    184 Posts
    yeah the swep sounds like a good idea but i doubt anyone would actually make it oh well still nice release

    Edited:

    this is the error i get
    vgui/SpawnIcon.lua:108: bad argument #1 to 'SetModel' (string expected, got table)
    Generated Spawn Icon (0 left in queue)

  21. Post #21
    ph:lxyz's Avatar
    March 2010
    299 Posts
    If you install both this and Starbank Redux, you can use the vault to store customers' money

  22. Post #22
    Dennab
    August 2008
    263 Posts
    Starbank Redux? What's that?

  23. Post #23
    ph:lxyz's Avatar
    March 2010
    299 Posts

  24. Post #24
    Agent3004's Avatar
    April 2009
    23 Posts
    i'm running this script (edited) on my GTARP server but ahm - it seems like the Bank Vault just give interests to the LAST player that did a transfer... - could you please fix this?

    and if the bankvault get removed and i spawn a new one, the bank-accounts are still there - i tried to fix this but i just dont get it-.-

  25. Post #25
    Bambs's Avatar
    May 2010
    90 Posts
    how do you get the money out?

  26. Post #26
    Free Gameservers
    darksoul69's Avatar
    August 2006
    2,987 Posts
    i'm running this script (edited) on my GTARP server but ahm - it seems like the Bank Vault just give interests to the LAST player that did a transfer... - could you please fix this?

    and if the bankvault get removed and i spawn a new one, the bank-accounts are still there - i tried to fix this but i just dont get it-.-
    Does the unedited version work fine?.

  27. Post #27

    June 2010
    66 Posts
    Can you add these most needed functions to it:
    1500 as max for input into bank (i put in 10k and i made like 1 mil fast)

    Shooting the bank vault enough times will break it and remove everyone as users and drop everyones money out of it so people can rob the bank.

    I tried to do this but i keep getting a error in gamemode.

  28. Post #28
    brodiewf's Avatar
    March 2010
    339 Posts
    This works for me. If you need any help with installing it please contact me at brodie@ontarioregimentgaming.com and i would be happy to assist you.

  29. Post #29

    July 2010
    4 Posts
    pics or i didnt happen.............
    Reply With Quote Edit / Delete Reply United States Show Events Dumb Dumb x 1 (list)

  30. Post #30
    Dennab
    July 2009
    623 Posts
    pics or i didnt happen.............
    We don't need pictures of your birth. I think that you posting here is enough evidence that you "happened".

  31. Post #31
    Zambies!'s Avatar
    August 2009
    8,139 Posts
    Great...great release. Best DRP release for a while it seems. Keep up the good work!
    Also, hes a troll ignore em.

  32. Post #32

    January 2010
    80 Posts
    Do I need to merge the show teams tab? Is there anything important that I should copy to the newer version of that file?