• Print

Author Topic: need help x2 asap  (Read 8678 times)

0 Members and 1 Guest are viewing this topic.

Offline lampman13

  • Jr. Member
  • **
  • Posts: 71
  • Karma: -10
need help x2 asap
« on: February 22, 2014, 11:56:55 am »
ok so i have to codes and a few issues ok so first thing first i have made a broadcast thing that allows admins to broadcast a message to the server and the problems i have with this code is
  • it is not admin pacific
  • it does not broadcast the message and has major lua errors

that code is
Code: Lua
  1. function Menu( ply )
  2.        
  3.         local ply = LocalPlayer()
  4.        
  5.         local BackGround = vgui.Create( "DFrame" )
  6.         BackGround:SetSize( 200,70 )
  7.         BackGround:SetPos( (ScrW()/2)-BackGround:GetWide(),(ScrH()/2)-BackGround:GetTall() )
  8.         BackGround:SetTitle( "Menu" )
  9.         BackGround:SetVisible( true )
  10.         BackGround:SetDraggable( true )
  11.         BackGround:ShowCloseButton( true )
  12.         BackGround:MakePopup()
  13.         BackGround.Paint = function()
  14.                 draw.RoundedBox(4, 0, 0, BackGround:GetWide(), BackGround:GetTall(), Color(0, 225, 225, 255))
  15.                 draw.RoundedBox(2, 2, 2, BackGround:GetWide()-4, 21, Color(255, 0, 0, 255))
  16.         end
  17.        
  18.         local TextEntry = vgui.Create( "DTextEntry", BackGround )
  19.         TextEntry:SetPos( 20,30 )
  20.         TextEntry:SetTall( 20 )
  21.         TextEntry:SetWide( 160 )
  22.         TextEntry:SetEnterAllowed( true )
  23.         TextEntry.OnEnter = function()
  24.                 PrintMessage( HUD_PRINTCENTER ..TextEntry:GetText() )
  25.                 BackGround:SetVisible()
  26.         end
  27. end
  28. concommand.Add("open_menu",Menu)
  29.  
then i have a darkrp thing that is supposed to allow admins to go undercover and it changes there name and there user group display or in other words it is supposed to show them as a user and there are 2 files i dont know if thats a problem but my friend made it and wants it fixed i need help :P the first code is in a file called cl_init.lua and the code is
Code: Lua
  1. include("init.lua")
  2. concommand.Add( "disguise", function()
  3.         Derma_StringRequest( "Disguise menu!", "What would you like your undercover name to be? ( Type self to exit disguise mode )", "",
  4.                 function( text ) RunConsoleCommand( "rp_disguise", text ); end );
  5. end )
the second code is in a file called init.lua the code for that is
Code: Lua
  1. include("cl_init.lua")
  2. local meta = FindMetaTable( "Player" );
  3. local function NotifyPlayers( msg )
  4.         if ( !msg ) then return; end
  5.        
  6.         for _, Player in pairs ( player.GetAll() ) do
  7.                 Player:ChatPrint( msg );
  8.         end
  9. end
  10.  
  11. local function HasValue( thingToCheck )
  12.         if ( thingToCheck == "" ) then
  13.                 return ( false );
  14.         else
  15.                 return ( true );
  16.         end
  17. end
  18.  
  19. function meta:ResetDisguise()
  20.         local nameToUse;
  21.        
  22.         if ( HasValue( self:GetNetworkedString( "DisguiseName" ) ) ) then
  23.                 nameToUse = ( self:GetNetworkedString( "DisguiseName" ) );
  24.         else
  25.                 nameToUse = ( self:GetName() );
  26.         end
  27.        
  28.         self:SetNetworkedBool( "IsDisguised", false );
  29.         self:SetNetworkedString( "DisguiseName", "" );
  30.         NotifyPlayers( nameToUse .. " has left the game." );
  31.         timer.Simple( math.random( 1, 7 ), function()
  32.                 self:setDarkRPVar( "rpname", self.StartName );
  33.                 NotifyPlayers( self:Nick() .. " has joined the game." );
  34.         end )
  35. end
  36.  
  37. function hasAccess(ply)
  38. if (ply:GetUserGroup() == "trialmod") then return true end
  39. if (ply:GetUserGroup() == "admin") then return true end
  40. if (ply:GetUserGroup() == "superadmin") then return true end
  41. if (ply:GetUserGroup() == "Mod") then return true end
  42. if (ply:GetUserGroup() == "Owner") then return true end
  43. return false
  44. end
  45.  
  46. local function DisguisePlayer( Player, _, args )
  47.        
  48.         local nameToUse;
  49.        
  50.         if ( !args[1] || !tostring( args[1] ) ) then
  51.                 return;
  52.         end
  53.        
  54.         if ( !hasAccess(Player) ) then
  55.                 return;
  56.         end
  57.        
  58.         if ( !Player || !Player:IsValid() ) then
  59.                 return;
  60.         end
  61.        
  62.         if ( string.lower( args[1] ) == "self" ) then
  63.                 Player:ResetDisguise();
  64.         else
  65.                 if ( HasValue( Player:GetNetworkedString( "DisguiseName" ) ) ) then
  66.                         nameToUse = ( Player:GetNetworkedString( "DisguiseName" ) );
  67.                 else
  68.                         nameToUse = ( Player:GetName() );
  69.                 end
  70.                 Player:SetNetworkedBool( "IsDisguised", true );
  71.                 Player:SetNetworkedString( "DisguiseName", args[1] );
  72.                 NotifyPlayers( nameToUse .. " has left the game." );
  73.                 timer.Simple( math.random( 2, 6 ), function()
  74.                         NotifyPlayers( args[1] .. " has joined the game." );
  75.                         Player:setDarkRPVar( "rpname", args[1] );
  76.                 end )
  77.         end
  78.        
  79. end
  80. concommand.Add( "rp_disguise", DisguisePlayer );
  81.  
  82. hook.Add( "PlayerInitialSpawn", "SavePlayerName", function( Player )
  83.         Player.StartName = ( Player:GetName() );
  84. end )
« Last Edit: February 22, 2014, 12:18:20 pm by lampman13 »

Offline Neku

  • Hero Member
  • *****
  • Posts: 549
  • Karma: 27
Re: need help x2 asap
« Reply #1 on: February 22, 2014, 12:13:28 pm »
I have a feeling your friend is using the wrong syntax.
Out of the Garry's Mod business.

Offline lampman13

  • Jr. Member
  • **
  • Posts: 71
  • Karma: -10
Re: need help x2 asap
« Reply #2 on: February 22, 2014, 12:17:21 pm »
thanks for a quick reply but what is wrong with it :/

Offline Megiddo

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 6214
  • Karma: 394
  • Project Lead
Re: need help x2 asap
« Reply #3 on: February 22, 2014, 12:25:35 pm »
What is the error?
Experiencing God's grace one day at a time.

Offline lampman13

  • Jr. Member
  • **
  • Posts: 71
  • Karma: -10
Re: need help x2 asap
« Reply #4 on: February 22, 2014, 12:50:02 pm »
the first ones error is
[ERROR] lua/autorun/client/menu.lua:24: unexpected symbol near '..'
  1. unknown - lua/autorun/client/menu.lua:0
 the second one doesnt do anything it acts as if it isnt there and this is saying that line 24 HUD_PRINTCENTER is not what i am supposed to use

Offline lampman13

  • Jr. Member
  • **
  • Posts: 71
  • Karma: -10
Re: need help x2 asap
« Reply #5 on: February 22, 2014, 01:32:46 pm »
does anyone know how to make a box pop up on the middle topish of the screen?

Offline LuaTenshi

  • Hero Member
  • *****
  • Posts: 545
  • Karma: 47
  • Just your ordinary moon angel!
    • Mirai.Red
Re: need help x2 asap
« Reply #6 on: February 23, 2014, 09:20:30 pm »
Found your problem its on line 24 of this code.

Code: Lua
  1. function Menu( ply )
  2.        
  3.         local ply = LocalPlayer()
  4.        
  5.         local BackGround = vgui.Create( "DFrame" )
  6.         BackGround:SetSize( 200,70 )
  7.         BackGround:SetPos( (ScrW()/2)-BackGround:GetWide(),(ScrH()/2)-BackGround:GetTall() )
  8.         BackGround:SetTitle( "Menu" )
  9.         BackGround:SetVisible( true )
  10.         BackGround:SetDraggable( true )
  11.         BackGround:ShowCloseButton( true )
  12.         BackGround:MakePopup()
  13.         BackGround.Paint = function()
  14.                 draw.RoundedBox(4, 0, 0, BackGround:GetWide(), BackGround:GetTall(), Color(0, 225, 225, 255))
  15.                 draw.RoundedBox(2, 2, 2, BackGround:GetWide()-4, 21, Color(255, 0, 0, 255))
  16.         end
  17.        
  18.         local TextEntry = vgui.Create( "DTextEntry", BackGround )
  19.         TextEntry:SetPos( 20,30 )
  20.         TextEntry:SetTall( 20 )
  21.         TextEntry:SetWide( 160 )
  22.         TextEntry:SetEnterAllowed( true )
  23.         TextEntry.OnEnter = function()
  24.                 PrintMessage( HUD_PRINTCENTER ..TextEntry:GetText() )
  25.                 BackGround:SetVisible()
  26.         end
  27. end
  28. concommand.Add("open_menu",Menu)
  29.  

Change PrintMessage( HUD_PRINTCENTER ..TextEntry:GetText() ) to PrintMessage( HUD_PRINTCENTER, TextEntry:GetText() )



Will try to find any other code errors shortly, but change that and see if there are any new errors. (And post them here.)
I cry every time I see that I am not a respected member of this community.

Offline lampman13

  • Jr. Member
  • **
  • Posts: 71
  • Karma: -10
Re: need help x2 asap
« Reply #7 on: February 24, 2014, 12:21:33 pm »
doesnt work i tried it that way first but i did change it to draw text here is the code now it still doesnt print the message i dont get errors now but it dosnt work and is still not ply:IsAdmin as i do not know where to put it.
Code: Lua
  1. function UCast( ply )
  2.        
  3.         local ply = LocalPlayer()
  4.        
  5.         local BackGround = vgui.Create( "DFrame" )
  6.         BackGround:SetSize( 200,70 )
  7.         BackGround:SetPos( (ScrW()/2)-BackGround:GetWide(),(ScrH()/2)-BackGround:GetTall() )
  8.         BackGround:SetTitle( "UCast" )
  9.         BackGround:SetVisible( true )
  10.         BackGround:SetDraggable( true )
  11.         BackGround:ShowCloseButton( true )
  12.         BackGround:MakePopup()
  13.         BackGround.Paint = function()
  14.                 draw.RoundedBox(4, 0, 0, BackGround:GetWide(), BackGround:GetTall(), Color(0, 225, 225, 255))
  15.                 draw.RoundedBox(2, 2, 2, BackGround:GetWide()-4, 21, Color(255, 150, 0, 255))
  16.         end
  17.        
  18.         local TextEntry = vgui.Create( "DTextEntry", BackGround )
  19.         TextEntry:SetPos( 20,30 )
  20.         TextEntry:SetTall( 20 )
  21.         TextEntry:SetWide( 160 )
  22.         TextEntry:SetEnterAllowed( true )
  23.         TextEntry.OnEnter = function()
  24.                 draw.DrawText(..TextEntry:GetText(), "HUDNumber5", ScrW()/2, ScrH()/2, Color(255, 255, 255, 255), TEXT_ALIGN_CENTER)
  25.                 BackGround:SetVisible()
  26.         end
  27. end
  28. concommand.Add("ucast_menu",UCast)
  29.  
« Last Edit: February 24, 2014, 12:23:30 pm by lampman13 »

Offline lampman13

  • Jr. Member
  • **
  • Posts: 71
  • Karma: -10
Re: need help x2 asap
« Reply #8 on: February 24, 2014, 03:43:58 pm »
also sorry for my being a noob how do i make it an addon lol i dont know do i make a new folder call it... UCast and put it in the gmod addons blah blah then make a folder in that called lua then in that call it autorun then in that client? then put my ucast thinger in that? or do i need to make a client folder in that?

Offline lampman13

  • Jr. Member
  • **
  • Posts: 71
  • Karma: -10
Re: need help x2 asap
« Reply #9 on: February 24, 2014, 04:11:49 pm »
ok great i figured it out i have one problem its the get text thing the , is breaking it if i remove it it does nothing :/ but it does display a text now just you have to specify it and i need it to write what is said by the admins
Code: Lua
  1. function UCast( ply )
  2.        
  3.         local ply = LocalPlayer()
  4.        
  5.         local BackGround = vgui.Create( "DFrame" )
  6.         BackGround:SetSize( 200,70 )
  7.         BackGround:SetPos( (ScrW()/2)-BackGround:GetWide(),(ScrH()/2)-BackGround:GetTall() )
  8.         BackGround:SetTitle( "UCast" )
  9.         BackGround:SetVisible( true )
  10.         BackGround:SetDraggable( true )
  11.         BackGround:ShowCloseButton( true )
  12.         BackGround:MakePopup()
  13.         BackGround.Paint = function()
  14.                 draw.RoundedBox(4, 0, 0, BackGround:GetWide(), BackGround:GetTall(), Color(0, 225, 225, 255))
  15.                 draw.RoundedBox(2, 2, 2, BackGround:GetWide()-4, 21, Color(255, 150, 0, 255))
  16.         end
  17.        
  18.         local TextEntry = vgui.Create( "DTextEntry", BackGround )
  19.         TextEntry:SetPos( 20,30 )
  20.         TextEntry:SetTall( 20 )
  21.         TextEntry:SetWide( 160 )
  22.         TextEntry:SetEnterAllowed( true )
  23.         TextEntry.OnEnter = function()
  24.                 chat.AddText( Color( 0, 255, 0 ), "(ADMIN)", Color( 0, 255, 0 ), ..TextEntry:GetText )
  25.                 chat.PlaySound()
  26.                 BackGround:SetVisible()
  27.         end
  28. end
  29. concommand.Add("ucast_menu",UCast)
  30.  

Offline lampman13

  • Jr. Member
  • **
  • Posts: 71
  • Karma: -10
Re: need help x2 asap
« Reply #10 on: February 24, 2014, 06:41:49 pm »
ok i finnaly got it i got it exactly how i wanted it i just had to play around a little i just need to make it ulx can anyone help me?
code==
Code: Lua
  1. function UCast( ply )
  2.        
  3.         local ply = LocalPlayer()
  4.        
  5.         local BackGround = vgui.Create( "DFrame" )
  6.         BackGround:SetSize( 200,70 )
  7.         BackGround:SetPos( (ScrW()/2)-BackGround:GetWide(),(ScrH()/2)-BackGround:GetTall() )
  8.         BackGround:SetTitle( "UCast" )
  9.         BackGround:SetVisible( true )
  10.         BackGround:SetDraggable( true )
  11.         BackGround:ShowCloseButton( true )
  12.         BackGround:MakePopup()
  13.         BackGround.Paint = function()
  14.                 draw.RoundedBox(4, 0, 0, BackGround:GetWide(), BackGround:GetTall(), Color(0, 225, 225, 255))
  15.                 draw.RoundedBox(2, 2, 2, BackGround:GetWide()-4, 21, Color(255, 150, 0, 255))
  16.         end
  17.        
  18.         local TextEntry = vgui.Create( "DTextEntry", BackGround )
  19.         TextEntry:SetPos( 20,30 )
  20.         TextEntry:SetTall( 20 )
  21.         TextEntry:SetWide( 160 )
  22.         TextEntry:SetEnterAllowed( true )
  23.         TextEntry.OnEnter = function()
  24.                 chat.AddText(Color( 0, 255, 0 ), "(ADMIN)", Color( 0, 255, 0 ), TextEntry:GetText())
  25.                 chat.PlaySound()
  26.                 BackGround:SetVisible()
  27.         end
  28. end
  29. concommand.Add("ucast_menu",UCast)

Offline lampman13

  • Jr. Member
  • **
  • Posts: 71
  • Karma: -10
Re: need help x2 asap
« Reply #11 on: February 25, 2014, 01:21:11 pm »
anyone know why it only works client?

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: need help x2 asap
« Reply #12 on: February 25, 2014, 07:01:31 pm »
Lampman, sometimes your noob-ish-ness really makes me want to poke out my eyes so as to not see silly questions like you just asked.

You can't run GUI on a server.
Derma/GUI = client only.


"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline lampman13

  • Jr. Member
  • **
  • Posts: 71
  • Karma: -10
Re: need help x2 asap
« Reply #13 on: February 25, 2014, 07:10:04 pm »
yeah i know im still knew remember that lol i need to learn somehow and if you telling me that makes me rememeber then great lol but i already realised it (and was told) today about 6 sp yeah lol i am a noob but itll go away :P im gonna try to use Ulib.tsay but im learning how to use it so :P we'll see how it goes

Offline Neku

  • Hero Member
  • *****
  • Posts: 549
  • Karma: 27
Re: need help x2 asap
« Reply #14 on: February 25, 2014, 07:13:15 pm »
Um, could you do me a favor and please, please use punctuation.
It's very difficult to read through your posts sometimes.
Sorry for asking if this offends you, but it would let me, and most likely others help you better.
Out of the Garry's Mod business.

  • Print