Hi, I am trying to convert these lines to net. Any help please?
Client:
[code]
function jobqueue:OpenQueueWindow(t)
blah blah
end
[/code]
Server
[code]
p:SendLua("jobqueue:OpenQueueWindow("..t..")")
[/code] Thanks
I'm not sure what "t" is so you made need to change the net.Write* and net.Read* parts.
serverside
[code]
util.AddNetworkString("openWindowJobs");
//inside your function; would replace your SendLua() part
net.Start("openWindowJobs");
net.WriteString(t);
net.Send(p);
[/code]
clientside
[code]
net.Receive("openWindowJobs", function()
local t = net.ReadString();
jobqueue:OpenQueueWindow(t);
end)
[/code]
yeah its a string... nice guess!
Oops clientside was wrong - updated.
Hmmmmmmmmmmmmm It may not be a string. Heres wat i has.
[code]
[ERROR] addons/queue/lua/darkrp_modules/queue/cl_init.lua:11: attempt to index a nil value
1. OpenQueueWindow - addons/queue/lua/darkrp_modules/queue/cl_init.lua:11
2. func - addons/queue/lua/darkrp_modules/queue/cl_init.lua:7
3. unknown - lua/includes/modules/net.lua:32
[/code]
Client:
[code]jobqueue={}
net.Receive("openQueueMenu", function()
local t = net.ReadString();
jobqueue:OpenQueueWindow(t);
end)
function jobqueue:OpenQueueWindow(t)
local teamName=RPExtraTeams[t].name
local frame=vgui.Create("DFrame")
frame:SetSize(300,110)
frame:SetPos(ScrW()/2-frame:GetWide()/2,ScrH()/2-frame:GetTall()/2)
frame:SetVisible(true)
frame:SetTitle("QUEUE")
frame:SetDraggable(false)
frame:MakePopup()
frame:DoModal(true)[/code]
server:
[code]
jobqueue={}
util.AddNetworkString("AddToQueue")
util.AddNetworkString("RemoveFromQueue")
util.AddNetworkString("BecomeJob")
util.AddNetworkString("openQueueMenu");
local function hookedChangeTeam(p,t,f)
if f then return true end
local TEAM = RPExtraTeams[t]
if not TEAM then return false end
local max = TEAM.max
if (max ~= 0 and -- No limit
(max >= 1 and team.NumPlayers(t) >= max or -- absolute maximum
max < 1 and (team.NumPlayers(t) + 1) / #player.GetAll() > max) and p:Team()~=t) or jobqueue.status[t]>1 then -- fractional limit (in percentages
if jobqueue.status[t]<2 or (jobqueue.status[t]>1 and jobqueue.queue[t][1]~=p) then
net.Start("openQueueMenu");
net.WriteString(t);
net.Send(p);
return false
end
end
return true
end
jobqueue.queue={}
jobqueue.status={}
[/code]
Looks like t is probably a number, just do like tonumber(t) on the client or something
i used WriteInt and ReadInt, still broken.
Can you print exactly what t is?
yeah i made it print as a string, it said: 4. But when i used ReadInt and WriteInt it didnt work?
[editline]5th August 2014[/editline]
EDIT: Got it working. tonumber <3
Sorry, you need to Log In to post a reply to this thread.