Dark RP - Custom Entities

Hey Guys, sorry for posting here about this… but i’ve been playing around with this now for hours.

Before anyone asks, i have searched Facepunch for what i’m looking for before starting a new thread.

I’m starting up my own server, and i’ve absolutely no idea where to start… i’ve tried to learn the basics of Lua (loops, functions, etc) to understand the problems rather than relying on someone else to sort it, but i’ve come to my limit. :suicide:

Now this makes me sound seriously thick but hey! I’m trying to install some custom entities on Dark RP (money printers), it’s not a downloaded pack, i’ve done them myself; however, when i load up the garrys mod server, they return an error in console:

#1 error from console:
This error occurs on the server load.
[lua][gamemodes\darkrp\entities\entities\money_factory\init.lua:84] unexpected symbol near ‘,’
[gamemodes\darkrp\entities\entities\money_machine\init.lua:84] unexpected symbol near ‘,’
[gamemodes\darkrp\entities\entities\penny_printer\init.lua:84] unexpected symbol near ‘,’
[gamemodes\darkrp\entities\entities\refurbished_money_printer\init.lua:84] unexpected symbol near ‘,’[/lua]

#2 error from console:
This occurs when you try to purchase the printer.
[lua]Attempted to create unknown entity type money_machine!
[gamemodes\darkrp\gamemode\main.lua:1167] attempt to index field ‘dt’ (a nil value)(Hook: PlayerSay)
[cpp] Error: hook->PlayerSay returned a non-string!
Adam.: /buymoneymachine
[/lua]

If you have not enough money to purchase the printer, it returns
“You can not afford this” - supposed to happen.

So it’s something to do with the actual spawning of the entity - i’m guessing…

Here are my files:
(All the files are the same except the variables, such as amount to print, name, model, etc…)

addentities.lua
[lua]AddCustomShipment(“Desert eagle”, “models/weapons/w_pist_deagle.mdl”, “weapon_deagle2”, 215, 10, true, 215, true, {TEAM_GUN})
AddCustomShipment(“Fiveseven”, “models/weapons/w_pist_fiveseven.mdl”, “weapon_fiveseven2”, 0, 10, true, 205, true, {TEAM_GUN})
AddCustomShipment(“Glock”, “models/weapons/w_pist_glock18.mdl”, “weapon_glock2”, 0, 10, true, 160, true, {TEAM_GUN})
AddCustomShipment(“P228”, “models/weapons/w_pist_p228.mdl”, “weapon_p2282”, 0, 10, true, 185, true, {TEAM_GUN})

AddCustomShipment(“AK47”, “models/weapons/w_rif_ak47.mdl”, “weapon_ak472”, 2450, 10, false, nil, false, {TEAM_GUN})
AddCustomShipment(“MP5”, “models/weapons/w_smg_mp5.mdl”, “weapon_mp52”, 2200, 10, false, nil, false, {TEAM_GUN})
AddCustomShipment(“M4”, “models/weapons/w_rif_m4a1.mdl”, “weapon_m42”, 2450, 10, false, nil, false, {TEAM_GUN})
AddCustomShipment(“Mac 10”, “models/weapons/w_smg_mac10.mdl”, “weapon_mac102”, 2150, 10, false, nil, false, {TEAM_GUN})
AddCustomShipment(“Pump shotgun”, “models/weapons/w_shot_m3super90.mdl”, “weapon_pumpshotgun2”, 1750, 10, false, nil, false, {TEAM_GUN})
AddCustomShipment(“Sniper rifle”, “models/weapons/w_snip_g3sg1.mdl”, “ls_sniper”, 3750, 10, false, nil, false, {TEAM_GUN})

AddEntity(“Drug lab”, “drug_lab”, “models/props_lab/crematorcase.mdl”, 400, 3, “/buydruglab”, {TEAM_GANG, TEAM_MOB})
AddEntity(“Penny printer”, “penny_printer”, “models/props_lab/reciever01b.mdl”, 200, 2, “/buypennyprinter”)
AddEntity(“Refurbished Money printer”, “refurbished_money_printer”, “models/props_c17/consolebox03a.mdl”, 500, 2, “/buyrefurbprinter”)
AddEntity(“Money printer”, “money_printer”, “models/props_c17/consolebox01a.mdl”, 1000, 2, “/buymoneyprinter”)
AddEntity(“Money Machine”, “money_machine”, “models/props_lab/reciever_cart.mdl”, 5000, 2, “/buymoneymachine”)
AddEntity(“Money Factory”, “money_Factory”, “models/props_lab/servers.mdl”, 30000, 2, “/buymoneyfactory”)
AddEntity(“Microwave”, “microwave”, “models/props/cs_office/microwave.mdl”, 400, 1, “/buymicrowave”, TEAM_COOK)
AddEntity(“Gun lab”, “gunlab”, “models/props_c17/TrapPropeller_Engine.mdl”, 500, 1, “/buygunlab”, TEAM_GUN)[/lua]

cl_init.lua
[lua]include(“shared.lua”)

function ENT:Initialize()
end

function ENT:Draw()
self.Entity:DrawModel()

local Pos = self:GetPos()
local Ang = self:GetAngles()

local owner = self.dt.owning_ent
owner = (ValidEntity(owner) and owner:Nick()) or "unknown"

surface.SetFont("HUDNumber5")
local TextWidth = surface.GetTextSize("Money machine")
local TextWidth2 = surface.GetTextSize(owner)

Ang:RotateAroundAxis(Ang:Up(), 90)

cam.Start3D2D(Pos + Ang:Up() * 11.5, Ang, 0.11)
	draw.WordBox(2, -TextWidth*0.5, -30, "Money machine", "HUDNumber5", Color(140, 0, 0, 100), Color(255,255,255,255))
	draw.WordBox(2, -TextWidth2*0.5, 18, owner, "HUDNumber5", Color(140, 0, 0, 100), Color(255,255,255,255))
cam.End3D2D()

end

function ENT:Think()
end
[/lua]

init.lua
[lua] – RRPX Money Printer reworked for DarkRP by philxyz
AddCSLuaFile(“cl_init.lua”)
AddCSLuaFile(“shared.lua”)
include(“shared.lua”)

local PrintMore
function ENT:Initialize()
self:SetModel(“models/props_lab/reciever_cart.mdl”)
self:PhysicsInit(SOLID_VPHYSICS)
self:SetMoveType(MOVETYPE_VPHYSICS)
self:SetSolid(SOLID_VPHYSICS)
local phys = self:GetPhysicsObject()
if phys:IsValid() then phys:Wake() end
self.sparking = false
self.damage = 100
self.IsMoneyPrinter = true
timer.Simple(27, PrintMore, self)
end

function ENT:OnTakeDamage(dmg)
if self.burningup then return end

self.damage = (self.damage or 100) - dmg:GetDamage()
if self.damage <= 0 then
	local rnd = math.random(1, 10)
	if rnd < 3 then
		self:BurstIntoFlames()
	else
		self:Destruct()
		self:Remove()
	end
end

end

function ENT:Destruct()
local vPoint = self:GetPos()
local effectdata = EffectData()
effectdata:SetStart(vPoint)
effectdata:SetOrigin(vPoint)
effectdata:SetScale(1)
util.Effect(“Explosion”, effectdata)
Notify(self.dt.owning_ent, 1, 4, “Your money machine has exploded!”)
end

function ENT:BurstIntoFlames()
Notify(self.dt.owning_ent, 0, 4, “Your money machine is overheating!”)
self.burningup = true
local burntime = math.random(8, 18)
self:Ignite(burntime, 0)
timer.Simple(burntime, self.Fireball, self)
end

function ENT:Fireball()
if not self:IsOnFire() then self.burningup = false return end
local dist = math.random(20, 280) – Explosion radius
self:Destruct()
for k, v in pairs(ents.FindInSphere(self:GetPos(), dist)) do
if not v:IsPlayer() and not v.IsMoneyPrinter then v:Ignite(math.random(5, 22), 0) end
end
self:Remove()
end

PrintMore = function(ent)
if ValidEntity(ent) then
ent.sparking = true
timer.Simple(3, ent.CreateMoneybag, ent)
end
end

function ENT:CreateMoneybag()
if not ValidEntity(self) then return end
if self:IsOnFire() then return end
local MoneyPos = self:GetPos()

if math.random(1, 50) == 3 then self:BurstIntoFlames() end

local amount = GetConVarNumber("mprintamount")
if amount == 0 then
	amount = math.random(850, 1200)
end

DarkRPCreateMoneyBag(Vector(MoneyPos.x + 15, MoneyPos.y, MoneyPos.z + 15), amount)
self.sparking = false
timer.Simple(300), PrintMore, self)

end

function ENT:Think()
if not self.sparking then return end

local effectdata = EffectData()
effectdata:SetOrigin(self:GetPos())
effectdata:SetMagnitude(1)
effectdata:SetScale(1)
effectdata:SetRadius(2)
util.Effect("Sparks", effectdata)

end
[/lua]

shared.lua
[lua]ENT.Type = “anim”
ENT.Base = “base_gmodentity”
ENT.PrintName = “Money Machine”
ENT.Author = “Adam.”
ENT.Spawnable = false
ENT.AdminSpawnable = false

function ENT:SetupDataTables()
self:DTVar(“Int”,0,“price”)
self:DTVar(“Entity”,1,“owning_ent”)
end[/lua]

Yep, that’s all.
Basically, can someone point me in the right direction and show me what’s wrong here?

Thanks in advance!
Adam.

p.s. Sorry for DarkRP moaning.

timer.Simple(300***)***, PrintMore, self)

Remove that parenthesis.

Well, that’s the first error removed!

Cheers :slight_smile:

**Edit:

You gotta be kidding me… I restarted the server, and bang it works.

Thanks a lot TylerB :)**

*Edit 2:

And… I’ve come across another bug, they’re all printing 250…*

**Edit 3:

Fixed.**

Good luck on the server! :smile: