• Warrior Gaming Base Wars - Need help finding the error and fixing.
    6 replies, posted
Hey guys I am just wondering if anyone can help me out with this script, I have done everything right(according to my knowledge) and it just wont print any money. Here is the script: [CODE]AddCSLuaFile("cl_init.lua") AddCSLuaFile("shared.lua") include('shared.lua') function ENT:Initialize() self.Entity:SetModel( "models/props_lab/reciever01b.mdl" ) self.Entity:PhysicsInit(SOLID_VPHYSICS) self.Entity:SetMoveType(MOVETYPE_VPHYSICS) self.Entity:SetSolid(SOLID_VPHYSICS) self.Entity:SetColor(Color(127,111,63,255)) local phys = self.Entity:GetPhysicsObject() if(phys:IsValid()) then phys:Wake() end timer.Create( tostring(self.Entity), 18, 0, function( Pl ) self:giveMoney end) timer.Create( tostring(self.Entity) .. "fuckafkfags", 750, 1, function()self:shutOff end) timer.Create( tostring(self.Entity) .. "notifyoff", 700, 1, function()self:notifyPl end) self.Entity:SetNWBool("sparking",false) self.Entity:SetNWInt("damage",100) self.Entity:SetNWInt("upgrade", 0) local ply = self.Owner ply:GetTable().maxBronzePrinter=ply:GetTable().maxBronzePrinter + 1 self.Inactive = false self.NearInact = false self.Entity:SetNWInt("power",0) self.Payout = {950, "Bronze Money Printer"} end function ENT:giveMoney() local ply = self.Owner if(IsValid(ply) && !self.Inactive && self.Entity:IsPowered()) then // ply:AddMoney( 25 ); local trace = { } trace.start = self.Entity:GetPos()+self.Entity:GetAngles():Up()*15; trace.endpos = trace.start + self.Entity:GetAngles():Forward() + self.Entity:GetAngles():Right() trace.filter = self.Entity local tr = util.TraceLine( trace ); local amount = math.random( 82, 110 ) if (self.Enitty:GetNWInt("upgrade")==4) then amount = math.random( 400, 447) elseif (self.Entity:GetNWInt("upgrade")==3) then amount = math.random( 330, 377 ) elseif (self.Entity:GetNWInt("upgrade")==2) then amount = math.random( 220, 274 ) elseif (self.Entity:GetNWInt("upgrade")==1) then amount = math.random( 192, 220 ) end local moneybag = ents.Create( "prop_moneybag" ); moneybag:SetModel( "models/notes.mdl" ); moneybag:SetPos( tr.HitPos ); moneybag:SetAngles(self.Entity:GetAngles()) moneybag:Spawn(); moneybag:SetColor(Color(200,255,200,255)) moneybag:SetMoveType( MOVETYPE_VPHYSICS ) moneybag:GetTable().MoneyBag = true; moneybag:GetTable().Amount = amount Notify( ply, 0, 3, "Bronze Printer Printed $" .. amount ); elseif (self.Inactive) then Notify( ply, 4, 3, "A money printer is inactive, press use on it to make it active again." ); elseif !self.Entity:IsPowered() then Notify(ply, 4, 3, "A money printer does not have enough power. Get a power plant.") end end function ENT:shutOff() local ply = self.Owner self.Inactive = true Notify( ply, 1, 3, "NOTICE: A MONEY PRINTER HAS GONE INACTIVE" ); Notify( ply, 1, 3, "PRESS USE ON IT TO CONTINUE GETTING MONEY" ); self.Entity:SetColor(Color(255,0,0,254)) end function ENT:notifypl() self.NearInact = true local ply = self.Owner Notify( ply, 4, 3, "NOTICE: A MONEY PRINTER IS ABOUT TO GO INACTIVE" ); Notify( ply, 4, 3, "PRESS USE ON IT TO PREVENT THIS" ); self.Entity:SetColor(Color(255,150,150,254)) end function ENT:Use(activator,caller) local ply = self.Owner if (self.NearInact==true && activator==ply && self.Entity:GetNWBool("sparking")==false && ply:CanAfford(40)) then ply:AddMoney( -40 ) self.NearInact = false self.Entity:SetNWBool("sparking",true) timer.Create( tostring(self.Entity) .. "resupply", 1, 1, function() self:Reload() end) end end function ENT:Reload() Notify(self.Owner, 0, 3, "Counterfeit money printer resupplied") timer.Destroy( tostring(self.Entity) .. "fuckafkfags") timer.Create( tostring(self.Entity) .. "fuckafkfags", 250, 1, function() self:shutOff() end) timer.Destroy( tostring(self.Entity) .. "notifyoff") timer.Create( tostring(self.Entity) .. "notifyoff", 200, 1, function() self:notifypl() end) self.Inactive = false self.NearInact = false ply:AddMoney( -250 ) self.Entity:SetColor(Color(140, 120, 83, 254)) local drugPos = self.Entity:GetPos() self.Entity:SetNWBool("sparking",false) end function ENT:Think() if (IsValid(self.Owner)==false) then self.Entity:Remove() end end function ENT:OnRemove( ) timer.Destroy(tostring(self.Entity)) timer.Destroy(tostring(self.Entity) .. "fuckafkfags") timer.Destroy(tostring(self.Entity) .. "notifyoff") local ply = self.Owner if IsValid(ply) then ply:GetTable().maxBronzePrinter=ply:GetTable().maxBronzePrinter - 1 end end[/CODE] //Made by: Warrior Gaming Basically, I have tried pretty much everything to my knowledge, now I am asking for some help which was my last resort. Thanks in advance, Warrior Gaming [highlight](User was banned for this post ("wrong section, make one thread not two" - postal))[/highlight]
Any errors?
Yes, the errors consist of saying: [ERROR][@gamemodes/Basewars/entities/entities/money_printer_bronze/init.lua:15: Timer Failed! - In the console then that ERROR I have tried pretty much everything to my knowledge. Thanks.
Your timers are incorrect. You need () at the end of your function when you call it. [editline]28th November 2013[/editline] Example: [lua] timer.Create(tostring(self.Entity), 18, 0, function() self:giveMoney() end) [/lua]
[QUOTE=ms333;43007053]Your timers are incorrect. You need () at the end of your function when you call it. [editline]28th November 2013[/editline] Example: [lua] timer.Create(tostring(self.Entity), 18, 0, function() self:giveMoney() end) [/lua][/QUOTE] I have tried that, it still give me the same error; it just isn't working; I will try it later. Thanks for the help though :)
Well that's a start. Also, the entire error output would be nice.
[QUOTE=ms333;43007080]Well that's a start. Also, the entire error output would be nice.[/QUOTE] I will try to get the whole error output for you, I cannot at the moment. It will hopefully be with you within the next hour. [editline]28th November 2013[/editline] Sorry I could not get you the whole output, will get it to you by: 4:30pm
Sorry, you need to Log In to post a reply to this thread.