• Print

Author Topic: Voice battery length with ULX groups  (Read 7077 times)

0 Members and 1 Guest are viewing this topic.

Offline seabeds

  • Newbie
  • *
  • Posts: 35
  • Karma: 0
    • Seaside TTT
Voice battery length with ULX groups
« on: July 12, 2015, 05:15:03 pm »
Hello everyone! I run a garry's mod server on the newest update. Obviously I got the voice battery to work since it comes with the gamemode but I would like to have certain ULX groups to have a larger battery than the default. To put this more im perspective, the default battery is set to 0.5, and i would like to have VIP users to have a battery of 0.3.

How can i make this possible? I was messing around and I'm not sure. Figured i could come here for help :)

Offline Decicus

  • Hero Member
  • *****
  • Posts: 552
  • Karma: 81
    • Alex Thomassen
Re: Voice battery length with ULX groups
« Reply #1 on: July 13, 2015, 04:29:43 am »
If I remember right, the easiest and 'only' way is to modify lines 626-630 in cl_voice.lua of the gamemode. This isn't recommended, as it will probably need to be modified again after a Garry's Mod update, but I don't think there's currently any other way.

Should look something like:
Code: Lua
  1. if ply:IsAdmin() or ply:IsDetective() then
  2.     return GetGlobalFloat("ttt_voice_drain_admin", 0) -- Default 0.05
  3. elseif ply:IsUserGroup( "vip" ) then
  4.     return 0.1
  5. else
  6.     return GetGlobalFloat("ttt_voice_drain_normal", 0) -- Default: 0.2
  7. end
0.1 is just an example, since it's half of the drain rate of normal players, thus giving twice the battery for "vip". Change this how you would like it to be.
Contact information:
E-mail: alex@thomassen.xyz.
You can also send a PM.

Offline Aaron113

  • Hero Member
  • *****
  • Posts: 803
  • Karma: 102
Re: Voice battery length with ULX groups
« Reply #2 on: July 13, 2015, 09:30:34 am »
Overwrite VOICE.Tick right below it.  That is where all of this is handled and VOICE appears to be a gobal variable.  You could basically copy the existing code there and modify it to work how you want.

Offline seabeds

  • Newbie
  • *
  • Posts: 35
  • Karma: 0
    • Seaside TTT
Re: Voice battery length with ULX groups
« Reply #3 on: July 13, 2015, 10:28:08 am »
If I remember right, the easiest and 'only' way is to modify lines 626-630 in cl_voice.lua of the gamemode. This isn't recommended, as it will probably need to be modified again after a Garry's Mod update, but I don't think there's currently any other way.

Should look something like:
Code: Lua
  1. if ply:IsAdmin() or ply:IsDetective() then
  2.     return GetGlobalFloat("ttt_voice_drain_admin", 0) -- Default 0.05
  3. elseif ply:IsUserGroup( "vip" ) then
  4.     return 0.1
  5. else
  6.     return GetGlobalFloat("ttt_voice_drain_normal", 0) -- Default: 0.2
  7. end
0.1 is just an example, since it's half of the drain rate of normal players, thus giving twice the battery for "vip". Change this how you would like it to be.

And if i wanted to make VIP+ users have an even longer battery, it would look like this?

Code: Lua
  1. if ply:IsAdmin() or ply:IsDetective() then
  2.     return GetGlobalFloat("ttt_voice_drain_admin", 0) -- Default 0.05
  3. elseif ply:IsUserGroup( "vip" ) then
  4.     return 0.1
  5. elseif ply:IsUserGroup( "vip+" ) then
  6.     return 0.05
  7. else
  8.     return GetGlobalFloat("ttt_voice_drain_normal", 0) -- Default: 0.2
  9. end

Offline Decicus

  • Hero Member
  • *****
  • Posts: 552
  • Karma: 81
    • Alex Thomassen
Re: Voice battery length with ULX groups
« Reply #4 on: July 13, 2015, 10:47:02 am »
And if i wanted to make VIP+ users have an even longer battery, it would look like this?

Code: Lua
  1. if ply:IsAdmin() or ply:IsDetective() then
  2.     return GetGlobalFloat("ttt_voice_drain_admin", 0) -- Default 0.05
  3. elseif ply:IsUserGroup( "vip" ) then
  4.     return 0.1
  5. elseif ply:IsUserGroup( "vip+" ) then
  6.     return 0.05
  7. else
  8.     return GetGlobalFloat("ttt_voice_drain_normal", 0) -- Default: 0.2
  9. end

That looks correct.
Contact information:
E-mail: alex@thomassen.xyz.
You can also send a PM.

Offline seabeds

  • Newbie
  • *
  • Posts: 35
  • Karma: 0
    • Seaside TTT
Re: Voice battery length with ULX groups
« Reply #5 on: July 13, 2015, 10:57:44 am »
That looks correct.

Alright, i just tried it and console was flooded with this error

[ERROR] gamemodes/terrortown/gamemode/cl_init.lua:323: attempt to index global 'RADIO' (a nil value)
  1. unknown - gamemodes/terrortown/gamemode/cl_init.lua:323


And the error is pointing to this code
Code: Lua
  1. RADIO:StoreTarget()
« Last Edit: July 13, 2015, 11:01:31 am by seabeds »

Offline seabeds

  • Newbie
  • *
  • Posts: 35
  • Karma: 0
    • Seaside TTT
Re: Voice battery length with ULX groups
« Reply #6 on: July 16, 2015, 11:02:14 am »
Help anyone?

Offline Decicus

  • Hero Member
  • *****
  • Posts: 552
  • Karma: 81
    • Alex Thomassen
Re: Voice battery length with ULX groups
« Reply #7 on: July 18, 2015, 08:39:39 am »
Alright, i just tried it and console was flooded with this error

[ERROR] gamemodes/terrortown/gamemode/cl_init.lua:323: attempt to index global 'RADIO' (a nil value)
  1. unknown - gamemodes/terrortown/gamemode/cl_init.lua:323


And the error is pointing to this code
Code: Lua
  1. RADIO:StoreTarget()

Can you post the full error log?
Contact information:
E-mail: alex@thomassen.xyz.
You can also send a PM.

Offline Aaron113

  • Hero Member
  • *****
  • Posts: 803
  • Karma: 102
Re: Voice battery length with ULX groups
« Reply #8 on: July 18, 2015, 09:58:44 pm »
The full code that you changed as well as code around it would be nice as well.  I feel like it may be a syntax error.

Offline seabeds

  • Newbie
  • *
  • Posts: 35
  • Karma: 0
    • Seaside TTT
Re: Voice battery length with ULX groups
« Reply #9 on: July 20, 2015, 03:34:55 pm »
Can you post the full error log?

If I an not mistaken, that is the only error in console that came up. It was spamming and flooding console at an extrmley fast rate though. So i may have missed something

Offline seabeds

  • Newbie
  • *
  • Posts: 35
  • Karma: 0
    • Seaside TTT
Re: Voice battery length with ULX groups
« Reply #10 on: July 20, 2015, 04:14:11 pm »
Tried again and now i am getting this error:

[ERROR] gamemodes/terrortown/gamemode/cl_init.lua:326: attempt to index global 'VOICE' (a nil value)
  1. unknown - gamemodes/terrortown/gamemode/cl_init.lua:326

Did i mention im trying to do this on a TTT server? That may have an effect

Offline Decicus

  • Hero Member
  • *****
  • Posts: 552
  • Karma: 81
    • Alex Thomassen
Re: Voice battery length with ULX groups
« Reply #11 on: July 20, 2015, 07:36:15 pm »
The files I asked you to edit are gamemode-specific files for TTT. I assumed it was TTT, because of the server banner in your signature.

As Aaron113 said, could you post the full code you changed as well? Use the code BBcodes.
Contact information:
E-mail: alex@thomassen.xyz.
You can also send a PM.

Offline seabeds

  • Newbie
  • *
  • Posts: 35
  • Karma: 0
    • Seaside TTT
Re: Voice battery length with ULX groups
« Reply #12 on: July 21, 2015, 09:22:09 am »
The only file I editted was gamemode/terrortown/gamemode/cl_voice

I went from the default (Lines 626-631):
Code: Lua
  1. if ply:IsAdmin() or ply:IsDetective() then
  2.       return GetGlobalFloat("ttt_voice_drain_admin", 0)
  3.    else
  4.       return GetGlobalFloat("ttt_voice_drain_normal", 0)
  5.    end
  6. end


To this:
Code: Lua
  1. if ply:IsAdmin() or ply:IsDetective() then
  2.     return GetGlobalFloat("ttt_voice_drain_admin", 0) -- Default 0.05
  3. elseif ply:IsUserGroup( "vip" ) then
  4.     return 0.1
  5. elseif ply:IsUserGroup( "vip+" ) then
  6.     return 0.05
  7. else
  8.     return GetGlobalFloat("ttt_voice_drain_normal", 0) -- Default: 0.2
  9. end


That is the only thing I touched. Now when the file is editted and saved, and the server is restarted, I connect and my console is flooded with the error I said earlier.
« Last Edit: July 21, 2015, 09:25:07 am by seabeds »

Offline seabeds

  • Newbie
  • *
  • Posts: 35
  • Karma: 0
    • Seaside TTT
Re: Voice battery length with ULX groups
« Reply #13 on: August 08, 2015, 03:47:53 pm »
I still wish and hope to have this answered/helped.

  • Print