Net Message -> Server To Client

  • Initiateur de la discussion Deadman69330
  • Date de début
  • Initiateur de la discussion
Deadman69330

Deadman69330

Psychopathe
Messages
2 289
Score réaction
309
Points
290
Bonjour,

J'aurais besoin d'envoyer un net message au client depuis le serveur. Le problème c'est que je galère :/
J'aurais bien besoin d'un petit coup de pouce, voilà mon code côté serveur (le message est censé s'envoyer dans le ENT:StartTouch(ent):

Code:
AddCSLuaFile("cl_init.lua")
AddCSLuaFile("shared.lua")
include("shared.lua")
util.AddNetworkString("IsCooking")
util.AddNetworkString("TimeLeft")
function ENT:Initialize() self:SetModel("models/props_c17/furnitureStove001a.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.isBaking = false self.finishBakeTime = 0
end
function ENT:StartTouch(ent) if ent:GetClass() == "deadman_cooking_farine" and self.isBaking == false then ent:Remove() self.isBaking = true self.finishBakeTime = CurTime() + Deadman.Config.Time.Cooking net.Start("TimeLeft") net.WriteBool(true) net.Send() end
end
function ENT:Think() if self.isBaking == true then if self.finishBakeTime <= CurTime() then self.isBaking = false local bread = ents.Create("deadman_cooking_bread") bread:SetPos(self:GetPos() + Vector(0,0,30)) bread:Spawn() end end
end


Et voilà le code client:
Code:
include("shared.lua")
surface.CreateFont("DeadmanCooking1", { font = "Arial", size = 50, weight = 500, blursize = 0, scanlines = 0, antialias = true,
} )
function ENT:Draw() self:DrawModel() local ang = self:GetAngles() ang:RotateAroundAxis(self:GetAngles():Right(), 270) ang:RotateAroundAxis(self:GetAngles():Forward(), 90) local pos = self:GetPos() cam.Start3D2D(pos/1.02, ang, 0.1) draw.RoundedBox(0,-250,-100,400,100,Color(0,0,0,180)) net.Receive("TimeLeft", function(len) if "TimeLeft" == false then draw.SimpleText("Mettre un ingrédient", "DeadmanCooking1",-50,-50,Color(120,120,255),1,1 ) else draw.SimpleText("Cuisson en cours...", "DeadmanCooking1",-50,-50,Color(120,120,255),1,1 ) end end) cam.End3D2D()
end
Merci beaucoup de votre aide
 
ZarosOVH

ZarosOVH

Modérateur
Membre du Staff
Messages
6 527
Score réaction
5 488
Points
1 295
dans le net.Send() tu dois rajouter comme argument le joueur qui doit recevoir ce net
 
  • Initiateur de la discussion
Deadman69330

Deadman69330

Psychopathe
Messages
2 289
Score réaction
309
Points
290
Zaros_Live à dit:
dans le net.Send() tu dois rajouter comme argument le joueur qui doit recevoir ce net
Code:
[ERROR] addons/deadman_cooking/lua/entities/deadman_cooking_cooker/init.lua:62: Tried to use a NULL entity! 1. Send - [C]:-1 2. unknown - addons/deadman_cooking/lua/entities/deadman_cooking_cooker/init.lua:62

et à la ligne 62 c'est le net.Send(ply)
 
ZarosOVH

ZarosOVH

Modérateur
Membre du Staff
Messages
6 527
Score réaction
5 488
Points
1 295
Deadman69330 à dit:
Code:
[ERROR] addons/deadman_cooking/lua/entities/deadman_cooking_cooker/init.lua:62: Tried to use a NULL entity! 1. Send - [C]:-1 2. unknown - addons/deadman_cooking/lua/entities/deadman_cooking_cooker/init.lua:62

et à la ligne 62 c'est le net.Send(ply)
Sur le code que tu as mit en haut, ply n’est pas declarer
 
thepsyca

thepsyca

Psychopathe
Messages
2 164
Score réaction
648
Points
365
Code:
AddCSLuaFile("cl_init.lua")
AddCSLuaFile("shared.lua")
include("shared.lua")
util.AddNetworkString("IsCooking")
function ENT:Initialize() self:SetModel("models/props_c17/furnitureStove001a.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.isBaking = false self.finishBakeTime = 0 self:SetNWBool( "timeleft", false )
end
function ENT:StartTouch(ent) if ent:GetClass() == "deadman_cooking_farine" and self.isBaking == false then ent:Remove() self.isBaking = true self.finishBakeTime = CurTime() + Deadman.Config.Time.Cooking self:SetNWBool( "timeleft", true ) end
end
function ENT:Think() if self.isBaking == true then if self.finishBakeTime <= CurTime() then self.isBaking = false local bread = ents.Create("deadman_cooking_bread") bread:SetPos(self:GetPos() + Vector(0,0,30)) bread:Spawn() end end
end
Code:
include("shared.lua")
surface.CreateFont("DeadmanCooking1", { font = "Arial", size = 50, weight = 500, blursize = 0, scanlines = 0, antialias = true,
} )
function ENT:Draw() self:DrawModel() local ang = self:GetAngles() ang:RotateAroundAxis(self:GetAngles():Right(), 270) ang:RotateAroundAxis(self:GetAngles():Forward(), 90) local pos = self:GetPos() cam.Start3D2D(pos/1.02, ang, 0.1) draw.RoundedBox(0,-250,-100,400,100,Color(0,0,0,180)) if self:GetNWBool( "timeleft" ) == false then draw.SimpleText("Mettre un ingrédient", "DeadmanCooking1",-50,-50,Color(120,120,255),1,1 ) else draw.SimpleText("Cuisson en cours...", "DeadmanCooking1",-50,-50,Color(120,120,255),1,1 ) end cam.End3D2D()
end

Essaie ça sinon
 
  • J'aime
Réactions: PierreB, Yoh Sambre ♪ et Deadman69330
  • Initiateur de la discussion
Deadman69330

Deadman69330

Psychopathe
Messages
2 289
Score réaction
309
Points
290
thepsyca à dit:
Code:
AddCSLuaFile("cl_init.lua")
AddCSLuaFile("shared.lua")
include("shared.lua")
util.AddNetworkString("IsCooking")
function ENT:Initialize() self:SetModel("models/props_c17/furnitureStove001a.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.isBaking = false self.finishBakeTime = 0 self:SetNWBool( "timeleft", false )
end
function ENT:StartTouch(ent) if ent:GetClass() == "deadman_cooking_farine" and self.isBaking == false then ent:Remove() self.isBaking = true self.finishBakeTime = CurTime() + Deadman.Config.Time.Cooking self:SetNWBool( "timeleft", true ) end
end
function ENT:Think() if self.isBaking == true then if self.finishBakeTime <= CurTime() then self.isBaking = false local bread = ents.Create("deadman_cooking_bread") bread:SetPos(self:GetPos() + Vector(0,0,30)) bread:Spawn() end end
end
Code:
include("shared.lua")
surface.CreateFont("DeadmanCooking1", { font = "Arial", size = 50, weight = 500, blursize = 0, scanlines = 0, antialias = true,
} )
function ENT:Draw() self:DrawModel() local ang = self:GetAngles() ang:RotateAroundAxis(self:GetAngles():Right(), 270) ang:RotateAroundAxis(self:GetAngles():Forward(), 90) local pos = self:GetPos() cam.Start3D2D(pos/1.02, ang, 0.1) draw.RoundedBox(0,-250,-100,400,100,Color(0,0,0,180)) if self:GetNWBool( "timeleft" ) == false then draw.SimpleText("Mettre un ingrédient", "DeadmanCooking1",-50,-50,Color(120,120,255),1,1 ) else draw.SimpleText("Cuisson en cours...", "DeadmanCooking1",-50,-50,Color(120,120,255),1,1 ) end cam.End3D2D()
end

Essaie ça sinon
Merci ca marche :)
 
Discord d'entraide
Rejoignz-nous sur Discord