• Trying to open a derma from a command
    2 replies, posted
I've made a script that call a function which send a net message to the client to open a derma when he connect, I've also made a command to open the same derma but when I use the command nothing happens and I don't really know why :/ So here is my server script: util.AddNetworkString( "OpenCharacterMenu" ) if file.Exists( "characters", "DATA" ) == false then     file.CreateDir( "characters" ) end hook.Add( "PlayerInitialSpawn", "Spawn", function( player )     local rank = player:GetUserGroup()     OpenCharacterMenu( player, rank )     --local steamid64 = player:SteamID64()     --WriteToFile(steamid64) end ) hook.Add( "OnPlayerChat", "OpenCharacterMenuCommand", function( ply, strText, bTeam, bDead )     if strText == "!character" then         local rank = ply:GetUserGroup()         OpenCharacterMenu( ply, rank )         return true     end end ) function WriteToFile( steamid64 )     file.Write( "characters/"..steamid64..".txt", steamid64.."," ) end function OpenCharacterMenu( player, rank )     net.Start( "OpenCharacterMenu" )     net.WriteString( rank )     net.Send( player ) end and here is my client script: net.Receive( "OpenCharacterMenu", function()     local rank = net.ReadString()     OpenCharacterMenuCl( rank ) end ) function OpenCharacterMenuCl( rank )     local Frame = vgui.Create( "DFrame" )     Frame:SetPos( 5, 5 )     Frame:SetSize( ScrW() * 0.624, ScrH() * 0.6 )     Frame:Center()     Frame:SetTitle( "Character Menu" )     Frame:SetVisible( true )     Frame:SetDraggable( false )     Frame:ShowCloseButton( false )     Frame:MakePopup()     local Button = vgui.Create( "DButton", Frame )     Button:SetText( "Choose" )     Button:SetTextColor( Color( 255, 255, 255 ) )     Button:SetPos( ( ScrW() * 0.624 ) / 2 - 50, (ScrH() * 0.6 ) - 40 )     Button:SetSize( 100, 30 )     Button.Paint = function( self, w, h )     draw.RoundedBox( 0, 0, 0, w, h, Color( 41, 128, 185, 250 ) ) -- Draw a blue button     end     Button.DoClick = function()         Frame:Close()     end end
OnPlayerChat is a client only hook. Use GM/PlayerSay.
Thanks mate.
Sorry, you need to Log In to post a reply to this thread.