I am trying to create a button that when ANY engineer hits it a certain number of times it creates a few outputs. Only needs to activate once. I borrowed ff_security_b1 code and tried to change it and also tried to just create what I needed.... I didnt receive lua errors but the func_button I named engy_spanner_button didnt fire... I didn't receive any console lua errors either. Please help this noob, maps almost done.
heres the code:
----------------------------
--first attempt modified slightly from ff_security_b1
----------------------------
NUM_HITS_TO_REPAIR = 10
FORT_POINTS_PER_REPAIR = 100
function gen_onrepair( team )
-- outputs, add any thing you want to happen when the generator is repaired here
-- teamstring is either "red" or "blue"
OutputEvent( "beam2", "TurnOn" )
OutputEvent( "tele_2_trigger", "Enable" )
BroadCastMessage("Beam 2 has been activated")
end
function gen_onclank( player )
-- add any thing you want to happen when the generator is hit by a wrench (while its detted) here
BroadCastMessage("whats going on here?")
end
generators = {
[Team.kUnassigned] = {
status=0,
repair_status=0
}
}
base_gen = func_button:new({ team = Team.kUnassigned })
function base_gen
ndamage()
if IsPlayer( GetPlayerByID(info_attacker) ) then
local player = CastToPlayer( GetPlayerByID(info_attacker) )
if info_classname == "ff_weapon_spanner" then
generators[self.team].repair_status = generators[self.team].repair_status + 1
if generators[self.team].repair_status >= NUM_HITS_TO_REPAIR then
player:AddFortPoints( FORT_POINTS_PER_REPAIR, "Repairing the Crane" )
gen_onrepair( self.team )
generators[self.team].status = 0
else
gen_onclank( player )
end
end
end
end
----------------------------------------------------------
-- my attempt to create a engy spanner button
-----------------------------------------------------------
base_gen = func_button:new({ team = Team.kUnassigned })
function base_gen
ndamage()
if IsPlayer( GetPlayerByID(info_attacker) ) then
local player = CastToPlayer( GetPlayerByID(info_attacker) )
if info_classname == "ff_weapon_spanner" then
generators.repair_status = generators.repair_status + 1
if generators.repair_status >= NUM_HITS_TO_REPAIR then
player:AddFortPoints( FORT_POINTS_PER_REPAIR, "Repairing the Crane" )
OutputEvent( "beam2", "TurnOn" )
OutputEvent( "tele_2_trigger", "Enable" )
BroadCastMessage("Beam 2 has been activated")
else
gen_onclank( player )
end
end
end
end
engy_spanner_button = base_gen:new({ team = Team.kUnassigned })