ULX

Author Topic: Last Position Teleporting  (Read 6449 times)

0 Members and 1 Guest are viewing this topic.

Offline Ivef

  • Newbie
  • *
  • Posts: 4
  • Karma: 0
Last Position Teleporting
« on: August 19, 2013, 09:42:07 PM »
This is a very, very simple add-on to the current teleport functions that will allow you to teleport either yourself or other players back to their last position after you or somebody else has teleported them.
Basically how it works is whenever you or somebody else teleports their position gets saved and can be accessed via a command.

Take the attached file and backup your old teleport.lua located below. (Incase you want to remove this feature.)
/addons/ulx/lua/modules/sh/teleport.lua


This is the command function: Note this will not work without the other things like the table and setting values when somebody teleports.
Code: [Select]
function ulx.back( calling_ply, target_ply )
if not calling_ply:IsValid() then
Msg( "Cannot run from console.\n" )
return
end
if not target_ply:Alive() then
ULib.tsayError( calling_ply, target_ply:Nick() .. " is dead!", true )
return
end
local newpos = LastPos[ target_ply:SteamID() ]
if not newpos then
ULib.tsayError( calling_ply, "No last position found.", true )
return
end
target_ply:SetPos( LastPos[ target_ply:SteamID() ] )
target_ply:SetLocalVelocity( Vector( 0, 0, 0 ) )
ulx.fancyLogAdmin( calling_ply, "#A teleported #T back to their last position.", target_ply )
end
local back = ulx.command( CATEGORY_NAME, "ulx back", ulx.back, "!back" )
back:addParam{ type = ULib.cmds.PlayerArg, ULib.cmds.optional }
back:defaultAccess( ULib.ACCESS_ADMIN )
back:help( "Teleports you or the selected player back to their last position." )

You must be logged in to view the attached file.

Offline Cadence

  • Newbie
  • *
  • Posts: 1
  • Karma: 0
Re: Last Position Teleporting
« Reply #1 on: August 24, 2013, 04:43:50 PM »
How do i give someone the permission for this ? even i dont have it please tell me.

Offline Ivef

  • Newbie
  • *
  • Posts: 4
  • Karma: 0
Re: Last Position Teleporting
« Reply #2 on: August 24, 2013, 08:49:49 PM »
To grant access to an individual player enter this into console ( if you have access, if not do it from RCon. ):
Code: [Select]
ulx userallow "name" "ulx back" "^" - This will allow them to only run it on themself. I assume that replacing this with a * will let them run it on anybody.

To grant it to a group:
Code: [Select]
ulx groupallow "group" "ulx back" "^" - Again, this will only allow them to run it on themself, except everybody in the group will have access.


By default, this command is restricted to admins only.