• Print

Author Topic: TTT Event Help  (Read 7256 times)

0 Members and 1 Guest are viewing this topic.

Offline Unknown Gamer

  • Jr. Member
  • **
  • Posts: 79
  • Karma: -2
    • TrueKnife TTT
TTT Event Help
« on: October 10, 2014, 02:37:30 pm »
 HOLA AGAIN,

So more coding error YAAAA  ;D So i've been coding a TTT event and I want it so only certain people can pull certain guns out. Ex. Innocents can only use H.U.G.E 249. If a glock gets added, they can't pull it out and it resets it back to the H.U.G.E. That works BUT... It only works for one, So traitors can only pull out a crowbar only. That works but i can't make it so only innocents can pull a certain gun out. Any help. Heres my current code im using.
Code: Lua
  1. local allowed_weapons = {
  2.         "weapon_zm_carry",
  3.         "weapon_zm_improvised"
  4. }
  5.  
and

Code: Lua
  1. if ply:GetRole() == INNOCENT then
  2.     local allowed_weapons = {
  3.         "weapon_zm_carry",
  4.         "weapon_zm_improvised"
  5.     }
  6. end
  7.  
« Last Edit: October 23, 2014, 02:20:45 pm by BuilderGaming »
Newb Coder. Soon to get better

Offline Unknown Gamer

  • Jr. Member
  • **
  • Posts: 79
  • Karma: -2
    • TrueKnife TTT
Re: TTT Event Help
« Reply #1 on: October 23, 2014, 02:36:04 pm »
*bump*
Newb Coder. Soon to get better

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: TTT Event Help
« Reply #2 on: October 23, 2014, 07:21:26 pm »
You'll need to show more code than that.
What bit of code checks to see what they're pulling out?
Is GetRole() a function set up in the TTT gamemode?
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline Neku

  • Hero Member
  • *****
  • Posts: 549
  • Karma: 27
Re: TTT Event Help
« Reply #3 on: October 24, 2014, 07:59:25 am »
GetRole() returns ROLE_TRAITOR, ROLE_DETECTIVE, and ROLE_INNOCENT.

Your code isn't working because you're using INNOCENT.
Out of the Garry's Mod business.

Offline Unknown Gamer

  • Jr. Member
  • **
  • Posts: 79
  • Karma: -2
    • TrueKnife TTT
Re: TTT Event Help
« Reply #4 on: October 26, 2014, 10:31:06 am »
WOW! I am stupid. I did put ROLE_INNNOCENT for every other but this ;-; let me try ti
Newb Coder. Soon to get better

Offline Unknown Gamer

  • Jr. Member
  • **
  • Posts: 79
  • Karma: -2
    • TrueKnife TTT
Re: TTT Event Help
« Reply #5 on: October 26, 2014, 09:34:57 pm »
OK, i changed it heres the new code
Code: Lua
  1.         if ply:GetRole() == ROLE_INNOCENT then
  2.                 local allowed_weapons = {
  3.                         "weapon_zm_carry",
  4.                         "weapon_zm_improvised",
  5.                         "weapon_zm_sledge"
  6.                 {
  7.         end

and

Code: Lua
  1.         if ply:GetRole() == ROLE_TRAITOR then
  2.                 local allowed_weapons = {
  3.                         "weapon_zm_carry",
  4.                         "weapon_zm_improvised"
  5.                 }
  6.         end

but it keeps saying this for the ROLE_INNOCENT line
Code: Lua
  1. [ERROR] addons/wyozitttev/lua/wtevents/juggernut.lua:59: '}' expected (to close '{' at line 55) near '{'
  2.   1. unknown - addons/wyozitttev/lua/wtevents/juggernut.lua:0
  3.  
Newb Coder. Soon to get better

Offline Decicus

  • Hero Member
  • *****
  • Posts: 552
  • Karma: 81
    • Alex Thomassen
Re: TTT Event Help
« Reply #6 on: October 26, 2014, 10:08:58 pm »
OK, i changed it heres the new code
Code: Lua
  1.         if ply:GetRole() == ROLE_INNOCENT then
  2.                 local allowed_weapons = {
  3.                         "weapon_zm_carry",
  4.                         "weapon_zm_improvised",
  5.                         "weapon_zm_sledge"
  6.                 {
  7.         end

and

Code: Lua
  1.         if ply:GetRole() == ROLE_TRAITOR then
  2.                 local allowed_weapons = {
  3.                         "weapon_zm_carry",
  4.                         "weapon_zm_improvised"
  5.                 }
  6.         end

but it keeps saying this for the ROLE_INNOCENT line
Code: Lua
  1. [ERROR] addons/wyozitttev/lua/wtevents/juggernut.lua:59: '}' expected (to close '{' at line 55) near '{'
  2.   1. unknown - addons/wyozitttev/lua/wtevents/juggernut.lua:0
  3.  

The error pretty much says what's wrong.
Line #6 of your "innocent" code has "{" (opening curly bracket) instead of "}" (closing curly bracket).
Contact information:
E-mail: alex@thomassen.xyz.
You can also send a PM.

Offline Unknown Gamer

  • Jr. Member
  • **
  • Posts: 79
  • Karma: -2
    • TrueKnife TTT
Re: TTT Event Help
« Reply #7 on: October 28, 2014, 06:39:47 am »
The error pretty much says what's wrong.
Line #6 of your "innocent" code has "{" (opening curly bracket) instead of "}" (closing curly bracket).

My god ive never been so stupid out of my 3 months of coding ;-;
Newb Coder. Soon to get better

Offline Unknown Gamer

  • Jr. Member
  • **
  • Posts: 79
  • Karma: -2
    • TrueKnife TTT
Re: TTT Event Help
« Reply #8 on: October 29, 2014, 05:56:45 am »
Now it says "ply" is a nil value for ply:GetRoll  >:(
« Last Edit: October 29, 2014, 04:06:08 pm by BuilderGaming »
Newb Coder. Soon to get better

Offline bender180

  • Full Member
  • ***
  • Posts: 217
  • Karma: 42
    • Benders Villa
Re: TTT Event Help
« Reply #9 on: October 29, 2014, 01:40:08 pm »
you havent told gmod what ply is.
Made community pool and community bowling and for the life of me couldn't tell you why they are popular.
Also made the ttt ulx commands.

Offline Unknown Gamer

  • Jr. Member
  • **
  • Posts: 79
  • Karma: -2
    • TrueKnife TTT
Re: TTT Event Help
« Reply #10 on: October 29, 2014, 04:06:20 pm »
Sorry, I was at school and tried to post ASAP. Heres the actual error
Code: Lua
  1. [ERROR] addons/wyozitttev/lua/wtevents/juggernut.lua:32: attempt to index global 'ply' (a nil value)
  2.   1. unknown - addons/wyozitttev/lua/wtevents/juggernut.lua:32

Here is line 32 to 37
Code: Lua
  1.         if ply:GetRole() == ROLE_TRAITOR then
  2.                 local allowed_weapons = {
  3.                         "weapon_zm_carry",
  4.                         "weapon_zm_improvised"
  5.                 }
  6.         end
Newb Coder. Soon to get better

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: TTT Event Help
« Reply #11 on: October 29, 2014, 07:41:01 pm »
you havent told gmod what ply is.
The answer is still the same, no matter how many times you tell us the error, you're not defining what ply is in your function.
Therefore, ply is nil.
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline Unknown Gamer

  • Jr. Member
  • **
  • Posts: 79
  • Karma: -2
    • TrueKnife TTT
Re: TTT Event Help
« Reply #12 on: October 30, 2014, 03:00:16 pm »
My god. IM JUST RETARTED TODAY! I forgot to add my function ;;;;--------;;;;; There are other bugs but I know how to fix them. Thanks Guys  ;)
Newb Coder. Soon to get better

  • Print