Code:
flag_button_common = func_button:new({ team = Team.kUnassigned, flagname = "default_flag_name" })
function flag_button_common:allowed( allowed_entity )
if IsPlayer( allowed_entity ) then
local player = CastToPlayer( allowed_entity )
-- if player is on the correct team
if player:GetTeamId() == self.team then
-- if flag is at its spawn point
if _G[self.flagname].status == 0 then
return EVENT_ALLOWED
end
end
end
return EVENT_DISALLOWED
end
-- if not allowed
function flag_button_common:onfailuse( use_entity )
if IsPlayer( use_entity ) then
local player = CastToPlayer( use_entity )
BroadCastMessageToPlayer( player, "#FF_NOTALLOWEDBUTTON" )
end
end
red_flag_button = flag_button_common:new({ team = Team.kRed, flagname = "flag_name" })
blue_flag_button = flag_button_common:new({ team = Team.kBlue, flagname = "flag_name" })
Hopefully that works for you.