Author Topic: jail tp to coördinates  (Read 8855 times)

0 Members and 1 Guest are viewing this topic.

Offline ULXGmodFan

  • Newbie
  • *
  • Posts: 28
  • Karma: 0
jail tp to coördinates
« on: May 22, 2014, 09:03:45 AM »
Hello,

I love ulx, especially with lots of plugins. Never have any trouble or miss stuff which I need for my sandbox building server. There is only 1 thing that's really missing for me and that's a jail tp command to preset coördinates. If your server runs on a map you sometimes have a jail included. I know some mods have it, but they're not half as good as ulx is. It can be simply done I think with a command for the sadmin ulx setjailposition or something. Or even jailposition1, jailposition2, jailpos3 and 4 so you can have 4 different cells or somehting. But that's not really needed for sandbox, but would definately be cool as an extra if it's not too much trouble. But a jailposition command would be super.

So I kindly would ask if it's possible to include it, it would be really really really awesome!

Thanks alot
« Last Edit: May 22, 2014, 09:08:15 AM by ULXGmodFan »

Offline Avoid

  • Full Member
  • ***
  • Posts: 142
  • Karma: 42
Re: jail tp to coördinates
« Reply #1 on: May 22, 2014, 10:12:14 AM »
Hello there,
eventhough this does not quite belong in the suggestions category, you can accomplish this task easily by yourself, take a look at jailtp:
Code: [Select]
       ------------------------------ Jail TP ------------------------------
function ulx.jailtp( calling_ply, target_ply, seconds )
local t = {}
        t.start = calling_ply:GetPos() + Vector( 0, 0, 32 ) -- Move them up a bit so they can travel across the ground
        t.endpos = calling_ply:GetPos() + calling_ply:EyeAngles():Forward() * 16384
        t.filter = target_ply
        if target_ply ~= calling_ply then
                t.filter = { target_ply, calling_ply }
        end
        local tr = util.TraceEntity( t, target_ply )

        local pos = tr.HitPos

        if ulx.getExclusive( target_ply, calling_ply ) then
                ULib.tsayError( calling_ply, ulx.getExclusive( target_ply, calling_ply ), true )
                return
        elseif not target_ply:Alive() then
                ULib.tsayError( calling_ply, target_ply:Nick() .. " is dead!", true )
                return
        elseif not jailableArea( pos ) then
                ULib.tsayError( calling_ply, "That is not an area where a jail can be placed!", true )
                return
        else
                if target_ply:InVehicle() then
                        target_ply:ExitVehicle()
                end

                target_ply:SetPos( pos )
                target_ply:SetLocalVelocity( Vector( 0, 0, 0 ) ) -- Stop!

                doJail( target_ply, seconds )
        end

        local str = "#A teleported and jailed #T"
        if seconds > 0 then
                str = str .. " for #i seconds"
        end
        ulx.fancyLogAdmin( calling_ply, str, target_ply, seconds )
end
local jailtp = ulx.command( CATEGORY_NAME, "ulx jailtp", ulx.jailtp, "!jailtp" )
jailtp:addParam{ type=ULib.cmds.PlayerArg }
jailtp:addParam{ type=ULib.cmds.NumArg, min=0, default=0, hint="seconds, 0 is forever", ULib.cmds.round, ULib.cmds.optional }
jailtp:defaultAccess( ULib.ACCESS_ADMIN )
jailtp:help( "Teleports, then jails target(s)." )

Especially at those lines here:
Code: [Select]
local pos = tr.HitPos
 target_ply:SetPos( pos )

Hope I pointed you in the right direction.
Avoid
« Last Edit: May 22, 2014, 10:15:03 AM by Avoid »

Offline ULXGmodFan

  • Newbie
  • *
  • Posts: 28
  • Karma: 0
Re: jail tp to coördinates
« Reply #2 on: May 22, 2014, 12:28:26 PM »
I cant really do Code  :-[ I figure I need to put the coördinates at the place where the 0,0,0 is?

But that way you can never change the position while playing. I think it would be handy to have as extra cmd. If a custom jail position isn't set the jail is at the current position as default :)
« Last Edit: May 22, 2014, 12:32:07 PM by ULXGmodFan »

Offline Neku

  • Hero Member
  • *****
  • Posts: 549
  • Karma: 27
Re: jail tp to coördinates
« Reply #3 on: May 22, 2014, 09:41:00 PM »
You can have another command that stores the location in the data folder.

Then have jailtp send the target to the stored location .
Out of the Garry's Mod business.

Offline ULXGmodFan

  • Newbie
  • *
  • Posts: 28
  • Karma: 0
Re: jail tp to coördinates
« Reply #4 on: May 27, 2014, 07:43:43 AM »
You can have another command that stores the location in the data folder.

Then have jailtp send the target to the stored location .
Could you maybe provide me with steps? I really don't understand which file I should make and which extention etc. Thanks alot

Offline Neku

  • Hero Member
  • *****
  • Posts: 549
  • Karma: 27
Re: jail tp to coördinates
« Reply #5 on: May 27, 2014, 08:38:35 AM »
Could you maybe provide me with steps? I really don't understand which file I should make and which extention etc. Thanks alot

For the command or the data?
Out of the Garry's Mod business.

Offline ULXGmodFan

  • Newbie
  • *
  • Posts: 28
  • Karma: 0
Re: jail tp to coördinates
« Reply #6 on: May 28, 2014, 10:06:46 AM »
To make ULX tpjail work for a location somewhere

Offline ULXGmodFan

  • Newbie
  • *
  • Posts: 28
  • Karma: 0
Re: jail tp to coördinates
« Reply #7 on: May 29, 2014, 08:21:21 AM »
I'm sorry to ask it again but I really don't understand what I should change. Any help is greatly appreciated.

Offline Cobalt

  • Full Member
  • ***
  • Posts: 216
  • Karma: 44
  • http://steamcommunity.com/id/__yvl/
Re: jail tp to coördinates
« Reply #8 on: May 29, 2014, 06:41:32 PM »
Here's how I would go about doing it:
1. Create a blank data file to put your vector in
2. Hook initialize and read the file using util.StringToType (after you check if there is anything in it) and save that as a global vector
3. Create a ulx command to write a vector to that file using util.TypeToString (Have a function in it to refresh the global vector if you overwrite it)
4. Copy jailtp but instead of sending it to the position where you are looking, send it to the global vector instead.

Offline Neku

  • Hero Member
  • *****
  • Posts: 549
  • Karma: 27
Re: jail tp to coördinates
« Reply #9 on: May 29, 2014, 10:03:28 PM »
Here's what I came up with, I haven't tested it, so tell me if anything goes wrong.
I posted the code in the attachments.
Out of the Garry's Mod business.

Offline ULXGmodFan

  • Newbie
  • *
  • Posts: 28
  • Karma: 0
Re: jail tp to coördinates
« Reply #10 on: June 08, 2014, 01:13:25 AM »
Here's how I would go about doing it:
1. Create a blank data file to put your vector in
2. Hook initialize and read the file using util.StringToType (after you check if there is anything in it) and save that as a global vector
3. Create a ulx command to write a vector to that file using util.TypeToString (Have a function in it to refresh the global vector if you overwrite it)
4. Copy jailtp but instead of sending it to the position where you are looking, send it to the global vector instead.
I have now idea how to handel util.stringtype and all that stuff, lol, blank textfile? shold I call it lua or addon or? Man I wish i could be better at moddding like this
Here's what I came up with, I haven't tested it, so tell me if anything goes wrong.
I posted the code in the attachments.
Thganks, I will try this, put it in addons?


Edit: Thanks Neku, I understand your file.  Looks like other addons I have. So it just overwrites the existing one? On what line do I add the vector coordinates?


Oh and one more thing, should I remove the space in the file name before I put in addons? Are change the space for an underscore?
« Last Edit: June 08, 2014, 01:25:04 AM by ULXGmodFan »

Offline ULXGmodFan

  • Newbie
  • *
  • Posts: 28
  • Karma: 0
Re: jail tp to coördinates
« Reply #11 on: June 08, 2014, 01:31:56 AM »
Oh awesome! You added it to the menu. Yes it looks very clear and easy and handy the jailpos in the menu, but if I click it and then try to teleport it says that the map has no jail pos set.


But what you've done is EXACTLY what I needed, many thanks, if this works it should be in ULX standard

Offline Neku

  • Hero Member
  • *****
  • Posts: 549
  • Karma: 27
Re: jail tp to coördinates
« Reply #12 on: June 08, 2014, 01:56:11 AM »
Oh awesome! You added it to the menu. Yes it looks very clear and easy and handy the jailpos in the menu, but if I click it and then try to teleport it says that the map has no jail pos set.


But what you've done is EXACTLY what I needed, many thanks, if this works it should be in ULX standard

There's a command to set the jail position at your current location by the way.
Out of the Garry's Mod business.

Offline ULXGmodFan

  • Newbie
  • *
  • Posts: 28
  • Karma: 0
Re: jail tp to coördinates
« Reply #13 on: June 08, 2014, 02:02:21 AM »
Which is? I tried with rcon ulx jailpos "coordinates copied from getpos"

It would be awesome if it works in the menu too.

Thanks alot

Offline Neku

  • Hero Member
  • *****
  • Posts: 549
  • Karma: 27
Re: jail tp to coördinates
« Reply #14 on: June 08, 2014, 02:04:33 AM »
It should just be !jailpos.
There aren't any parameters for it, just use it and it will set a jailtp position for that specific map.

Please note: jailpos is not usable in rcon. And jailpos requires superadmin or an "equivalent".
« Last Edit: June 08, 2014, 02:12:30 AM by Neku »
Out of the Garry's Mod business.