ULX

Author Topic: Be cloak when noclipping ?  (Read 13176 times)

0 Members and 4 Guests are viewing this topic.

Offline encestralz

  • Newbie
  • *
  • Posts: 4
  • Karma: 0
Be cloak when noclipping ?
« on: May 08, 2016, 11:27:57 AM »
Hi !

I want to cloak people who are in noclip mode, with that they will be able to see RP scenes without disturbing players !

I know it's possible, it was like that when I was moderator on another server, I press V and I can fly and be invisible and when I have to talk with a player, I press V and I'm not flying and I'm visible, I want to do that on my own server.

I already searched for that here and on the DarkRP's forum, but found nothing...

Sorry for my bad English !

Hope you have the solution !
« Last Edit: May 08, 2016, 11:32:07 AM by encestralz »

Offline Bytewave

  • Respected Community Member
  • Hero Member
  • *****
  • Posts: 718
  • Karma: 116
  • :)
    • My Homepage
Re: Be cloak when noclipping ?
« Reply #1 on: May 08, 2016, 12:44:30 PM »
Code: [Select]
bind v "ulx noclip;ulx cloak"?
bw81@ulysses-forums ~ % whoami
Homepage

Offline MrPresident

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 2728
  • Karma: 430
    • |G4P| Gman4President
Re: Be cloak when noclipping ?
« Reply #2 on: May 08, 2016, 02:23:12 PM »
Isn't that what ghost mode does?

Offline encestralz

  • Newbie
  • *
  • Posts: 4
  • Karma: 0
Re: Be cloak when noclipping ?
« Reply #3 on: May 09, 2016, 08:51:34 AM »
Code: [Select]
bind v "ulx noclip;ulx cloak"?
That work, but when I wan't te return in "normal mode" I'm not flying anymore but still invisible :/
And It's telling this message : "You cloaked Yourself by amount 0"

Isn't that what ghost mode does?
What is Ghost Mode ? How enable that ?

The simple bind on the old RP server was "Bind v "ulx noclip" and with that I was able to fly and be invisible or walk and be visible when I want ! :)

Thanks for you help, waiting for other solutions

Offline MrPresident

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 2728
  • Karma: 430
    • |G4P| Gman4President
Re: Be cloak when noclipping ?
« Reply #4 on: May 09, 2016, 03:38:41 PM »
What is Ghost Mode ? How enable that ?

Bahaha.. It would seem we removed ulx ghost a couple *five* years ago.

But yes... when it did exist, it essentially gave you noclip and made you invisible.

Offline iViscosity

  • Respected Community Member
  • Hero Member
  • *****
  • Posts: 803
  • Karma: 58
Re: Be cloak when noclipping ?
« Reply #5 on: May 09, 2016, 06:00:57 PM »
Ulx uncloak.
I'm iViscosity. I like gaming and programming. Need some help? Shoot me PM.

Offline roastchicken

  • Respected Community Member
  • Sr. Member
  • *****
  • Posts: 476
  • Karma: 84
  • I write code
Re: Be cloak when noclipping ?
« Reply #6 on: May 09, 2016, 08:54:37 PM »
Ulx uncloak.

Yes, but then you need two separate binds for cloaking/uncloaking.

encestralz, if you know lua then I suggest you poke around garrysmod/addons/ulx/lua/ulx/modules/sh/fun.lua and garrysmod/addons/ulx/lua/ulx/modules/sh/util.lua files (and the ulx.cloak & ulx.noclip functions within) to see how noclip and cloak work and then combine them into one command.

Alternatively you could just call ulx.cloak() and ulx.noclip() from your own command.
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 iViscosity

  • Respected Community Member
  • Hero Member
  • *****
  • Posts: 803
  • Karma: 58
Re: Be cloak when noclipping ?
« Reply #7 on: May 10, 2016, 04:30:24 AM »
Yes, but then you need two separate binds for cloaking/uncloaking.

Do you think there would be a way to use a togglebind?
I'm iViscosity. I like gaming and programming. Need some help? Shoot me PM.

Offline roastchicken

  • Respected Community Member
  • Sr. Member
  • *****
  • Posts: 476
  • Karma: 84
  • I write code
Re: Be cloak when noclipping ?
« Reply #8 on: May 10, 2016, 04:54:24 AM »
Do you think there would be a way to use a togglebind?

Can't say I've ever heard of that.

edit:

After a quick search I've found out what a togglebind is (I think), and yes, it seems like this would work for this occasion.

Taking inspiration from the ulx ghost command that was taken from us too soon (RIP ulx ghost), here are the commands you need in order to make a togglebind to toggle noclip and cloak:

Code: [Select]
alias Ghoster GhostMe
alias GhostMe "ulx noclip 1; ulx cloak; alias Ghoster UnGhostMe"
alias UnGhostMe "ulx noclip 0; ulx uncloak; alias Ghoster GhostMe"
bind "v" Ghoster

This is untested, but should work. I don't remember if aliases get saved between game restarts, so you might want to add this to <steam-install-dir>/SteamApps/common/GarrysMod/garrysmod/cfg/autoexec.cfg so it's there every time you open the game.
« Last Edit: May 10, 2016, 05:08:15 AM by roastchicken »
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 encestralz

  • Newbie
  • *
  • Posts: 4
  • Karma: 0
Re: Be cloak when noclipping ?
« Reply #9 on: May 10, 2016, 12:04:25 PM »
Bahaha.. It would seem we removed ulx ghost a couple *five* years ago.

But yes... when it did exist, it essentially gave you noclip and made you invisible.

I dont know how, but I think the server where I was moderator get this command with ulx noclip, I think he took the old ghostmode code and put it in the noclip code, because when we push "v" to quickly after a respawn, we were a real ghost, I'll try to get the old ghostmode code !

Yes, but then you need two separate binds for cloaking/uncloaking.

encestralz, if you know lua then I suggest you poke around garrysmod/addons/ulx/lua/ulx/modules/sh/fun.lua and garrysmod/addons/ulx/lua/ulx/modules/sh/util.lua files (and the ulx.cloak & ulx.noclip functions within) to see how noclip and cloak work and then combine them into one command.

Alternatively you could just call ulx.cloak() and ulx.noclip() from your own command.

I'll try it, but i'm not really good in LUA :/

Can't say I've ever heard of that.

edit:

After a quick search I've found out what a togglebind is (I think), and yes, it seems like this would work for this occasion.

Taking inspiration from the ulx ghost command that was taken from us too soon (RIP ulx ghost), here are the commands you need in order to make a togglebind to toggle noclip and cloak:

Code: [Select]
alias Ghoster GhostMe
alias GhostMe "ulx noclip 1; ulx cloak; alias Ghoster UnGhostMe"
alias UnGhostMe "ulx noclip 0; ulx uncloak; alias Ghoster GhostMe"
bind "v" Ghoster

This is untested, but should work. I don't remember if aliases get saved between game restarts, so you might want to add this to <steam-install-dir>/SteamApps/common/GarrysMod/garrysmod/cfg/autoexec.cfg so it's there every time you open the game.

That work, but I have to reset that anytime, I think that will be the last option if create a new command don't work, I just want to get easy bind for my staff ;)

Thanks for your help !

Offline roastchicken

  • Respected Community Member
  • Sr. Member
  • *****
  • Posts: 476
  • Karma: 84
  • I write code
Re: Be cloak when noclipping ?
« Reply #10 on: May 10, 2016, 12:09:24 PM »
You might have misunderstood me; there is a way to make it so that aliases won't be reset. Just add them to <steam-install-dir>/SteamApps/common/GarrysMod/garrysmod/cfg/autoexec.cfg and they'll be persistent. However if this is something you want for all of your staff, I think it's better to create a command for that. Of course, that's a bit difficult if you don't know lua.
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 encestralz

  • Newbie
  • *
  • Posts: 4
  • Karma: 0
Re: Be cloak when noclipping ?
« Reply #11 on: May 10, 2016, 12:12:07 PM »
You might have misunderstood me; there is a way to make it so that aliases won't be reset. Just add them to <steam-install-dir>/SteamApps/common/GarrysMod/garrysmod/cfg/autoexec.cfg and they'll be persistent. However if this is something you want for all of your staff, I think it's better to create a command for that. Of course, that's a bit difficult if you don't know lua.

Yeah but everyone need to put the aliases in their local Gmod installation ?

I'll try first to get the old Ghostmode code, I will see what I'm getting
« Last Edit: May 10, 2016, 12:16:26 PM by encestralz »

Offline iViscosity

  • Respected Community Member
  • Hero Member
  • *****
  • Posts: 803
  • Karma: 58
Re: Be cloak when noclipping ?
« Reply #12 on: May 10, 2016, 02:35:17 PM »
I think the easiest way to do this would be making a command in itself. Something along the lines of: when I type this then this should happen, if it's already active and I type that then this will happen.

If you get the logic down and do a bit of research on LUA, you could probably figure it out. Remember, we are here to help you, but most people would rather you learn how to do it yourself instead of just giving you the code.

There are some helpful functions that may help you though:
http://wiki.garrysmod.com/page/Player/GodEnable
http://wiki.garrysmod.com/page/Player/GodDisable
http://wiki.garrysmod.com/page/Entity/SetMoveType
http://ulyssesmod.net/docs/files/lua/ulib/server/player-lua.html#invisible

If you have an understanding of these, you could probably make something that would work. Good luck!

Note: If you can't figure it out, I suppose I could likely help you out, but at least try first.
« Last Edit: May 10, 2016, 02:38:53 PM by Masterbinkie »
I'm iViscosity. I like gaming and programming. Need some help? Shoot me PM.

Offline roastchicken

  • Respected Community Member
  • Sr. Member
  • *****
  • Posts: 476
  • Karma: 84
  • I write code
Re: Be cloak when noclipping ?
« Reply #13 on: May 10, 2016, 03:03:07 PM »
I don't think anyone should dive into creating a ULX command if they don't know the basics of lua. I think encestralz's best bet is to use the old ulx ghost command.
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 JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: Be cloak when noclipping ?
« Reply #14 on: May 10, 2016, 03:18:07 PM »
RoastChicken, but but but, our old ghost command isn't written for our newer ULib command API.
Sure, it could be converted by us experienced folks, but, the new ones trying to learn ULX and even Lua would be challenged even more.
Code: [Select]
local function doGhost( ply )
if not ply.ghost then return end
local dTime = FrameTime()
local speed = 500
local upspeed = 200

if ply:KeyDown( IN_FORWARD ) then
ply:SetPos( ply:GetPos() + ply:GetForward() * (speed*dTime) )
elseif ply:KeyDown( IN_BACK ) then
ply:SetPos( ply:GetPos() + ply:GetForward() * (speed*dTime*-1) )
end

if ply:KeyDown( IN_MOVERIGHT ) then
ply:SetPos( ply:GetPos() + ply:GetRight() * (speed*dTime) )
elseif ply:KeyDown( IN_MOVELEFT ) then
ply:SetPos( ply:GetPos() + ply:GetRight() * (speed*dTime*-1) )
end

if ply:KeyDown( IN_JUMP ) then
ply:SetPos( ply:GetPos() + ply:GetUp() * (upspeed*dTime) )
elseif ply:KeyDown( IN_DUCK ) then
ply:SetPos( ply:GetPos() + ply:GetUp() * (upspeed*dTime*-1) )
end
end

function ulx.cc_ghost( ply, command, argv, args )
local targets
if #argv < 1 then
if not ply:IsValid() then
Msg( "You have no physical body to ghost.\n" )
return
end
targets = { ply }
else
local err
targets, err = ULib.getUsers( argv[ 1 ], _, true, ply ) -- Enable keywords
if not targets then
ULib.tsay( ply, err, true )
return
end
end

for _, v in ipairs( targets ) do
if v:InVehicle() then
v:ExitVehicle()
end

if ulx.getExclusive( v, ply ) then
ULib.tsay( ply, ulx.getExclusive( v, ply ), true )
else
v:SetMoveType( MOVETYPE_NONE )
v:SetNotSolid( true )
v:GodEnable()
ULib.invisible( v, true )
v.ghost = true
ulx.setExclusive( v, "ghosted" )

-- This is a self-removing think for ghosts. When there's no more ghosts, it dies.
local function ghostThink()
local remove = true
local players = player.GetAll()
for _, player in ipairs( players ) do
if player.ghost then
doGhost( player )
remove = false
end
end
if remove then
hook.Remove( "Think", "ULXGhostThink" )
end
end
hook.Add( "Think", "ULXGhostThink", ghostThink )

ulx.logUserAct( ply, v, "#A ghosted #T", true )
end
end
end
ulx.concommand( "ghost", ulx.cc_ghost, " - Ghosts you.", ULib.ACCESS_ADMIN, "!ghost", true, ulx.ID_HELP )

function ulx.cc_unghost( ply, command, argv, args )
local targets
if #argv < 1 then
if not ply:IsValid() then
Msg( "You have no physical body to unghost.\n" )
return
end
targets = { ply }
else
local err
targets, err = ULib.getUsers( argv[ 1 ], _, true, ply ) -- Enable keywords
if not targets then
ULib.tsay( ply, err, true )
return
end
end

for _, v in ipairs( targets ) do
if v:InVehicle() then
v:ExitVehicle()
end

v:SetMoveType( MOVETYPE_WALK )
v:SetNotSolid( false )
v:GodDisable()
ULib.invisible( v, false )
v.ghost = nil
ulx.clearExclusive( v )

ulx.logUserAct( ply, v, "#A unghosted #T", true )
end
end
ulx.concommand( "unghost", ulx.cc_unghost, " - Unghosts you.", ULib.ACCESS_ADMIN, "!unghost", true, ulx.ID_HELP )

To those who aren't familiar with current ULib and ULX code API and styles, the above WILL NOT WORK "as is".
I only post it as reference.

Creating new command using ulx.cloak() and ulx.ghost(), as stated previously by someone else in this topic, would be MUCH simpler to do.
(I'm not even sure why Megiddo made this ghost the way he did, but I'm sure at the time it was an awesome reason)
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming