• DarkRP Addon - Bank Manager
    31 replies, posted
  • Avatar of enjia2000
  • 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 [/code] 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 [/code] 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. [/code] shared.lua [code] ENT.Type = "anim" ENT.Base = "base_gmodentity" ENT.PrintName = "Bank Vault" ENT.Author = "Andrew" ENT.Spawnable = false ENT.AdminSpawnable = false [/code] 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 [/code] 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 [/code] 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) [/code]
  • [QUOTE=Rago;14419452]Why won't you make files of it?[/QUOTE] 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.
  • Avatar of stuky4ever
  • 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
  • Avatar of Plastic
  • 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?
  • Avatar of DJ-PASOU
  • 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
  • Avatar of Wikki94
  • [QUOTE=IWHeadHunter;16249242]Does this work?[/QUOTE] 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.
  • Avatar of vioman
  • 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?
  • Avatar of IWHeadHunter
  • yeah im having the same problem as Plastic, and DJ-PASOU if you have addentities.lua I think you have to put in there.
  • Avatar of Mmmaaattt94
  • [QUOTE=Plastic;14758503]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?[/QUOTE] same problem here
  • Avatar of Searanger
  • 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 [url]http://rapidshare.com/files/275225317/DarkRP.rar[/url]
  • 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 !
  • Avatar of James0890
  • 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.
  • Avatar of KillerLUA
  • [QUOTE]What exactly does the Bank Manager do? Seems pointless.[/QUOTE] 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 [QUOTE]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. [/QUOTE] 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!
  • yeah the swep sounds like a good idea but i doubt anyone would actually make it oh well still nice release [editline]07:31PM[/editline] 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)
  • Avatar of ph:lxyz
  • If you install both this and Starbank Redux, you can use the vault to store customers' money
  • Avatar of ph:lxyz
  • [QUOTE=SaltyPeppr;21244150]Starbank Redux? What's that?[/QUOTE] [url]http://www.facepunch.com/showthread.php?t=914487[/url]
  • Avatar of Agent3004
  • 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-.-
  • [QUOTE=Agent3004;21648436]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-.-[/QUOTE] Does the unedited version work fine?.
  • 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.
  • Avatar of brodiewf
  • This works for me. If you need any help with installing it please contact me at [email]brodie@ontarioregimentgaming.com[/email] and i would be happy to assist you.
  • Avatar of doctorjohndoria
  • [QUOTE=Soupiest;23631251]pics [B]or i didnt happen[/B].............[/QUOTE] We don't need pictures of your birth. I think that you posting here is enough evidence that you "happened".