Soooo I need help with my map vote for TTT.
Here is my first attempt:
init.lua:
[CODE]
util.AddNetworkString("mv_start")
hook.Add("TTTEndRound", "Checkforroundend", function()
net.Start("mv_start")
net.Broadcast()
print("Hook checked and sended!")
end)
[/CODE]
cl_init.lua:
[CODE]
net.Receive("mv_start", function()
local mv_frame = vgui.Create("DFrame")
mv_frame:SetSize(ScrW(), ScrH())
mv_frame:Center()
mv_frame:SetVisible(true)
mv_frame:MakePopup()
mv_frame:SetDraggable(false)
mv_frame:SetSizable(false)
mv_frame.Paint = function(s, w, h)
draw.RoudedBox(0, 0, 0, w, h, Color(5, 5, 5, 240))
end
print("Frame created and received!")
end)
[/CODE]
And here is my second attempt:
init.lua:
[CODE]
util.AddNetworkString("mv_start")
hook.Add( "Initialize", "AutoTTTMapVote", function()
print("Hook checked and sended!")
if GAMEMODE_NAME == "terrortown" then
function CheckForMapSwitch()
-- Check for mapswitch
local rounds_left = math.max(0, GetGlobalInt("ttt_rounds_left", 3) - 1)
SetGlobalInt("ttt_rounds_left", rounds_left)
local time_left = math.max(0, (GetConVar("ttt_time_limit_minutes"):GetInt() * 60) - CurTime())
local switchmap = false
local nextmap = string.upper(game.GetMapNext())
if rounds_left <= 0 then
LANG.Msg("limit_round", {mapname = nextmap})
switchmap = true
elseif time_left <= 0 then
LANG.Msg("limit_time", {mapname = nextmap})
switchmap = true
end
if switchmap then
timer.Stop("end2prep")
net.Start("mv_start")
net.Broadcast()
end
end
end
end)
[/CODE]
cl_init.lua is the same as in the first attempt
So the prints just doesn't work... and derma doesn't open.
Both attempts were failed.
Thanks
The first thing that comes to mind is that you're not writing anything to "mv_start". So, you're starting it, and then sending it out, but nothing with it, which might be why it's not working clientside. Try:
[code]
net.Start("mv_start")
net.WriteString("mapnameorsomething")
net.Broadcast()
[/code]
and see if that triggers it.
The reason I think this is because the docs for [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/net/Broadcast]net.Broadcast[/url] say "sends the currently built net message", and if there's no net message built yet it might not send.
[QUOTE=Shadari;52490015]The first thing that comes to mind is that you're not writing anything to "mv_start". So, you're starting it, and then sending it out, but nothing with it, which might be why it's not working clientside. Try:
[code]
net.Start("mv_start")
net.WriteString("mapnameorsomething")
net.Broadcast()
[/code]
and see if that triggers it.
The reason I think this is because the docs for [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/net/Broadcast]net.Broadcast[/url] say "sends the currently built net message", and if there's no net message built yet it might not send.[/QUOTE]
I don't think that's the problem as the print's doesn't work as well. I think it might be something with the hook itself.
[QUOTE=matik04;52490028]I don't think that's the problem as the print's doesn't work as well. I think it might be something with the hook itself.[/QUOTE]
Can you confirm that the files that that code is in is loading in? Put a print statement at the top of each file with [code]print("file X has loaded")[/code] to make sure it's an issue with the code and not GMod not reading the file or something.
[QUOTE=Shadari;52490076]Can you confirm that the files that that code is in is loading in? Put a print statement at the top of each file with [code]print("file X has loaded")[/code] to make sure it's an issue with the code and not GMod not reading the file or something.[/QUOTE]
hmm... nope but idk if it'll help: When I typed in "reload_legacy_addons" the folder with the mapvote showed up.
[QUOTE=matik04;52490121]hmm... nope but idk if it'll help: When I typed in "reload_legacy_addons" the folder with the mapvote showed up.[/QUOTE]
So, the reason I ask this is because I think it might be an issue with the plugin being loaded in and not with your code. reload_legacy_addons will print any folders it finds in the addons folder, but if the addon can't load then that's a separate issue. (If I'm wrong on this, someone please step in and correct me because I don't want to spread misinformation. This is based on me running 'reload_legacy_addons', creating a new empty folder in addons, and running the command again and the folder showing up.)
Can you post your addon.json, and your folder structure?
[QUOTE=Shadari;52490151]So, the reason I ask this is because I think it might be an issue with the plugin being loaded in and not with your code. reload_legacy_addons will print any folders it finds in the addons folder, but if the addon can't load then that's a separate issue. (If I'm wrong on this, someone please step in and correct me because I don't want to spread misinformation. This is based on me running 'reload_legacy_addons', creating a new empty folder in addons, and running the command again and the folder showing up.)
Can you post your addon.json, and your folder structure?[/QUOTE]
I didn't created it as it was a test addon.
I think I didn't needed a addon.json I could be wrong.
[QUOTE=matik04;52490163]I didn't created it as it was a test addon.
I think I didn't needed a addon.json I could be wrong.[/QUOTE]
I might be wrong about the addon.json thing, as I don't know the engine inside and out.
But -- if you have test prints at the very top of your files and you're not seeing the output in your console, then that leads me to believe the file isn't being read. The reason I think that its not running is probably the folder structure. The folder structure should be
[code]addons/youraddonfolder/lua/autorun/server/init.lua
addons/youraddonfolder/lua/autorun/client/cl_init.lua[/code]
If that looks right, someone with more experience might have to step in, because your code looks right and your addon should be running and at least printing testing/debug messages at this point.
[QUOTE=Shadari;52490202]I might be wrong about the addon.json thing, as I don't know the engine inside and out.
But -- if you have test prints at the very top of your files and you're not seeing the output in your console, then that leads me to believe the file isn't being read. The reason I think that its not running is probably the folder structure. The folder structure should be
[code]addons/youraddonfolder/lua/autorun/server/init.lua
addons/youraddonfolder/lua/autorun/client/cl_init.lua[/code]
If that looks right, someone with more experience might have to step in, because your code looks right and your addon should be running and at least printing testing/debug messages at this point.[/QUOTE]
hm I did "addons/youraddonfolder/lua/autorun/init.lua and cl_init.lua" as it always worked.
I can try it if you want.
Hmmm... wierd... very wierd, it works now. But I remember that I was doing right... Maybe I mistaked it with entities. But still thanks!
Sorry, you need to Log In to post a reply to this thread.