• How to fix this network problem?
    2 replies, posted
CLIENT [Lua] hook.Add( "OnPlayerChat", "HelloCommand", function( ply, strText, bTeam, bDead ) strText = string.lower( strText ) if ( strText == "!wanted" ) then DOAP = vgui.Create( "DFrame" ) DOAP:SetSize( 1000, 500 ) DOAP:SetText( "" ) DOAP:Center() DOAP:SetTitle("") DOAP:SetVisible( true ) DOAP:SetDraggable( false ) DOAP:ShowCloseButton( false ) DOAP:MakePopup() DOAP.Paint = function(s, w, h) draw.RoundedBox(5, 0, 0, w, h, Color(0,0,0)) draw.RoundedBox(5, 2, 2, w-4, h-4, Color(50, 50, 50)) end local DOAB5 = vgui.Create( "DButton" , DOAP ) DOAB5:SetPos( 615, 361) DOAB5:SetText( "Update" ) DOAB5:SetTextColor(Color(255,255,255)) DOAB5:SetSize( 100, 18 ) DOAB5:SetTextColor( Color(255,255,255)) DOAB5.Paint = function(s, w, h) draw.RoundedBox(3,0,0,w,h,Color(50, 50, 255)) end DOAB5.DoClick = function() DOATEXTE:OnChange() DOATEXTE:OnTextChanged( true ) Pricedead = tonumber( DOATEXTE:GetValue() ) end local DOAB6 = vgui.Create( "DButton" , DOAP ) DOAB6:SetPos( 615, 421) DOAB6:SetText( "Update" ) DOAB6:SetTextColor(Color(255,255,255)) DOAB6:SetSize( 100, 18 ) DOAB6:SetTextColor( Color(255,255,255)) DOAB6.Paint = function(s, w, h) draw.RoundedBox(3,0,0,w,h,Color(50, 50, 255)) end DOAB6.DoClick = function() DOATEXTE2:OnChange() DOATEXTE2:OnTextChanged( true ) Pricealive = tonumber( DOATEXTE2:GetValue() ) end local DOAT2 = vgui.Create( "DLabel" , DOAP ) DOAT2:SetPos( 465, 20 ) DOAT2:SetText( "Dead or Alive" ) DOAT2:SetSize(200, 20) local DOAB = vgui.Create( "DButton" , DOAP ) DOAB:SetPos( 977, 3) DOAB:SetText( "X" ) DOAB:SetSize( 20, 20 ) DOAB:SetTextColor( Color(255,255,255)) DOAB.Paint = function(s, w, h) draw.RoundedBox(3,0,0,w,h,Color(255, 50, 50)) end DOAB.DoClick = function() DOAP:Close() end local DOAC = vgui.Create( "DComboBox" , DOAP ) DOAC:SetPos( 400, 150 ) DOAC:SetSize( 200, 20 ) DOAC:SetValue( "Player" ) for k, v in pairs( player.GetAll() ) do DOAC:AddChoice ( tostring( v:Name() ) ) DOAC:GetSelected(v:Name()) play = v:Name() end local DOAT = vgui.Create( "DLabel" , DOAP ) DOAT:SetPos( 460, 35 ) DOAT:SetText( "Wanted menu" ) DOAT:SetSize(200,200) local DOAB2 = vgui.Create( "DButton" , DOAP ) DOAB2:SetPos( 390, 180) DOAB2:SetText( "Wanted" ) DOAB2:SetSize( 100, 20 ) DOAB2:SetTextColor( Color(255,255,255)) DOAB2.Paint = function(s, w, h) draw.RoundedBox(3,0,0,w,h,Color(255, 50, 50)) end DOAB2.DoClick = function() wanted = true unwanted = false net.Start( "DOAMESS" ) net.WriteString( play ) net.WriteBool( unwanted ) net.WriteBool( wanted ) net.WriteBool( Deadoralive ) net.WriteBool( Dead ) net.WriteBool( Alived ) net.WriteFloat( Pricealive ) net.WriteFloat( Pricedead ) net.SendToServer() end local DOAB3 = vgui.Create( "DButton" , DOAP ) DOAB3:SetPos( 510, 180) DOAB3:SetText( "Unwanted" ) DOAB3:SetTextColor(Color(255,255,255)) DOAB3:SetSize( 100, 20 ) DOAB3:SetTextColor( Color(255,255,255)) DOAB3.Paint = function(s, w, h) draw.RoundedBox(3,0,0,w,h,Color(50, 180, 50)) end DOAB3.DoClick = function() unwanted = true wanted = false net.Start( "DOAMESS" ) net.WriteString( play ) net.WriteBool( unwanted ) net.WriteBool( wanted ) net.WriteBool( Deadoralive ) net.WriteBool( Dead ) net.WriteBool( Alived ) net.WriteFloat( Pricealive ) net.WriteFloat( Pricedead ) net.SendToServer() end DOACH = vgui.Create("DCheckBox", DOAP) DOACH:SetPos(495,250) DOACH:Toggle() function DOACH:OnChange( bVal ) if ( bVal ) then DOACH2:SetValue() DOACH3:SetValue() Deadoralive = true end end DOACH2 = vgui.Create("DCheckBox", DOAP) DOACH2:SetPos(145,250) function DOACH2:OnChange( bVal ) if ( bVal ) then DOACH:SetValue() DOACH3:SetValue() Dead = true end end DOACH3 = vgui.Create("DCheckBox", DOAP) DOACH3:SetPos(845,250) function DOACH3:OnChange( bVal ) if ( bVal ) then DOACH2:SetValue() DOACH:SetValue() Alived = true end end local DOAT3 = vgui.Create( "DLabel" , DOAP ) DOAT3:SetPos( 140, 230 ) DOAT3:SetText( "Dead" ) DOAT3:SetSize(200, 20) local DOAT4 = vgui.Create( "DLabel" , DOAP ) DOAT4:SetPos(475, 230) DOAT4:SetText( "Dead or Alive" ) DOAT4:SetSize(200, 20) local DOAT5 = vgui.Create( "DLabel" , DOAP ) DOAT5:SetPos( 840, 230 ) DOAT5:SetText( "Alive" ) DOAT5:SetSize(200, 20) DOATEXTE = vgui.Create( "DTextEntry", DOAP ) DOATEXTE:SetPos( 410, 360 ) DOATEXTE:SetSize( 200, 20 ) DOATEXTE:SetText( 5000 ) DOATEXTE.OnEnter = function( self ) Pricedead = tonumber( self:GetValue() ) end DOATEXTE2 = vgui.Create( "DTextEntry", DOAP ) DOATEXTE2:SetPos( 410, 420 ) DOATEXTE2:SetSize( 200, 20 ) DOATEXTE2:SetText( 5000 ) DOATEXTE2.OnEnter = function( self ) Pricealive = tonumber( self:GetValue() ) end --local DOAB4 = vgui.Create( "DButton" , DOAP ) --DOAB4:SetPos( 460, 460) --DOAB4:SetText( "Done" ) --DOAB4:SetTextColor(Color(255,255,255)) --DOAB4:SetSize( 100, 20 ) --DOAB4:SetTextColor( Color(255,255,255)) --DOAB4.Paint = function(s, w, h) --draw.RoundedBox(3,0,0,w,h,Color(50, 50, 255)) --end --DOAB3.DoClick = function() -- net.Start( "DOAMESS" ) -- net.WriteString( play ) -- net.WriteBool( unwanted ) -- net.WriteBool( wanted ) -- net.WriteBool( Deadoralive ) -- net.WriteBool( Dead ) -- net.WriteBool( Alived ) -- net.WriteFloat( Pricealive ) -- net.WriteFloat( Pricedead ) -- net.SendToServer() --end local DOAT6 = vgui.Create( "DLabel" , DOAP ) DOAT6:SetPos( 485, 340 ) DOAT6:SetText( "Price dead" ) DOAT6:SetSize(200, 20) local DOAT7 = vgui.Create( "DLabel" , DOAP ) DOAT7:SetPos( 485, 400 ) DOAT7:SetText( "Price alive" ) DOAT7:SetSize(200, 20) return true end end ) [/Lua] SERVER [Lua] util.AddNetworkString( "DOAMESS" ) net.Receive( "DOAMESS", function(len, ply) MsgN("DOAMESS: Contains "..len.." bits") --MsgN("Player: "..ply) local play = net.ReadString() local unwanted = net.ReadBool() local wanted = net.ReadBool() local doa = net.ReadBool() local dead = net.ReadBool() local alive = net.ReadBool() local pricealive = net.ReadFloat() local pricedead = net.ReadFloat() end) if doa == true then reason = "Dead or Alive" print("It ") end if dead == true then reason = "Dead" print("did ") end if alive == true then reason = "Alive" print("work! ") end if wanted == true then if play:isWanted() then return end play:wanted( "Goverment", play:Nick() .. " is wanted by the police! " .. reason .. pricedead .. pricealive, 120 ) print("yay 1 ") end if unwanted == true then if not play:isWanted() then return end play:unWanted("Goverment") play(" yay 2 ") end print("end") [/Lua] CONSOLE OUTPUT DOAMESS 301 bites [editline]28th March 2016[/editline] It doesn't execute anything it just prints this out in the console. DOAMESS 301 bites
[code] util.AddNetworkString( "DOAMESS" ) net.Receive( "DOAMESS", function(len, ply) MsgN("DOAMESS: Contains "..len.." bits") --MsgN("Player: "..ply) local play = net.ReadString() local unwanted = net.ReadBool() local wanted = net.ReadBool() local doa = net.ReadBool() local dead = net.ReadBool() local alive = net.ReadBool() local pricealive = net.ReadFloat() local pricedead = net.ReadFloat() if doa == true then reason = "Dead or Alive" print("It ") end if dead == true then reason = "Dead" print("did ") end if alive == true then reason = "Alive" print("work! ") end if wanted == true then if play:isWanted() then return end play:wanted( "Goverment", play:Nick() .. " is wanted by the police! " .. reason .. pricedead .. pricealive, 120 ) print("yay 1 ") end if unwanted == true then if not play:isWanted() then return end play:unWanted("Goverment") play(" yay 2 ") end end) print("end") [/code]
[QUOTE=Coffeee;50020999]util.AddNetworkString( "DOAMESS" ) net.Receive( "DOAMESS", function(len, ply) MsgN("DOAMESS: Contains "..len.." bits") --MsgN("Player: "..ply) local play = net.ReadString() local unwanted = net.ReadBool() local wanted = net.ReadBool() local doa = net.ReadBool() local dead = net.ReadBool() local alive = net.ReadBool() local pricealive = net.ReadFloat() local pricedead = net.ReadFloat() if doa == true then reason = "Dead or Alive" print("It ") end if dead == true then reason = "Dead" print("did ") end if alive == true then reason = "Alive" print("work! ") end if wanted == true then if play:isWanted() then return end play:wanted( "Goverment", play:Nick() .. " is wanted by the police! " .. reason .. pricedead .. pricealive, 120 ) print("yay 1 ") end if unwanted == true then if not play:isWanted() then return end play:unWanted("Goverment") play(" yay 2 ") end end) print("end")[/QUOTE] Doesn't work :(
Sorry, you need to Log In to post a reply to this thread.