• Print

Author Topic: TTT Read out Firstpreptime  (Read 5037 times)

0 Members and 1 Guest are viewing this topic.

Offline DH1806

  • Newbie
  • *
  • Posts: 38
  • Karma: 0
TTT Read out Firstpreptime
« on: August 13, 2015, 08:05:05 am »
Hi Guys,
im working atm on a script that changes the Number of traitors manually because I don't like the way to do it as percent (2 Traitor with 6 People are okay, 4 with 12 are too much and so on...) so I wanted to write a script to change the ttt_traitor_pct for every different number of Players.
The question is WHEN to start the change of ttt_traitor_pct. The hook TTTBeginRound can't be used because it's called when the traitors are already selected. So I had to work with TTTPrepareRound which is called when the preparing begins. But since the preparing and the begin of the round people could still join. So I worked with getting the convar ttt_preptime_seconds and used a timer.simple with x-0,01.
The problem is that there is a ttt_firstpreptime which is called on the round after the mapchange and it's different than the normal ttt_preptime_seconds. So the scipt has to know when it has to use ttt_firstpreptime and when ttt_preptime_seconds. Is there a way to check if there was a mapchange in the previous round or how many rounds left until the next mapchange?
Would be glad if someone could help me :)

DH

Offline DH1806

  • Newbie
  • *
  • Posts: 38
  • Karma: 0
Re: TTT Read out Firstpreptime
« Reply #1 on: August 17, 2015, 03:32:05 pm »
No ideas? :/

Offline roastchicken

  • Respected Community Member
  • Sr. Member
  • *****
  • Posts: 476
  • Karma: 84
  • I write code
Re: TTT Read out Firstpreptime
« Reply #2 on: August 26, 2015, 05:05:39 am »
Well, TTT has to know when to use ttt_preptime_seconds, doesn't it? I dug around in TTT's code (located in GarrysMod/garrysmod/gamemodes/terrortown OR https://github.com/garrynewman/garrysmod/tree/master/garrysmod/gamemodes/terrortown) and I found this nice snippet of code:

Code: Lua
  1. -- Schedule round start
  2. local ptime = GetConVar("ttt_preptime_seconds"):GetInt()
  3. if GAMEMODE.FirstRound then
  4.   ptime = GetConVar("ttt_firstpreptime"):GetInt()
  5.   GAMEMODE.FirstRound = false
  6. end

The GAMEMODE.FirstRound is set to true in the TTT initiation, and then set to false once it is used in the above code. I don't remember entirely how to reference TTT functions outside of TTT, so you might have to figure that out. But other than that basically just replace ptime with a variable of your choice (or use ptime) and you're good!
Give a man some code and you help him for a day; teach a man to code and you help him for a lifetime.

  • Print