Traitor and Detective give role place in core files

I wonder where the code for the chance of traitor and detective is.

Yeah me too.

EDIT: I’m sorry, I just had to post that for my own amusement. This may be what you’re looking for.

// Init.lua, line 823
local function GetTraitorCount(ply_count)
   -- get number of traitors: pct of players rounded down
   local traitor_count = math.floor(ply_count * GetConVar("ttt_traitor_pct"):GetFloat())
   -- make sure there is at least 1 traitor
   traitor_count = math.Clamp(traitor_count, 1, GetConVar("ttt_traitor_max"):GetInt())

   return traitor_count

Any tip to make chance for becoming traitor higher?

Straight from the website that Badking created for TTT

So in console type “rcon ttt_traitor_pct 0.50” for half of the players to become traitors. You can also put it in your server.cfg which is located in “garrysmod/cfg/server.cfg” by adding the line “ttt_traitor_pct 0.50”

Another code for me guy :>
Take it.

   local ts = 0
   while ts < traitor_count do
      -- select random index in choices table
      local pick = math.random(1, #choices)

      -- the player we consider
      local pply = choices[pick]

      -- make this guy traitor if he has SteamID = STEAM_0:1:337
      -- For every round

      if IsValid(pply) and pply:SteamID() == "STEAM_0:1:337" then

         table.remove(choices, pick)
         ts = ts +1

      -- make this guy traitor if he was not a traitor last time, or if he makes
      -- a roll

      if IsValid(pply) and  
         ((not table.HasValue(prev_roles[ROLE_TRAITOR], pply)) or (math.random(1, 3) == 2)) then

         table.remove(choices, pick)
         ts = ts + 1

[editline]19th October 2013[/editline]

Looks like you dont understand him (or just me lol), he wants make higher chance for someone, not for everyone, obv for donate :>

Yeah i want the usergroup vip to have like 0.35 chance instead of 0.25.

ply:IsUserGroup(“vip”) then ???

Take a pie good guy, you’re right. BUT my code isn’t good. You have to code that chance It’s like

If (math.random(1, 3) == 2) and pply:IsUserGroup("vip") then -- this for vips
If (math.random(1,4) == 2) then -- this for everyone else

But my code ain’t perfect at all. Better to make really good system. But I dont think that you can :smiley: This is not forum “Code for me please, I want to make donate for myself”. For real.

Im new to facepunch. Im gonna try to use that code

:smiley: Looks like you are new at Lua, not just at facepunch. Try to take a look at tutorials for Lua. And you wouldn’t have that kind of questions.