I am currently attempting to make a DarkRP money printer, and attempting to make upgrade-able, While networking between the Client and Server this Error Appeared
[ERROR] lua/entities/sentinel_printer/init.lua:51: Tried to use a NULL entity!
1. Send - [C]:-1
2. func - lua/entities/sentinel_printer/init.lua:51
3. unknown - lua/includes/extensions/net.lua:32
I’ve tried rewriting the code in a different manner a few days ago but it still didn’t work. I’ve been told it’s because the receiving end is expecting an entity or is sending one, honestly I haven’t been able to wrap my head around that.
Client Code:
function speedpressed()
net.Start("SpeedCommsServer")
net.SendToServer("SpeedCommsServer")
end
net.Receive("SpeedLevelSuccess",function()
notification.AddLegacy("You have upgraded your printer!",0,5)
surface.PlaySound("common/stuck1.wav")
end)
net.Receive("SpeedLevelFailure",function()
notification.AddLegacy("Your printer is already max level!",0,5)
//surface.PlaySound("")
end)
The “SpeedPressed” is for a Derma button which sends a message to the server so it can do the logic and return whether the result to show the player.
Server:
AddCSLuaFile("cl_init.lua")
AddCSLuaFile("shared.lua")
util.AddNetworkString("UseDerma")
util.AddNetworkString("EntityOwner")
util.AddNetworkString("SpeedCommsServer")
util.AddNetworkString("SpeedCommsClient")
util.AddNetworkString("SpeedLevelSuccess")
util.AddNetworkString("SpeedLevelFailure")
include("shared.lua")
function ENT:Initialize()
self:SetModel("models/props_c17/consolebox05a.mdl")
self:PhysicsInit(SOLID_VPHYSICS)
self:SetMoveType(MOVETYPE_VPHYSICS)
self:SetSolid(SOLID_VPHYSICS)
self.timer = CurTime()
local phys = self:GetPhysicsObject()
if phys:IsValid() then
phys:Wake()
end
local printerowner = self:GetOwner()
end
printlvl = 10
net.Receive("SpeedCommsServer",function()
if printlvl < 5 then
printlvl = printlvl + 1
net.Start("SpeedLevelSuccess")
net.Send("SpeedLevelSuccess")
elseif printlvl > 5 then
net.Start("SpeedLevelFailure")
net.Send("SpeedLevelFailure")
end
end)
If anyone could come up with a solution and help that’d be much appreciated! This is not the full code, but these are the relevant parts of the code.