[b]You know ween you connect on a server and somethimes in chat appears something like " Join to
[url]www.google.ro[/url] " And I make this Thread becouse I can't fix it [/b]
timer.Create( "Delay", 20, 0, function()
or k,v in pairs( player.GetAll() ) do
v:ChatPrint( "Join ...whatever" )
end
end )
[b]The problem is cause this think don't work , and all the time ween I add this then I restart the server the first line disappear.
I put it on "garrysmod/lua/autorun/server/ " and I try to " garrysmod/lua/autorun/server " but none went [/b]
Did you just seriously write the line numbers yourself?
[LUA]timer.Create("JGDelay", 20, 0, function()
for _, ply in pairs(player.GetAll()) do
ply:ChatPrint("Joing to www.google.ro")
end
end)[/LUA]
[QUOTE=freemmaann;28969234]Did you just seriously write the line numbers yourself?
[LUA]
timer.Create("JGDelay", 20, 0, function()
for _, ply in pairs(player.GetAll()) do
ply:ChatPrint("Joing to www.google.ro")
end
end)
[/LUA][/QUOTE]
yes , becouse I don't know cause i can use [LUA]
And here [b] timer.Create("JGDelay", 20, 0, function() = 20 mean how many seconds !! yes ?[/b]
[editline]3rd April 2011[/editline]
And still the first line its remove after I restart the server ! I Get just this after Restart
[LUA] for _, ply in pairs(player.GetAll()) do
ply:ChatPrint("Joing to www.google.ro")
end
end) [/LUA]
[QUOTE=R@Rdeathmatch;28969334]yes , becouse I don't know cause i can use [LUA]
And here [b] timer.Create("JGDelay", 20, 0, function() = 20 mean how many seconds !! yes ?[/b]
[editline]3rd April 2011[/editline]
And still the first line its remove after I restart the server ! I Get just this after Restart
[LUA] for _, ply in pairs(player.GetAll()) do
ply:ChatPrint("Joing to www.google.ro")
end
end) [/LUA][/QUOTE]
Yes, check the wiki for more info: [b][url=http://wiki.garrysmod.com/?title=Timer.Create]Timer.Create [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b].
[QUOTE=freemmaann;28969581]Yes, check the wiki for more info: [b][url=http://wiki.garrysmod.com/?title=Timer.Create]Timer.Create [img_thumb]http://wiki.garrysmod.com/favicon.ico[/img_thumb][/url][/b].[/QUOTE]
No Becouse I don't Found it !!
[QUOTE=R@Rdeathmatch;28969857]No Becouse I don't Found it !![/QUOTE]
What are you talking about?
[QUOTE=freemmaann;28969908]What are you talking about?[/QUOTE]
I don't know about what to look on wiki ! this is why I don't found it there .
In the gamemode you could do:
[lua]
function SayToAll(arg) --When this function is run
for _, v in pairs(player.GetAll()) do --Get all players and
v:ChatPrint(""..arg.."") --Print whatever the string is in their chat boxes
end
end
function WebsiteJoin()
timer.Simple(100, WebsiteJoin)
SayToAll("Join at google.ro to become a part of the community!")
end
hook.Add("Initialize", "WebsiteMessage", WebsiteJoin)
[/lua]
[QUOTE=cis.joshb;28971855]In the gamemode you could do:
[lua]
function SayToAll(arg) --When this function is run
for _, v in pairs(player.GetAll()) do --Get all players and
v:ChatPrint(""..arg.."") --Print whatever the string is in their chat boxes
end
end
function WebsiteJoin()
timer.Simple(100, WebsiteJoin)
SayToAll("Join at google.ro to become a part of the community!")
end
hook.Add("Initialize", "WebsiteMessage", WebsiteJoin)
[/lua][/QUOTE]
I run SandBox so in what file I should put it ?? or I can put it on " garrysmod/lua/autorun/server/ " and there I make a new lua file with a name and I put this inside !
[QUOTE=cis.joshb;28971855]In the gamemode you could do:
[lua]
function SayToAll(arg) --When this function is run
for _, v in pairs(player.GetAll()) do --Get all players and
v:ChatPrint(""..arg.."") --Print whatever the string is in their chat boxes
end
end
function WebsiteJoin()
timer.Simple(100, WebsiteJoin)
SayToAll("Join at google.ro to become a part of the community!")
end
hook.Add("Initialize", "WebsiteMessage", WebsiteJoin)
[/lua][/QUOTE]
I run SandBox so in what file I should put it ?? or I can put it on " garrysmod/lua/autorun/server/ " and there I make a new lua file with a name and I put this inside !
Put it in init.lua
And you can use the
[lua]
SayToAll(arg)
[/lua]
function whenever you need to say something to everyone.
[QUOTE=Crap-Head;28974461]Put it in init.lua[/QUOTE]
Thx
[QUOTE=cis.joshb;28971855]In the gamemode you could do:
[lua]
function SayToAll(arg) --When this function is run
for _, v in pairs(player.GetAll()) do --Get all players and
v:ChatPrint(""..arg.."") --Print whatever the string is in their chat boxes
end
end
function WebsiteJoin()
timer.Simple(100, WebsiteJoin)
SayToAll("Join at google.ro to become a part of the community!")
end
hook.Add("Initialize", "WebsiteMessage", WebsiteJoin)
[/lua][/QUOTE]
I put this in init.lua to the finish of the code from there ! And ween i restart the server I get "Base Gamemode" not "SandBox"
Garry should really bring smartness back.
[QUOTE=Wizard of Ass;28996354]Garry should really bring smartness back.[/QUOTE]
He's obviously not native to english.
OP, non-lua language tip: [b]ween -> when[/b].
[editline]5th April 2011[/editline]
[QUOTE=R@Rdeathmatch;28994707]I put this in init.lua to the finish of the code from there ! And ween i restart the server I get "Base Gamemode" not "SandBox"[/QUOTE]
Don't put it in init.lua. That's silly.
Make a file lua/autorun/server/advert.lua.
Inside put:
[lua]
--180 sec = 3 min
timer.Create("adverttimer", 180, 0, function()
for k, v in ipairs(player.GetAll()) do
v:ChatPrint("Go to [url]www.lemonparty.org[/url] and join the community!")
end
end);
[/lua]
[QUOTE=Slight;28998449]He's obviously not native to english.
OP, non-lua language tip: [b]ween -> when[/b].
[editline]5th April 2011[/editline]
Don't put it in init.lua. That's silly.
Make a file lua/autorun/server/advert.lua.
Inside put:
[lua]
--180 sec = 3 min
timer.Create("adverttimer", 180, 0, function()
for k, v in ipairs(player.GetAll()) do
v:ChatPrint("Go to [url]www.lemonparty.org[/url] and join the community!")
end
end);
[/lua][/QUOTE]
Thx I will try
What?
[editline]5th April 2011[/editline]
My SayToAll should have ipairs, not pairs I think.
[QUOTE=cis.joshb;29007114]What?
[editline]5th April 2011[/editline]
My SayToAll should have ipairs, not pairs I think.[/QUOTE]
In this case, it doesn't matter. ipairs only works in cases where you got numerical indexes, and it goes from 1-2-3-4-5-6.... It does make the numbers come in order, but who cares if someone gets their message a split second before another gets it?
[QUOTE=R@Rdeathmatch;29000197]Thx I will try[/QUOTE]
There I make a post but I put in in [QUOTE] this was the problem why you don't see it !
[QUOTE=Slight;28998449]He's obviously not native to english.
OP, non-lua language tip: [b]ween -> when[/b].
[editline]5th April 2011[/editline]
Don't put it in init.lua. That's silly.
Make a file lua/autorun/server/advert.lua.
Inside put:
[lua]
--180 sec = 3 min
timer.Create("adverttimer", 180, 0, function()
for k, v in ipairs(player.GetAll()) do
v:ChatPrint("Go to [url]www.lemonparty.org[/url] and join the community!")
end
end);
[/lua][/QUOTE]
Thanks this it work !! And I want to ask you another think , how can I color what he print ??
And I want to ask what make the " 0 " = timer.Create("adverttimer", 180, 0, function() = the 180 is the time and 0 is ?
[QUOTE=R@Rdeathmatch;29091910]Thanks this it work !! And I want to ask you another think , how can I color what he print ??
And I want to ask what make the " 0 " = timer.Create("adverttimer", 180, 0, function() = the 180 is the time and 0 is ?[/QUOTE]
You can't change the print colour, the blue means its being printed serverside, the orange clientside.
You need to check the wiki before you make questions, people seem way less annoying that way, the third argument is the loop number, how many times the timer will repeat, 0 means infinite times.
[QUOTE=R@Rdeathmatch;29091910]Thanks this it work !! And I want to ask you another think , how can I color what he print ??
And I want to ask what make the " 0 " = timer.Create("adverttimer", 180, 0, function() = the 180 is the time and 0 is ?[/QUOTE]
I recommend you bookmark this page in your browser: [url]http://wiki.garrysmod.com/?title=Lua[/url] use the search bar to the right.
If you read the [b][url=http://wiki.garrysmod.com/?title=Timer.Create]Timer.Create [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b] page you'll see the third argument is repetitions. 0 meaning never ending timer which can only be stopped manually.
[QUOTE=Donkie;29011723]who cares if someone gets their message a split second before another gets it?[/QUOTE]
All network data is sent per Tick, meaning if I call chatprint x times before the next tick, they will be sent at the same time.
Sorry, you need to Log In to post a reply to this thread.