• Print

Author Topic: Extra credit for certain rank  (Read 7125 times)

0 Members and 1 Guest are viewing this topic.

Offline ojbristow

  • Newbie
  • *
  • Posts: 47
  • Karma: 0
    • Superclocked
Extra credit for certain rank
« on: January 03, 2014, 01:11:17 pm »
Hi all,

I have a question and really hope someone can help :)

When someone in a certain rank (supporter) is it possible for them to have an extra traitor or detective credit when it is their turn?

Thanks,

Owen


Offline Neku

  • Hero Member
  • *****
  • Posts: 549
  • Karma: 27
Re: Extra credit for certain rank
« Reply #1 on: January 03, 2014, 03:16:21 pm »
You should be able to do so by making if and elseif statements within TTT's code.

Go digging within the gamemode for a while, you'll find it.
Out of the Garry's Mod business.

Offline Cobalt

  • Full Member
  • ***
  • Posts: 216
  • Karma: 44
  • http://steamcommunity.com/id/__yvl/
Re: Extra credit for certain rank
« Reply #2 on: January 03, 2014, 03:21:43 pm »
--snip--
« Last Edit: January 03, 2014, 03:58:26 pm by Cobalt77 »

Offline ojbristow

  • Newbie
  • *
  • Posts: 47
  • Karma: 0
    • Superclocked
Re: Extra credit for certain rank
« Reply #3 on: January 03, 2014, 03:22:51 pm »
Thanks so much :)

Owen


Offline Neku

  • Hero Member
  • *****
  • Posts: 549
  • Karma: 27
Re: Extra credit for certain rank
« Reply #4 on: January 03, 2014, 03:24:18 pm »
Code: Lua
  1. --add pdata "TraitorCredit" somehow up here like this:
  2. ply:SetPData( "TraitorCredit", "true" )
  3.  
  4. --add players to traitor like this:
  5. hook.Add( "TTTBeginRound", "AddTraitors", function()
  6. for k, v in pairs( player.GetAll() ) do
  7. if v:IsUserGroup( "supporter" ) and v:GetPData( "TraitorCredit" ) == "true" and not v:IsActiveTraitor() then
  8. v:SetRole( ROLE_TRAITOR )
  9. v:RemovePData( "TraitorCredit" )
  10. end
  11. end )

What's with the extra ")" at the end of your code?
Out of the Garry's Mod business.

Offline ojbristow

  • Newbie
  • *
  • Posts: 47
  • Karma: 0
    • Superclocked
Re: Extra credit for certain rank
« Reply #5 on: January 03, 2014, 03:27:32 pm »
Sorry, what file does this go in, at the minute in looking at traitor_state.lua and cant see where I would slot this in. If im in the right place that is.


Offline Cobalt

  • Full Member
  • ***
  • Posts: 216
  • Karma: 44
  • http://steamcommunity.com/id/__yvl/
Re: Extra credit for certain rank
« Reply #6 on: January 03, 2014, 03:30:28 pm »
What's with the extra ")" at the end of your code?
Because I hooked that function. Also I missed an end, edited the original post.
Sorry, what file does this go in, at the minute in looking at traitor_state.lua and cant see where I would slot this in. If im in the right place that is.
Don't put it in ttt gamemode files, put it in lua/autorun/server
Also make sure you confgure it, don't just throw it in there because right now it won't do anything. You have to give them the credit first.
« Last Edit: January 03, 2014, 03:32:31 pm by Cobalt77 »

Offline ojbristow

  • Newbie
  • *
  • Posts: 47
  • Karma: 0
    • Superclocked
Re: Extra credit for certain rank
« Reply #7 on: January 03, 2014, 03:34:21 pm »
Thank you, Im pretty new to lua. Can you explain what I have to configure please?

Owen


Offline Cobalt

  • Full Member
  • ***
  • Posts: 216
  • Karma: 44
  • http://steamcommunity.com/id/__yvl/
Re: Extra credit for certain rank
« Reply #8 on: January 03, 2014, 03:39:06 pm »
Thank you, Im pretty new to lua. Can you explain what I have to configure please?

Owen
How do you want the players to get credits?

Offline ojbristow

  • Newbie
  • *
  • Posts: 47
  • Karma: 0
    • Superclocked
Re: Extra credit for certain rank
« Reply #9 on: January 03, 2014, 03:40:13 pm »
So, when someone in the supporter rank is selected as a T, they will automatically get it at the start?


Offline Cobalt

  • Full Member
  • ***
  • Posts: 216
  • Karma: 44
  • http://steamcommunity.com/id/__yvl/
Re: Extra credit for certain rank
« Reply #10 on: January 03, 2014, 03:45:02 pm »
So, when someone in the supporter rank is selected as a T, they will automatically get it at the start?
I'm not understanding, if they get traitor aren't they already traitor?

Offline ojbristow

  • Newbie
  • *
  • Posts: 47
  • Karma: 0
    • Superclocked
Re: Extra credit for certain rank
« Reply #11 on: January 03, 2014, 03:46:45 pm »
Yeah, but I want them to get a 'bonus' credit, so if a regular user has 2 credits by default I want the supporter to start off with 3.


Offline Cobalt

  • Full Member
  • ***
  • Posts: 216
  • Karma: 44
  • http://steamcommunity.com/id/__yvl/
Re: Extra credit for certain rank
« Reply #12 on: January 03, 2014, 03:58:12 pm »
Yeah, but I want them to get a 'bonus' credit, so if a regular user has 2 credits by default I want the supporter to start off with 3.
OOOOHHH CREDITS. For some reason I thought you meant like how people can buy a traitor round in the pointshop on some servers.

Do this:

Code: Lua
  1. hook.Add( "TTTBeginRound", "AddTraitors", function()
  2.         for k, v in pairs( player.GetAll() ) do
  3.                 if v:IsUserGroup( "supporter" ) and v:IsActiveTraitor() then
  4.                         v:AddCredits( 1 )
  5.                 end
  6.         end
  7.         for k, v in pairs( player.GetAll() ) do
  8.                 if v:IsUserGroup( "supporter" ) and v:IsActiveDetective() then
  9.                         v:AddCredits( 1 )
  10.                 end
  11.         end
  12. end )
  13.  
  14.  
« Last Edit: January 03, 2014, 04:00:12 pm by Cobalt77 »

Offline ojbristow

  • Newbie
  • *
  • Posts: 47
  • Karma: 0
    • Superclocked
Re: Extra credit for certain rank
« Reply #13 on: January 03, 2014, 03:59:06 pm »
Ah, so sorry for not making my self clear :(

Ill test this now

Thanks,

Owen


Offline ojbristow

  • Newbie
  • *
  • Posts: 47
  • Karma: 0
    • Superclocked
Re: Extra credit for certain rank
« Reply #14 on: January 03, 2014, 04:16:40 pm »
This works perfectly, thank so much :)

Owen


  • Print