• DCheckBoxLabel check NWInt, but still staying checked
    3 replies, posted
Hello, I'm creating a settings menu for in-game, this is some of the code below: CLIENT: local multi_core = vgui.Create( "DCheckBoxLabel", left_side ) multi_core:SetPos( 10, 40 ) multi_core:SetText( "Multicore Rendering" ) multi_core:SetFont( "SettingsOptionsCS" ) multi_core:SetTextColor( Color( 255, 255, 255 ) ) if LocalPlayer():GetNWInt( "CSMultiCoreS", 1 ) then     multi_core:SetValue( 1 ) elseif LocalPlayer():GetNWInt( "CSMultiCoreS", 0 ) then     multi_core:SetValue( 0 ) end multi_core.OnChange = function()     if multi_core:GetChecked(true) then         LocalPlayer():SetNWInt( "CSMultiCoreS", 1 )     else         LocalPlayer():SetNWInt( "CSMultiCoreS", 0 )     end end SERVER: hook.Add( "PlayerInitialSpawn", "SetValues", function( ply )     ply:SetNWInt( "CSMultiCoreS", 0 ) end) However even though the players NWInt is 0, the DCheckBox is still checked for some reason, why is this happening, how would I go about fixing it? Thank you!
Correct me if im wrong but, Maybe you are calling it way too early? I have never used NWInt so i may be competly wrong about this.
You're checking if the NWInt isn't nil or false, check 'if nwint == X then' or simply do 'multi_core:SetValue(LocalPlayer():GetNWInt("CSMultiCoreS"))' instead of the if statements. Also there are a couple other problems: you can't set NWInts clientside, you'd have to network the change to the server and set it there, and DCheckBox/GetChecked doesn't take any arguments, it returns a bool depending on the state of the checkbox, I think you're getting confused and and doing func(true) instead of func() == true.
Ah, awesome. Completely forgot about trying this, thank you!
Sorry, you need to Log In to post a reply to this thread.