Change to another team limited by time

I have the following code on my gamemode, in init.lua

/*---------------------------------------------------------
   Text when you chose another team
---------------------------------------------------------*/

function GM:KeyPress(p, key) 
    if ( key == IN_SPEED ) then 
        if ( p:Team( )== TEAM_BLUE ) then
        p:SetTeam( TEAM_RED )
        p:Kill( )
        p:PrintMessage(HUD_PRINTTALK,"you don't want to be in the team red? Press 'SHIFT' to be one again!"); -- eg: Aliens (blue)
        p:SprintEnable ()
        p:AddFrags(1)
        else
        p:SetTeam( TEAM_BLUE )
        p:Kill( )
        p:PrintMessage(HUD_PRINTTALK,"you don't want to be in the team blue? Press 'SHIFT' to be one again!"); -- eg: Predator(red)
        p:SprintDisable ()
        p:AddFrags(1)
        end
    end
    self.BaseClass:KeyPress(p, key)
end

So when somebody press the key SHIFT in the game, he changed to another team. Is there any way to limited the time you can press this key to one minute for example?

[lua]/---------------------------------------------------------
Text when you chose another team
---------------------------------------------------------
/

function GM:KeyPress(p, key)
if ( key == IN_SPEED and ( not p.LastSwap or CurTime() - p.LastSwap > 60 ) ) then
p.LastSwap = CurTime()
if ( p:Team( )== TEAM_BLUE ) then
p:SetTeam( TEAM_RED )
p:Kill( )
p:PrintMessage(HUD_PRINTTALK,“you don’t want to be in the team red? Press ‘SHIFT’ to be one again!”); – eg: Aliens (blue)
p:SprintEnable ()
p:AddFrags(1)
else
p:SetTeam( TEAM_BLUE )
p:Kill( )
p:PrintMessage(HUD_PRINTTALK,“you don’t want to be in the team blue? Press ‘SHIFT’ to be one again!”); – eg: Predator(red)
p:SprintDisable ()
p:AddFrags(1)
end
end
self.BaseClass:KeyPress(p, key)
end[/lua]

Is fully working, thanks :slight_smile:

Edit: any way to change SHIFT for F1 por example? xD