function Team_Swap()
local Backg = vgui.Create( "DFrame" )
Backg:SetSize( ScrW() / 2, ScrH() / 2 )
Backg:SetPos ( ScrW() / 2, ScrH() / 2 )
Backg:SetTitle( "Swap Teams" )
Backg:SetVisible ( true )
Backg:SetDraggable ( true )
Backg:ShowCloseButton ( true )
Backg:MakePopup()
local DColorButton = vgui.Create ( "DColorButton", Backg )
DColorButton:SetPos( 40, 40 )
DColorButton:Paint( 100, 40 )
DColorButton:SetSize( 100, 40 )
DColorButton:SetText( "Join Red Team", Color( 221,78,76 ) )
DColorButton:SetColor( Color( 221,78,76 )
function DColorButton:DoClick(player)
player:Kill()
player:SetTeam(1)
player:Spawn()
end
end
concommand.Add( "set_team", Team_Swap )
此代码运行良好...直到您完成其唯一目的单击按钮单击按钮时,将在控制台中返回以下文本
新回收]set_team
[错误] gamemodes/capturetheflag/gamemode/cl_init.lua:32:尝试索引本地“玩家”(零值) 1. DoClick - gamemodes/capturetheflag/gamemode/cl_init.lua:32 2. 未知 - lua/vgui/ dlabel.lua:218
[n3wr3cycl3|20|STEAM_0:1:59994487] Lua 错误:
[错误] gamemodes/capturetheflag/gamemode/cl_init.lua:32:尝试索引本地“玩家”(零值) 1. DoClick - gamemodes/capturetheflag/gamemode/cl_init.lua:32 2. 未知 - lua/vgui/ dlabel.lua:218
请帮忙!