• !rules help
    3 replies, posted
So i made this custom DFrame wich i will use for my rules, and asoon as we switched hosts, It didnt work. So i just want to know is there something wrong with the code? If it isnt then its ours aTags [QUOTE]hook.Add( "OnPlayerChat", "OpenRuleseGui", function( ply, text, team, isdead ) if (string.sub(text, 1, 6) == "!rules") && ply == LocalPlayer() then -- added an extra check local Frame = vgui.Create( "DFrame" ) Frame:SetPos(650,150) Frame:GetBackgroundBlur(true) Frame:ShowCloseButton(false) Frame:SetSize( 400,500 ) Frame:SetTitle( " " ) Frame:SetVisible( true ) Frame:SetDraggable( true ) Frame:MakePopup() Frame.Paint = function() surface.SetDrawColor( 50,50, 50, 200 ) surface.DrawRect( 0, 0, Frame:GetWide(), Frame:GetTall() ) end local texta = vgui.Create ( "DLabel", Frame ) texta:SetPos( 10,10 ) texta:SetSize(500,30) texta:SetText("1. Do not kill people in their main bases") texta:SetTextColor( Color( 255, 255, 255, 255 ) ) texta:SetFont("TreBuchet24") local textb = vgui.Create ( "DLabel", Frame ) textb:SetPos( 10,40 ) textb:SetSize(500,30) textb:SetText("2. Do not use offensive langauge") textb:SetTextColor( Color( 255, 255, 255, 255 ) ) textb:SetFont("TreBuchet24") local textc = vgui.Create ( "DLabel", Frame ) textc:SetPos( 10,70 ) textc:SetSize(500,30) textc:SetText("3. No sexual or racist comments") textc:SetTextColor( Color( 255, 255, 255, 255 ) ) textc:SetFont("TreBuchet24") local textd = vgui.Create ( "DLabel", Frame ) textd:SetPos( 10,100 ) textd:SetSize(500,30) textd:SetText("4. Play fair") textd:SetTextColor( Color( 255, 255, 255, 255 ) ) textd:SetFont("TreBuchet24") local texte = vgui.Create ( "DLabel", Frame ) texte:SetPos( 10,130 ) texte:SetSize(500,30) texte:SetText("5. Admin's word is final") texte:SetTextColor( Color( 255, 255, 255, 255 ) ) texte:SetFont("TreBuchet24") local textf = vgui.Create ( "DLabel", Frame ) textf:SetPos( 10,160 ) textf:SetSize(500,30) textf:SetText("6. No prop spawn/killing") textf:SetTextColor( Color( 255, 255, 255, 255 ) ) textf:SetFont("TreBuchet24") local textg = vgui.Create ( "DLabel", Frame ) textg:SetPos( 10,190 ) textg:SetSize(500,30) textg:SetText("7. No RDM") textg:SetTextColor( Color( 255, 255, 255, 255 ) ) textg:SetFont("TreBuchet24") local texth = vgui.Create ( "DLabel", Frame ) texth:SetPos( 10,220 ) texth:SetSize(500,30) texth:SetText("8. You must forget your past life if u die") texth:SetTextColor( Color( 255, 255, 255, 255 ) ) texth:SetFont("TreBuchet24") local texti = vgui.Create ( "DLabel", Frame ) texti:SetPos( 10,250 ) texti:SetSize(500,30) texti:SetText("9. If a assassin is blending in, u can no") texti:SetTextColor( Color( 255, 255, 255, 255 ) ) texti:SetFont("TreBuchet24") local textia = vgui.Create ( "DLabel", Frame ) textia:SetPos( 10,280 ) textia:SetSize(500,30) textia:SetText("longer see him") textia:SetTextColor( Color( 255, 255, 255, 255 ) ) textia:SetFont("TreBuchet24") local textj = vgui.Create ( "DLabel", Frame ) textj:SetPos( 3,310 ) textj:SetSize(500,30) textj:SetText("10. Only KOS Assassins if they break the law") textj:SetTextColor( Color( 255, 255, 255, 255 ) ) textj:SetFont("TreBuchet24") local closeb = vgui.Create ( "DButton", Frame ) closeb:SetPos( 60,370 ) closeb:SetSize ( 300,100 ) closeb:SetText ("Close") closeb:SetTextColor( Color( 255, 255, 255, 255 ) ) closeb:SetVisible(false) closeb.DoClick = function() Frame:Remove() end closeb.Paint = function() surface.SetDrawColor( 255, 0, 0, 255 ) surface.DrawRect( 0, 0, closeb:GetWide(), closeb:GetTall() ) end local check = vgui.Create ( "DCheckBox", Frame ) check:SetPos( 290,400 ) check:SetSize( 70,70 ) check:OnChange() local kick = vgui.Create ( "DButton", Frame ) kick:SetPos( 10, 360 ) kick:SetTextColor( Color( 255, 255, 255, 255 ) ) kick.Paint = function() surface.SetDrawColor( 255, 0, 0, 255 ) surface.DrawRect( 0, 0, kick:GetWide(), kick:GetTall() ) end kick:SetSize(190,90) kick:SetText( "I do not agree to these rules" ) kick.DoClick = function() Frame:Remove() ply:ConCommand("say /a I have not agreed to the rules, I will now be kicked.") timer.Simple( 2, function() ply:ConCommand("disconnect") end ) end local checktext = vgui.Create( "DLabel", Frame ) checktext:SetPos( 185,450 ) checktext:SetSize ( 250,50 ) checktext:SetText ( "By ticking this box u will agree to these rules" ) local checktexta = vgui.Create( "DLabel", Frame ) checktexta:SetPos( 185,462 ) checktexta:SetSize ( 250,50 ) checktexta:SetText ( "And accept any punishment if u break them" ) function check:OnChange( bVal ) if ( bVal ) then check:OnChange() else closeb:SetVisible(true) check:Remove() checktext:Remove() checktexta:Remove() kick:Remove() end end return true -- surpress the message end end )[/QUOTE]
You should really use [Code] tags. Also, please use tabbing in your codes. It will make errors much easier to spot and everything much nicer to read. Now as for the code itself - It works, tested it on a server. Are you sure you are running it on the client and not on the server?
[QUOTE=JasonMan34;50993519]You should really use [Code] tags. Also, please use tabbing in your codes. It will make errors much easier to spot and everything much nicer to read. Now as for the code itself - It works, tested it on a server. Are you sure you are running it on the client and not on the server?[/QUOTE] works again, it was aTags
And you should use tables: [code] local rules = { "Don't RDM", 'Genius rule #2', 'etc...' } local y = 15 for _, v in pairs( rules ) do local text = vgui.Create ( "DLabel", Frame ) text:SetPos( 10,10 ) text:SetSize(500,30) text:SetText( v ) text:SetTextColor( Color( 255, 255, 255, 255 ) ) text:SetFont("TreBuchet24") y = y + 35 end [/code]
Sorry, you need to Log In to post a reply to this thread.