• Print

Author Topic: Double setOpposites?  (Read 4560 times)

0 Members and 1 Guest are viewing this topic.

Offline WispySkies

  • Full Member
  • ***
  • Posts: 144
  • Karma: 0
  • I make random commands and Lua errors.
Double setOpposites?
« on: November 13, 2015, 02:41:41 pm »
The title, mainly, are you able to have 2 setOpposites in a command? I'm making a spectate thing (I'd rather take on making one myself to get the memory of the glua stuff {e.g. ply:SetMoveType etc}) to see anothers screen and I want an option to secretly spectate them. Add a way to exit the screen. Like this:
Code: Lua
  1. local CATEGORY_NAME = "Entity Suite"
  2.  
  3. function ulx.view( ply, target, should_exit, should_silent )
  4.     if not should_silent then
  5.         if not should_exit then
  6.             if ply == ply then
  7.                 ULib.tsayError( ply, "You can't spectate yourself!" )
  8.                 ply:Spectate( OBS_MODE_IN_EYE )
  9.                 local undoscreen = ply:GetMoveType()
  10.                 ply:SetMoveType( MOVETYPE_OBSERVER )
  11.                 ply:SpectateEntity( target )
  12.                 ulx.fancyLogAdmin( ply, "#A see #T's screen.", target )
  13.             else
  14.                 ply:Spectate( OBS_MODE_NONE )
  15.                 ply:SetMoveType( undoscreen )
  16.                 ulx.fancyLogAdmin( ply, "#A stopped seeing #T's screen.", target )
  17.             end
  18.         end
  19.     elseif should_silent then
  20.         if not should_exit then
  21.             if ply == ply then
  22.                 ULib.tsayError( ply, "You can't spectate yourself!" )
  23.                 ply:Spectate( OBS_MODE_IN_EYE )
  24.                 local undoscreen = ply:GetMoveType()
  25.                 ply:SetMoveType( MOVETYPE_OBSERVER )
  26.                 ply:SpectateEntity( target )
  27.                 ulx.fancyLogAdmin( ply, true, "#A see #T's screen.", target )
  28.             else
  29.                 ply:Spectate( OBS_MODE_NONE )
  30.                 ply:SetMoveType( undoscreen )
  31.                 ulx.fancyLogAdmin( ply, "#A stopped seeing #T's screen.", target )
  32.             end
  33.         end
  34.     end
  35. end
  36. local view = ulx.command( CATEGORY_NAME, "ulx view", ulx.view, "!view" )
  37. view:defaultAccess( ULib.ACCESS_SUPERADMIN )
  38. view:addParam{ type = ULib.PlayerArg, hint = "spectatee" }
  39. view:help( "Spectate a target." )
  40. view:setOpposite( "ulx stopview", { _, _, true }, "!stopview" )
  41. view:setOpposite( "ulx sview", { _, _, _, true }, "!sview" )
  42.  
Yes, the code is messy D:
« Last Edit: November 13, 2015, 02:45:07 pm by WispySkies »

Offline WispySkies

  • Full Member
  • ***
  • Posts: 144
  • Karma: 0
  • I make random commands and Lua errors.
Re: Double setOpposites?
« Reply #1 on: November 13, 2015, 02:56:55 pm »
Nevermind, !spectate too cool for me 8) Although, is 2 opposites possible?

Offline roastchicken

  • Respected Community Member
  • Sr. Member
  • *****
  • Posts: 476
  • Karma: 84
  • I write code
Re: Double setOpposites?
« Reply #2 on: November 16, 2015, 11:13:44 am »
The word opposite implies only two values. No, you cannot have two opposites.
Give a man some code and you help him for a day; teach a man to code and you help him for a lifetime.

Offline WispySkies

  • Full Member
  • ***
  • Posts: 144
  • Karma: 0
  • I make random commands and Lua errors.
Re: Double setOpposites?
« Reply #3 on: November 18, 2015, 04:40:35 pm »
Oh, alright. I thought that you could have 2 opposites, one to silence the command, and if you want to exit, so its separate. I though wrong, thank you.

Offline Bite That Apple

  • Hero Member
  • *****
  • Posts: 858
  • Karma: 416
  • Apple Innovations 2010®
    • Fun 4 Everyone Gaming
Re: Double setOpposites?
« Reply #4 on: November 18, 2015, 10:57:25 pm »
Like in math, a double negative is a positive, just saying.
Quote from: John F. Kennedy 1963
A man may die, nations may rise and fall, but an idea lives on.

  • Print