• How do you lock player when pre-timer starts and Unlock when the pre-timer ends in 0
    1 replies, posted
I want to make my pre round timer lock the player when it starts and unlock player when it ends. I know about ply:Lock() and ply:UnLock() but I get an error saying that ply is nil, and I've done local ply = LocalPlayer() This is my round code located in my shared.lua: [CODE] function UpdateTimer( time ) net.Start("round_timer") net.WriteInt( time, 10 ) net.Broadcast() end function RoundStart() -- Pre-round local time = 50 -- I want player lock to start here UpdateTimer( time ) timer.Create( "round", 1, time, function() time = time - 1 local Alive = 0 for k, v in pairs( player.GetAll() ) do if( v:Alive() ) then Alive = Alive + 1 end end if( Alive >= table.Count( player.GetAll() ) && table.Count( player.GetAll() ) > 1 && time <= 0 ) then roundActive = true net.Start("round_active") net.WriteBool( true ) net.Broadcast() elseif( table.Count( player.GetAll()) < 2 ) then UpdateTimer( 50 ) return end if( time <= 0 ) then -- I want player unlock to start here and player lock to end here. print( "Round started: " .. tostring(roundActive) ) RoundEndCheck() end UpdateTimer( time ) end) end function RoundEndCheck() print( "Round active: " .. tostring(roundActive) ) RunConsoleCommand("UnLock23951925u765323234261") time = 401 if( roundActive == false )then return end timer.Create( "checkdelay", 1, time, function() time = time - 1 UpdateTimer( time ) if( time <= 0 ) then EndRound( "No one" ) end local combineAlive = 0 local resistanceAlive = 0 for k, v in pairs( team.GetPlayers( 1 ) ) do if( v:Alive() ) then combineAlive = combineAlive + 1 end end for k, v in pairs( team.GetPlayers( 2 ) ) do if( v:Alive() ) then resistanceAlive = resistanceAlive + 1 end end print( "Combine Alive: " .. tostring(combineAlive) .. " | Resistance Alive: " .. tostring(resistanceAlive) ) if( combineAlive == 0 ) then EndRound( "Resistance" ) elseif( resistanceAlive == 0 ) then EndRound( "Combine" ) end end) end function EndRound( winners ) print( winners .. " won the round!" ) timer.Remove( "checkdelay" ) timer.Create("cleanup", 3, 1, function() game.CleanUpMap( false, {} ) for _, v in pairs( player.GetAll() ) do if( v:Alive() ) then v:SetupHands() v:StripWeapons() v:KillSilent() end v:SetGamemodeTeam( v:Team() ) end net.Start("round_active") net.WriteBool( false ) net.Broadcast() roundActive = false end) end[/CODE]
LocalPlayer() does not exist serverside.
Sorry, you need to Log In to post a reply to this thread.