• Print

Author Topic: attempt to concatenate local 'target_ply' (a table value)  (Read 7888 times)

0 Members and 1 Guest are viewing this topic.

Offline Tomzen

  • Full Member
  • ***
  • Posts: 115
  • Karma: -1
  • A new lua adventurer
    • Thirdage Gaming
attempt to concatenate local 'target_ply' (a table value)
« on: July 24, 2015, 01:48:21 am »
Code: Lua
  1. CATEGORY_NAME = "DarkRP" -- the category it appears in
  2. JOB_NAME = "citizen" -- default job name
  3. CMD_NAME = "citizen" -- cmd to run (e.g ulx citizen, !citizen)
  4. HELP_LINE = "Demote a player of choice." -- default help message
  5.  
  6. -- Dont edit below this line
  7. function ulx.forcedemote( calling_ply, target_ply )
  8.         game.ConsoleCommand( "rp_citizen " .. target_ply .. "\n" ) -- Sends the command to console to run
  9.     ulx.fancyLogAdmin( calling_ply, true, "#A forced #T to citizen." )
  10.     ULib.csay( target_ply, "You were forced to citizen by an admin." )
  11. end
  12.  
  13. local forcedemote = ulx.command( CATEGORY_NAME, "ulx " .. CMD_NAME, ulx.forcedemote, "!" .. CMD_NAME, true )
  14. forcedemote:addParam{ type=ULib.cmds.PlayersArg }
  15. forcedemote:defaultAccess( ULib.ACCESS_ADMIN )
  16. forcedemote:help( HELP_LINE ) -- End

Line 8 is giving me: [ERROR] addons/ulx/lua/ulx/modules/sh/citizen.lua:8: attempt to concatenate local 'target_ply' (a table value), and when I use...

Code: Lua
  1.             for k,v in pairs ( target_ply ) do
  2.                 game.ConsoleCommand( "rp_citizen " .. target_ply .. "\n" ) -- Sends the command to console to run
  3.             end

I get:
[ERROR] addons/ulx/lua/ulx/modules/sh/citizen.lua:8: bad argument #1 to 'pairs' (table expected, got userdata)
Finished:
Impersonate
<==> FakePromote/Demote <==> RandomMap <==> ForceMic <==> Search <==> PlayMenu <==
WIP:
ServerMode <==

Offline MrPresident

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 2727
  • Karma: 430
    • |G4P| Gman4President
Re: attempt to concatenate local 'target_ply' (a table value)
« Reply #1 on: July 24, 2015, 10:31:39 am »
Take a look at another thread we've been helping someone with recently. Similar issue.
/index.php/topic,8802.0.html

First off though, whether you decide to use a single or multiple targets, you wouldn't be able to just pass the player object through the game.ConsoleCommand like that. You'd have to do target_ply:Nick() and pass their name.

Offline Tomzen

  • Full Member
  • ***
  • Posts: 115
  • Karma: -1
  • A new lua adventurer
    • Thirdage Gaming
Re: attempt to concatenate local 'target_ply' (a table value)
« Reply #2 on: July 25, 2015, 02:43:59 am »
Thanks. It doesn't really need multiple targets, as it's an admin command and would probably be abused, so I'll set it back to one player and make it multiple players if there's demand, but for now it'll do.
Finished:
Impersonate
<==> FakePromote/Demote <==> RandomMap <==> ForceMic <==> Search <==> PlayMenu <==
WIP:
ServerMode <==

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: attempt to concatenate local 'target_ply' (a table value)
« Reply #3 on: July 25, 2015, 06:54:36 am »
No idea how deep some RP's go, but in real life, entire companies close, employees get laid off/fired.
That would technically mean entire group demotions. :)
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline Tomzen

  • Full Member
  • ***
  • Posts: 115
  • Karma: -1
  • A new lua adventurer
    • Thirdage Gaming
Re: attempt to concatenate local 'target_ply' (a table value)
« Reply #4 on: July 25, 2015, 09:32:44 am »
No idea how deep some RP's go, but in real life, entire companies close, employees get laid off/fired.
That would technically mean entire group demotions. :)

Ahh yes, I guess you could use it for that, but I was thinking more like:
1. You just got caught doing the wrong thing on your job, instead of getting banned for hours an admin can just demote you, and someone else would probably take the job.

or 2. An admin finds an AFK, instead of banning/kicking you could demote him.
But I guess I would probably kick an afk, depending on how long they've been afk for.
Finished:
Impersonate
<==> FakePromote/Demote <==> RandomMap <==> ForceMic <==> Search <==> PlayMenu <==
WIP:
ServerMode <==

  • Print