Run check when someone spawns clientside?

Hi guys, I’m pretty new to Lua coding my self and I’m trying to make a script that checks a user when they spawn, like their steamid and comments about them.

I already have the function to check them and I only need a hook or something, I tried doing a timer and it spams their thing in console+chat every seconds the timer is set to.

I need it to do something like


 function G_ListSpawn(self)
timer.Simple(G_WaitFor, function()
G_CheckList()
end)
end
hook.Add("PlayerInitialSpawn", "G_Spawn", G_ListSpawn)

but I’m pretty sure that the hook PlayerInitialSpawn is server side :frowning: please help

if you want to use those hooks clientside i’d recommend utilising the net library, check out the wiki page, it should be pretty helpful

I don’t know how to use those…

god is it too much to ask for at least some effort from your side?


if SERVER then
 util.AddNetworkString( "PlySpawned" )

hook.Add("PlayerSpawn","CSSpawn",function(ply)
  net.Start("PlySpawned") -- Start writing net msg
  net.WriteEntity(ply) --Who spawns? ply does
  net.Broadcast() --Sends to all players
end)

else --Clientside if you couldnt tell

net.Receive( "PlySpawned", function()
  local ply = net.ReadEntity()		 
  print( ply:GetName().." just spawned!" )
end )

end




Well if you spoon feed the guy he will continue asking to be spoon fed, sorta like a kitten. I mean its not like we have the largest amount of human knowledge at our fingertips…

I googled “Gmod lua how to use net library” and came up with this:

Enjoy

When PlayerInitialSpawn is called on server, that player is still not created on client, so if you use the net library to replicate this hook clientside, that clientside ply will be nil.

My prefered solution in this case is to use the OnEntityCreated hook on clientside, and check if the entity is a player, etc…

ok thanks :DD