• My lua script question
    4 replies, posted
Im trying to make it so that the leader of each team gets to pick their team name. I have this so far, but im not sure how to make it so when they enter the text, the vaiable "team1" is changed to the value of teh entered text. This is what I have so far team1 = "Default Nation 1" team2 = "Default Nation 2" leader1 = "Default Leader 1" leader2 = "Default Leader 2" function nation1name() local DermaPanel = vgui.Create( "DFrame" ) DermaPanel:SetPos( 250,250 ) DermaPanel:SetSize( 500, 50 ) DermaPanel:SetTitle( "Please enter a name for your nation" ) DermaPanel:ShowCloseButton( true ) DermaPanel:SetVisible( true ) DermaPanel:MakePopup() local DermaText = vgui.Create( "DTextEntry", DermaPanel ) DermaText:SetPos( 20,25 ) DermaText:SetTall( 20 ) DermaText:SetWide( 450 ) DermaText:SetEnterAllowed( true ) DermaText.OnEnter = function() DermaPanel:SetVisible( false ) end end [highlight](User was banned for this post ("Wrong section" - mahalis))[/highlight]
Add to autorun/teams.lua. [lua]if SERVER then AddCSLuaFile("teams.lua") team1 = team1 or "Default Nation 1" team2 = team2 or "Default Nation 2" leader1 = leader1 or "Default Leader 1" leader2 = leader2 or "Default Leader 2" concommand.Add("team1", function(ply,cmd,args) if args[1] and ply:IsAdmin() then team.SetUp (1, args[1] or "Default Nation 1", Color(0, 0, 255, 255)) // team1 end end) else function nation1name() local DermaPanel = vgui.Create( "DFrame" ) DermaPanel:SetPos( 250,250 ) DermaPanel:SetSize( 500, 50 ) DermaPanel:SetTitle( "Please enter a name for your nation" ) DermaPanel:ShowCloseButton( true ) DermaPanel:SetVisible( true ) DermaPanel:MakePopup() local DermaText = vgui.Create( "DTextEntry", DermaPanel ) DermaText:SetPos( 20,25 ) DermaText:SetTall( 20 ) DermaText:SetWide( 450 ) DermaText:SetEnterAllowed( true ) DermaText.OnEnter = function() team1 = LocalPlayer():ConCommand("team1 "..DermaText:GetValue()) DermaPanel:SetVisible( true ) end end concommand.Add("editteamname", nation1name) end[/lua]
can you explain it please :)
[QUOTE=FunkyDiabeetus;25294188]can you explain it please :)[/QUOTE] How did you code the lua, if you don't understand it?
Sorry, you need to Log In to post a reply to this thread.