• Print

Author Topic: Looking for the wrong value?  (Read 6822 times)

0 Members and 1 Guest are viewing this topic.

Offline zappsmcjack

  • Newbie
  • *
  • Posts: 4
  • Karma: 0
Looking for the wrong value?
« on: January 13, 2013, 09:13:35 pm »
aight so im tired and i really cannot figure out what im doing wrong
i have limited lua knowledge but this isn't exactly something hard to achieve

Code: [Select]
------------------------------ Traitor ------------------------------
function ulx.traitor( calling_ply, target_plys )
for i=1, #target_plys do
target_plys:SetRole(ROLE_TRAITOR)
end
ulx.fancyLogAdmin( calling_ply, "#A set the hp for #T to #i", target_plys )
end
local traitor = ulx.command( CATEGORY_NAME, "ulx traitor", ulx.traitor, "!traitor" )
traitor:addParam{ type=ULib.cmds.PlayersArg }
traitor:defaultAccess( ULib.ACCESS_ADMIN )
traitor:help( "Sets target(s) as a traitor" )

says SetRole is nil or something
and before it was looking for a num value i dont remember why

actually i might have just copy and pasted some code and edited it
i dont really remember
im really tired

all help is appreciated

Offline MrPresident

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 2727
  • Karma: 430
    • |G4P| Gman4President
Re: Looking for the wrong value?
« Reply #1 on: January 13, 2013, 09:29:59 pm »
SetRole isn't a default garry's mod. You'd be better off getting some help from a DarkRP coder.

saying that it is nil means that that function isn't recognized.

Offline zappsmcjack

  • Newbie
  • *
  • Posts: 4
  • Karma: 0
Re: Looking for the wrong value?
« Reply #2 on: January 13, 2013, 09:40:54 pm »
it's for TTT

basically all im looking for is so that SetRole is attributed to the name being entered or whatever

Offline Megiddo

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 6214
  • Karma: 394
  • Project Lead
Re: Looking for the wrong value?
« Reply #3 on: January 14, 2013, 03:31:14 am »
aight so im tired and i really cannot figure out what im doing wrong
i have limited lua knowledge but this isn't exactly something hard to achieve

Code: [Select]
------------------------------ Traitor ------------------------------
function ulx.traitor( calling_ply, target_plys )
for i=1, #target_plys do
target_plys:SetRole(ROLE_TRAITOR)
end
ulx.fancyLogAdmin( calling_ply, "#A set the hp for #T to #i", target_plys )
end
local traitor = ulx.command( CATEGORY_NAME, "ulx traitor", ulx.traitor, "!traitor" )
traitor:addParam{ type=ULib.cmds.PlayersArg }
traitor:defaultAccess( ULib.ACCESS_ADMIN )
traitor:help( "Sets target(s) as a traitor" )

says SetRole is nil or something
and before it was looking for a num value i dont remember why

actually i might have just copy and pasted some code and edited it
i dont really remember
im really tired

all help is appreciated

You probably meant to apply that function per player instead of to the target_plys table.
Experiencing God's grace one day at a time.

Offline zappsmcjack

  • Newbie
  • *
  • Posts: 4
  • Karma: 0
Re: Looking for the wrong value?
« Reply #4 on: January 14, 2013, 05:24:00 am »
the problem with it is right here

target_plys:SetRole(ROLE_TRAITOR)

apparently it's looking for some sort of value to be entered

Offline Megiddo

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 6214
  • Karma: 394
  • Project Lead
Re: Looking for the wrong value?
« Reply #5 on: January 14, 2013, 06:04:28 am »
apparently it's looking for some sort of value to be entered

...did you read what I wrote above? :)

Here's what you want:
Code: Lua
  1. ------------------------------ Traitor ------------------------------
  2. function ulx.traitor( calling_ply, target_plys )
  3.         for i=1, #target_plys do
  4.                 target_plys[i]:SetRole(ROLE_TRAITOR)
  5.         end
  6.         ulx.fancyLogAdmin( calling_ply, "#A set the hp for #T to #i", target_plys )
  7. end
  8. local traitor = ulx.command( CATEGORY_NAME, "ulx traitor", ulx.traitor, "!traitor" )
  9. traitor:addParam{ type=ULib.cmds.PlayersArg }
  10. traitor:defaultAccess( ULib.ACCESS_ADMIN )
  11. traitor:help( "Sets target(s) as a traitor" )
Experiencing God's grace one day at a time.

Offline zappsmcjack

  • Newbie
  • *
  • Posts: 4
  • Karma: 0
Re: Looking for the wrong value?
« Reply #6 on: January 14, 2013, 07:15:00 am »
my bad didn't see that, thanks

  • Print