Author Topic: Command help  (Read 2029 times)

0 Members and 1 Guest are viewing this topic.

Offline Dolph1n

  • Newbie
  • *
  • Posts: 2
  • Karma: 0
Command help
« on: January 07, 2017, 05:21:38 PM »
So, I'm not the best at coding, but I know basics and I'm pretty good at using ctrl+c and ctrl+v, so go easy on me.

Anyways I'm trying to make a command  for TTT that will check if you are alive, and if you are will give you a Tsay, and if you're NOT alive it will force you to spectate a player(like ulx spectate does).

Here's what I have so far:
Code: [Select]
function ulx.spectate( calling_ply, target_ply )
if not calling_ply:IsValid() then
Msg( "You can't spectate from dedicated server console.\n" )
return
end
for k,v in pairs(calling_plys) do
if v:Alive() then
Msg( "You can't spectate while alive!" )
else
calling_ply:Kill()
calling_ply:SetForceSpec(true)
calling_ply:SetTeam(TEAM_SPEC)
calling_ply:ConCommand( "ttt_spectate" )
calling_ply:ConCommand( "ttt_spectator_mode 1" )
calling_ply:Spectate( OBS_MODE_IN_EYE )
calling_ply:SpectateEntity( target_ply )



ulx.fancyLogAdmin( calling_ply, true, "#A began spectating #T", target_ply )
end
end
end

When I use the command, nothing happens and I get this error:
Code: [Select]
[ERROR] addons/ulx/lua/ulx/modules/sh/util.lua:200: function arguments expected near ':'
  1. unknown - addons/ulx/lua/ulx/modules/sh/util.lua:0

EDIT: I think I got it, retrying.

Ok, so I no longer get the error but nothing happens, at least while alive.

EDIT 2: Nothing happens while dead either.

EDIT 3: It's no longer a recognized command by ULX. Fun.

EDIT 4: There's gonna be a lot of edits in this. Wow I'm bad at coding.

I moved some "end"s around and got it to be a command again, but now I get this error:
Code: [Select]
[ERROR] addons/ulx/lua/ulx/modules/sh/util.lua:196: bad argument #1 to 'pairs' (table expected, got nil)
  1. pairs - [C]:-1
   2. call - addons/ulx/lua/ulx/modules/sh/util.lua:196
    3. __fn - addons/ulib/lua/ulib/shared/commands.lua:943
     4. unknown - addons/ulib/lua/ulib/shared/commands.lua:1296
      5. unknown - lua/includes/modules/concommand.lua:54
« Last Edit: January 07, 2017, 06:17:30 PM by Dolph1n »

An Error Has Occurred!

array_keys(): Argument #1 ($array) must be of type array, null given