• DarkRP Max Printers?
    4 replies, posted
I want all my printers to all contribute to the same max. To better explain, say you can have a max number of 20 printers. 3 of ruby 10 of gold and 12 of diamond so you can only spawn say all 3 ruby all 10 gold but only 7 diamond. If that makes any sense. Anyways It has been made into ONE entity. Here is my entitys Init.lua [CODE]ddCSLuaFile("cl_init.lua") AddCSLuaFile("shared.lua") include("shared.lua") ENT.SeizeReward = 950 local PrintMore function ENT:Initialize() self:SetModel("models/props_lab/reciever01b.mdl") self:SetColor(Color(255,255,255)) self.PrinterColors = Color(255,255,255) self.times = 0 self.givexp = 0 self.givemoney = 0 if(self.DarkRPItem.printertype == 'regular') then self.PrinterColors = Color(255,255,255) self:SetModel("models/props_lab/reciever01b.mdl") self:SetNetworkedString('printname', 'Regular Money Printer') self:SetNetworkedString('printtype', regular) self.xpamount = 65 self.moneyamount = 100 else if(self.DarkRPItem.printertype == 'gold') then self:SetModel("models/props_lab/reciever01b.mdl") self.xpamount = 300 self.moneyamount = 300 self.PrinterColors = Color(255,215,0) self:SetNetworkedString('printname', 'Gold Money Printer') self:SetNetworkedString('printtype', 'gold') else if(self.DarkRPItem.printertype == 'ruby') then self:SetModel("models/props_lab/reciever01a.mdl") self.PrinterColors = Color(255,0,0) self:SetNetworkedString('printname', 'Ruby Money Printer') self:SetNetworkedString('printtype', 'ruby') self.xpamount = 1062 self.moneyamount = 1200 else if(self.DarkRPItem.printertype == 'plat') then self:SetModel("models/props_c17/consolebox03a.mdl") self.PrinterColors = Color(255,255,255) self:SetNetworkedString('printname', 'Platinum Money Printer') self:SetNetworkedString('printtype', 'plat') self.xpamount = 1800 self.moneyamount = 1500 else if(self.DarkRPItem.printertype == 'diamond') then self:SetModel("models/props_c17/consolebox01a.mdl") self.PrinterColors = Color(135,200,250) self:SetNetworkedString('printname', 'Diamond Money Printer') self:SetNetworkedString('printtype', 'diamond') self.xpamount = 2500 self.moneyamount = 5000 else if(self.DarkRPItem.printertype == 'emerald') then self:SetModel("models/props_c17/consolebox01a.mdl") self.PrinterColors = Color(0,100,0) self:SetNetworkedString('printname', 'Emerald Money Printer') self:SetNetworkedString('printtype', 'emerald') self.xpamount = 3550 self.moneyamount = 10000 else if(self.DarkRPItem.printertype == 'ubub') then self:SetModel("models/props_wasteland/laundry_washer003.mdl") self.PrinterColors = Color(255,255,255) self:SetNetworkedString('printname', 'Unobtainium Money Printer') self:SetNetworkedString('printtype', 'unub') self.xpamount = 3500 self.moneyamount = 15000 else if(self.DarkRPItem.printertype == 'vronkie') then self:SetModel("models/maxofs2d/thruster_propeller.mdl") self.PrinterColors = Color(242,112,19) self:SetNetworkedString('printname', 'Vronkie\'s Money Printer') self:SetNetworkedString('printtype', 'vronkie') self.xpamount = (10*self:Getowning_ent():getDarkRPVar('level') or 0) self.moneyamount = 10*self:Getowning_ent():getDarkRPVar('level') or 0 end end end end end end end end self:PhysicsInit(SOLID_VPHYSICS) self:SetMoveType(MOVETYPE_VPHYSICS) self:SetSolid(SOLID_VPHYSICS) local phys = self:GetPhysicsObject() phys:Wake() self.sparking = false self.damage = 100 self.IsMoneyPrinter = true self.IsPrinter = true self.ownerssteam = self:Getowning_ent():SteamID() self:SetUseType(SIMPLE_USE) timer.Simple(90, function() PrintMore(self) end) self:SetColor(self.PrinterColors) self.sound = CreateSound(self, Sound("ambient/levels/labs/equipment_printer_loop1.wav")) self.sound:SetSoundLevel(21) self.sound:PlayEx(1, 100) self:SetNWInt('maxmoney', self.moneyamount*4) if(self:GetNetworkedInt('cash_money') >= 1) then self:SetColor(Color(0,255,0)) else self:SetNWInt('cash_money', 0) self:SetNWInt('xp_money', 0) end end[/CODE] and my add ent code [CODE] DarkRP.createEntity("Ruby Printer", { ent = "vrondakis_printer", printertype = 'ruby', model = "models/props_lab/reciever01a.mdl", price = 5000, max = 1, printer = true, level = 20, cmd = "buyrubyprinter" }) DarkRP.createEntity("Platinum Printer", { ent = "vrondakis_printer", printertype = 'plat', model = "models/props_c17/consolebox03a.mdl", price = 10000, max = 1, printer = true, level = 30, cmd = "buyplatprinter" }) DarkRP.createEntity("Diamond Printer", { ent = "vrondakis_printer", printertype = 'diamond', model = "models/props_c17/consolebox01a.mdl", price = 50000, max = 99, printer = true, level = 40, cmd = "buydiamondprinter" }) DarkRP.createEntity("Emerald Printer", { ent = "vrondakis_printer", printertype = 'emerald', model = "models/props_c17/consolebox01a.mdl", price = 100000, max = 99, printer = true, level = 50, cmd = "buyemeraldprinter" }) DarkRP.createEntity("Unobtainium Printer", { ent = "vrondakis_printer", printertype = 'ubub', model = "models/props_wasteland/laundry_washer003.mdl", price = 120000, max = 99, printer = true, level = 60, cmd = "buyunobprinter" })[/CODE] I was thinking about creating a Cvar for the entity "vrondakis_printer" But i dont know how to go about this.
[CODE] printerMax = currentNormal + currentGold + currentRuby; if ( printerMax > 10 ) { chatPrint("Too Many Printers!"); hint("Printer Limit Reached!", 4); } [/CODE] Basically...
Any specific folder or file I should put that in?
[QUOTE=raklatif;43860027][CODE] printerMax = currentNormal + currentGold + currentRuby; if ( printerMax > 10 ) { chatPrint("Too Many Printers!"); hint("Printer Limit Reached!", 4); } [/CODE] Basically...[/QUOTE] ... way to use { } when lua uses then end. Anyway, [CODE] local valueorsomethin = {} valueorsomethin["regular"] = 1 valueorsomethin["gold"] = 2 -- Change, add, whatever. local maxprinterpoints = 10 -- You can put this in the ENT:Spawn or ENT:Init hook. But if you put it in the Init hook, you'll have to define "ply" by yourself. -- function ENT:SpawnOrInit if !ply.Printer_Limit then -- We're basically tying a variable to the player. It makes things kind of easier. ply.Printer_Limit = 0 --Note that this doesn't save when the server restarts end if ply.Printer_Limit >= maxprinterpoints then ply:SendLua("notification.AddLegacy(\"Too many printers!\", NOTIFY_ERROR, 5)") -- Give that nice little message with an (X) on it ply:ConCommand("play buttons/button8.wav") -- Play a little error sound else ply.Printer_Limit = ply.Printer_Limit + valueorsomethin[self.DarkRPItem.printertype] end -- en function ENT:OnRemove() -- You can plug this in your code (Assuming you have ply defined.) ply.Printer_Limit = ply.Printer_Limit - valueorsomethin[self.DarkRPItem.printertype] end [/CODE] Also, I noticed a lot of your strings use single quotes, not double.. this is VERY bad and will break your code. Example: [code] (self.DarkRPItem.printertype == 'regular') -- Should be changed to (self.DarkRPItem.printertype == "regular") [/code] It's almost midnight so I'm going to bed soon. Hope this helps.
How and where would I do this?
Sorry, you need to Log In to post a reply to this thread.