Hi, I need help with my script, I can spawn an npc(in the entity menu) the npc can open menu with the use key. I use net function like this in server side
function ENT:Use(act, ply, use, val)
if IsValid(ply) and ply:IsPlayer() then
net.Start("HitmanUse")
net.Send(ply)
end
end
and this in client side
net.Receive("HitmanUse", OpenHitmanUse())
the OpenHitmanUse function is declared like this
local function OpenHitmanUse()
.......
end
this code work but if I change this code to
function ENT:Use(act, ply, use, val)
if IsValid(ply) and ply:IsPlayer() then
net.Start("HitmanUse")
net.WriteEntity(ply)
net.Send(ply)
end
end
net.Receive("HitmanUse", function(len, pl)
OpenHitmanUse(pl)
end)
local function OpenHitmanUse(pl)
THE SAME CODE HERE.....
end
the code not work, no error in console and the addon menu named "hitman" in the entity menu is not showed and the npc dispawn in game.
Sorry for my english i'm french, Thanks.
I dont see you recieving the net.WriteEntity(ply) anywhere.
I think is my error how receive it in my net.receive function ?
Why do you need to WriteEntity.
And did you util.AddNetworkString?
yes I have use util.AddNetworkString
util.AddNetworkString("HitmanUse")
I would to send ply to the client side
net.Receive("HitmanUse", OpenHitmanUse())
should be
net.Receive("HitmanUse", OpenHitmanUse)
there's also no reason to send the player to itself, just call LocalPlayer.
thanks it's working
Sorry, you need to Log In to post a reply to this thread.