• Print

Author Topic: Help with the return command  (Read 4607 times)

0 Members and 1 Guest are viewing this topic.

Offline BlueNova

  • Full Member
  • ***
  • Posts: 113
  • Karma: 13
  • The most powerful force in the universe.
Help with the return command
« on: March 10, 2018, 09:39:38 pm »
Hey,

So I'm making a custom ulx command that is being tacked onto the teleport commands. It simply just combines the functionality of bring but also freezes the target. So far the command works fine yet when I try to return the person I summoned I get this error.

Code: [Select]
Bot03 does not have any previous locations to send them to.
The way I'm having their position set is a lot shorter than bring so I think that may have something to do with it.

Code: Lua
  1. target_ply:SetPos(calling_ply:GetPos() + Vector(50, 50, 0))
  2. target_ply:Freeze(true)

The rest of the code is just conditioned like if they're alive and such. But the given statement above is the real meat and potatoes of this command.

So basically I just want to know how come when I try to return them it doesn't work? I've read over teleport.lua several times and it may be because it's late but I can't put it together. Any help would be appreciated.

Thanks

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: Help with the return command
« Reply #1 on: March 10, 2018, 10:03:17 pm »
Check your functions to ensure your setting ulx_prevpos key on target object.
Without seeing all your code, really no way for us to tell best solution.
ulx_prevpos is used 7 times within standard teleport.lua
target_ply.ulx_prevpos is used 4.
You're likely missing setting it. ULX has a single tool function used in send/bring/teleport and return that target_ply.ulx_prevpos gets set in.
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline BlueNova

  • Full Member
  • ***
  • Posts: 113
  • Karma: 13
  • The most powerful force in the universe.
Re: Help with the return command
« Reply #2 on: March 10, 2018, 10:08:22 pm »
I'll provide the entire code for novelty I suppose. Though I will read through the rest of the file in the morning when I am more attentive.

Code: Lua
  1.  
  2. function ulx.breeze(calling_ply, target_ply)
  3.        
  4.         if not calling_ply:IsValid() then
  5.                 MsgN("You cannot use this from the console.")
  6.                 return
  7.         end
  8.  
  9.         if not target_ply:Alive() then
  10.                 ULib.tsayError(calling_ply, target_ply:Nick() .. " is dead!", true)
  11.                 return
  12.         end
  13.  
  14.         if not calling_ply:Alive() then
  15.                 ULib.tsayError(calling_ply, "You are dead!", true)
  16.                 return
  17.         end
  18.        
  19.         if calling_ply == target_ply then
  20.                 ULib.tsayError(calling_ply, "You are trying to get closer to yourself than we feel is necessary.", true)
  21.                 return
  22.         end
  23.  
  24.         if target_ply:InVehicle() then
  25.                 target_ply:ExitVehicle()
  26.         end
  27.  
  28.         target_ply:SetPos(calling_ply:GetPos() + Vector(50, 50, 0))
  29.         target_ply:Freeze(true)
  30.  
  31.         ulx.fancyLogAdmin(calling_ply, "#A has summoned and frozen #T", target_ply)
  32. end
  33.  
  34. local breeze = ulx.command(CATEGORY_NAME, "ulx breeze", ulx.breeze, "!breeze", true)
  35. breeze:addParam{type=ULib.cmds.PlayerArg}
  36. breeze:defaultAccess(ULib.ACCESS_ADMIN)
  37. breeze:help("Summons and freezes a player.")



God <censor> I'm an idiot.

All it took was literally this...

Code: Lua
  1. target_ply.ulx_prevpos = target_ply:GetPos()
  2. target_ply.ulx_prevang = target_ply:EyeAngles()

Note to self, don't try to work when you can barely think. Things won't work out.

Thanks though, JamminR, I probably would've starred at this in awe for a couple more hours if you haven't pointed out that it never defined a previous position for the target player.
« Last Edit: March 10, 2018, 10:18:25 pm by BlueNova »

  • Print