[lua]
function Roleplay.HellPerson( )
local pl = LocalPlayer( )
local X = ScrW( ) / 2
local Y = ScrH( ) / 2
local Frame = vgui.Create( "DFrame" )
local ResponseA = { "I've seen things man.", "The end is near.", "I've been abducted." } -- Npc random chat
local ResponseB = { "Sure...", "What?", "Liar.", "Hoax.", "I bet.", "Hrghh?" } -- Players Random Choice of Response
Frame:SetPos( X * 0.70, Y * 0.80 )
Frame:SetSize( 370, 99 )
Frame:SetTitle( "Strange Hippie" )
Frame:SetBackgroundBlur( false )
Frame:ShowCloseButton( true )
Frame:SetDraggable( true )
Frame:SetVisible( true )
Frame:MakePopup( )
local Tab_Sheet = vgui.Create( "DPropertySheet", Frame )
Tab_Sheet:SetPos( 2, 30 )
Tab_Sheet:SetSize( Frame:GetWide( ) - 4, Frame:GetTall( ) - 35 )
local Chat_Panel = vgui.Create( "DPanelList", Tab_Sheet )
Chat_Panel:SetPos( 0, 0 )
Chat_Panel:SetSize( Tab_Sheet:GetWide( ), 64 )
Chat_Panel.Paint = function( )
draw.RoundedBox( 1, 0, 0, Chat_Panel:GetWide( ), Chat_Panel:GetTall( ), Color( 40, 40, 40, 255 ) )
draw.DrawText( math.random( 1, ResponseA ), "Default", 65, 0, Color( 255, 255, 255, 255 ), 0 )
end
local Icon = vgui.Create( "SpawnIcon", Chat_Panel )
Icon:SetPos( 0, 0 )
Icon:SetIconSize( 64 )
Icon:SetModel( Roleplay.HippieMdl )
local Button = vgui.Create( "DButton", Chat_Panel )
Button:SetPos( 65, 40 )
Button:SetSize( 60, 20 )
Button:SetText( math.random( 1, ResponseB ) )
Button.DoClick = function( )
Frame:SetVisible( false )
Frame = nil
end
end
[/lua]
Should I use math randoms for this? I know theres another way I just forgot the name. Also does the random look like it will work?
This is what you want to do :
[code]// This one runs faster.
Button:SetText( ResponseB[math.random( 1, #ResponseB )] )[/code]
or
[code]Button:SetText( table.Random(ResponseB ) )[/code]
Sorry, you need to Log In to post a reply to this thread.