[code]if SERVER then
util.AddNetworkString("SendHints")
local hintDelay = 1200
hook.Add("Initialize", "SendHints", function()
timer.Create("SendHints", hintDelay, 0, function()
//send the message to display the hint.
net.Start("SendHints")
net.Broadcast()
end)
end)
else
//Definitions
local hintsRussian = {
"Something something",
"Something somethingelse"
}
local hintsEnglish = {
"Purge is un-active!",
"Purge is active!"
}
net.Receive("SendHints", function()
local isrus = GetConVarString("gmod_language") == "ru"
local msg = "No hints!"
if isrus then
local ran = math.random(1, #hintsRussian)
msg = hintsRussian[ran]
else
local num = math.random(1, #hintsEnglish)
msg = hintsEnglish[num]
end
chat.AddText(Color( 50, 255, 50 ), "[Purge] ", Color( 255, 255, 255 ), msg ) //show the message;
end)
end
[/code]
This system now shows a message for everyone at the same time, but doesn't show the same message for everyone, how can this be fixed, please help!
By not randomizing the num variable.
Try this:
[code]if SERVER then
util.AddNetworkString("Language")
end
if CLIENT then
net.Start("Language")
net.WriteString(GetConVarString("gmod_language"))
net.SendToServer()
end
if SERVER then
local hintsRussian = {
"Something something",
"Something somethingelse"
}
local hintsEnglish = {
"Purge is un-active!",
"Purge is active!"
}
local hintDelay = 10
net.Receive("Language", function(len, ply)
local language = net.ReadString()
end)
util.AddNetworkString("SendHints")
hook.Add("Initialize", "SendHints", function()
timer.Create("SendHints", hintDelay, 0, function()
net.Start("SendHints")
if language == "ru" then
net.WriteString(hintsRussian[math.random(1, #hintsRussian)])
else
net.WriteString(hintsEnglish[math.random(1, #hintsEnglish)])
end
net.Broadcast()
end)
end)
end
if CLIENT then
net.Receive("SendHints", function()
chat.AddText(Color( 50, 255, 50 ), "[Purge] ", Color( 255, 255, 255 ), net.ReadString() )
end)
end[/code]
[QUOTE=code_gs;45391258]Try this:
[code]if SERVER then
util.AddNetworkString("Language")
else
net.Start("Language")
net.WriteString(GetConVarString("gmod_language"))
net.SendToServer()
end
if SERVER then
local hintsRussian = {
"Something something",
"Something somethingelse"
}
local hintsEnglish = {
"Purge is un-active!",
"Purge is active!"
}
local hintDelay = 1200
net.Receive("Language", function(len, ply)
local language = net.ReadString()
end)
util.AddNetworkString("SendHints")
hook.Add("Initialize", "SendHints", function()
timer.Create("SendHints", hintDelay, 0, function()
net.Start("SendHints")
if language == "ru" then
net.WriteString(hintsRussian[math.random(1, #hintsRussian)])
else
net.WriteString(hintsEnglish[math.random(1, #hintsEnglish)])
end
net.Broadcast()
end)
end)
else
net.Receive("SendHints", function()
chat.AddText(Color( 50, 255, 50 ), "[Purge] ", Color( 255, 255, 255 ), net.ReadString() )
end)
end[/code][/QUOTE]
[ERROR] addons/adverts/lua/autorun/adverts.lua:7: Calling net.Start with unpooled message name [[url]http://goo.gl/qcx0y][/url]
1. Start - [C]:-1
2. unknown - addons/adverts/lua/autorun/adverts.lua:7
[editline]14th July 2014[/editline]
[QUOTE=Frozendairy;45391410][ERROR] addons/adverts/lua/autorun/adverts.lua:7: Calling net.Start with unpooled message name [[url]http://goo.gl/qcx0y][/url]
1. Start - [C]:-1
2. unknown - addons/adverts/lua/autorun/adverts.lua:7[/QUOTE]
I re-pasted, It didn't do the error again.
[editline]14th July 2014[/editline]
[QUOTE=Frozendairy;45391410][ERROR] addons/adverts/lua/autorun/adverts.lua:7: Calling net.Start with unpooled message name [[url]http://goo.gl/qcx0y][/url]
1. Start - [C]:-1
2. unknown - addons/adverts/lua/autorun/adverts.lua:7
[editline]14th July 2014[/editline]
I re-pasted, It didn't do the error again.[/QUOTE]
The System does not display the message, only "[Purge]"
Ok, so, I'm not trying to be rude at all when I say this, and I'll try and look into your issue, but you have made several threads in the last day regarding this, maybe it's time you try to do some debuging on your own instead replying here saying "here's the error, fix it".
[QUOTE=crazyscouter;45391608]Ok, so, I'm not trying to be rude at all when I say this, and I'll try and look into your issue, but you have made several threads in the last day regarding this, maybe it's time you try to do some debuging on your own instead replying here saying "here's the error, fix it".[/QUOTE]Just giving people something to do :)
Sorry, you need to Log In to post a reply to this thread.