Server Owner In-Server - Is This Right?

What I want to do is make a script that sends a message to the clients on my server telling them if I’m in the server or not (I know that they can just press the tab key). I got stuck after this started looking wrong.


if player("PlayerNameHere") = false then
	Msg("PlayerNameHere is gone.")
else
	Msg("PlayerNameHere is here."
end

If it is right then how would I make it resend the message again and again with intervals of 120 seconds between each message?

[lua]
local ID = “STEAM_0:0:16636723”

for _, v in ipairs( player.GetAll() ) do
    if v:SteamID() == ID then
	Msg(v:GetName().." is here.

“)
else
Msg(v:GetName()…” is gone.
")
end
end
[/lua]

[lua]local mySteamID = “your steamid here”

timer.Create(“NotifyPlayersOfMe”, 120, 0, function()
local found

for _,v in ipairs(player.GetAll()) do
    if(v:SteamID() == mySteamID) then
        found = true
    end
end

if(found) then
    FindMetaTable("Player"):ChatPrint("MyName is on the server!")

else
FindMetaTable(“Player”):ChatPrint(“MyName is not on the server!”)
end
end
[/lua]

I broke a lot of my habits with this piece of code. Oh well.

Dave, you missed a ) near the last end. And you aren’t even concat’ing his name.

[editline]11:00AM[/editline]

And, chatprint doesn’t take tables.

Thank you, I’m going to add that code now.

It won’t work by the way.

Then I’ll attempt to tweak it to make it work.

[lua]

local mySteamID = “your steamid here”

timer.Create(“NotifyPlayersOfMe”, 120, 0, function()
local found
local name
for _,v in ipairs(player.GetAll()) do
if(v:SteamID() == mySteamID) then
found = true
name = v:Nick()
end
end

if(found) then
   for _,v in ipairs(player.GetAll()) do v:ChatPrint(name.." is on the server!") end

else
for _,v in ipairs(player.GetAll()) do v:ChatPrint(name…" is not on the server!") end
end
end)
[/lua]
Fixed it.

Thank you.

Oshit, i forgot something

[editline]11:19AM[/editline]

Fixed

Yeah yeah, but I was kinda in a rush, so I missed a few things.

Did you know you can call a function on the metatable and it’ll send it to all the entities who have that metatable? Isn’t that great :slight_smile:

Really? News to me.

If Dave is correct I learned something new, thanks!