• Print

Author Topic: Temporary Name Change? - Need Command Help  (Read 17502 times)

0 Members and 1 Guest are viewing this topic.

Offline Zoeo

  • Newbie
  • *
  • Posts: 15
  • Karma: 1
Temporary Name Change? - Need Command Help
« on: April 07, 2015, 10:23:16 am »
I have made a code that will allow a player to hide their admin/moderator status by placing them into a hidemod group (If using MySQL it can be modified to set them into a user/member group and upon rejoin their rank is given back) and then be able to use the commands in that group, unhide being one of them.  The code it'self works like a charm, but the one problem I am having is changing that persons name on the scoreboard temporarily without having to change it on Steam.

If anyone knows how to change a name on scoreboard it'd be amazing!

(Note: Not on DarkRP. I need it on TTT)

Offline Decicus

  • Hero Member
  • *****
  • Posts: 552
  • Karma: 81
    • Alex Thomassen
Re: Temporary Name Change? - Need Command Help
« Reply #1 on: April 07, 2015, 10:31:10 am »
Unless you modify the TTT scoreboard to override the normal Garry's Mod display name (which is via Steam, as you said), then this isn't possible.
Contact information:
E-mail: alex@thomassen.xyz.
You can also send a PM.

Offline Zoeo

  • Newbie
  • *
  • Posts: 15
  • Karma: 1
Re: Temporary Name Change? - Need Command Help
« Reply #2 on: April 07, 2015, 10:40:18 am »
Unless you modify the TTT scoreboard to override the normal Garry's Mod display name (which is via Steam, as you said), then this isn't possible.
If that is the case, would it be possible to remove the person's entire row from the scoreboard via ulx command and then just rejoin to add that row back?

Offline Decicus

  • Hero Member
  • *****
  • Posts: 552
  • Karma: 81
    • Alex Thomassen
Re: Temporary Name Change? - Need Command Help
« Reply #3 on: April 07, 2015, 10:55:06 am »
I don't think that's possible without modifying it either.
Contact information:
E-mail: alex@thomassen.xyz.
You can also send a PM.

Offline Aaron113

  • Hero Member
  • *****
  • Posts: 803
  • Karma: 102
Re: Temporary Name Change? - Need Command Help
« Reply #4 on: April 07, 2015, 10:57:15 am »
This would hide the name if you set ply.FakeName to a new name.  It will not however hide your group from anyone (especially if your group displays on the scoreboard).  An old gamemode I used to help with used this to hide staff from the public eye.
Code: Lua
  1. local META = FindMetaTable("Player")
  2.  
  3. local OldNick = META.Nick
  4.  
  5. function META:Nick()
  6.         return self.FakeName or OldNick(self)
  7. end

EDIT:  It will also not hide you from the status command.
« Last Edit: April 07, 2015, 10:59:59 am by Aaron113 »

Offline Zoeo

  • Newbie
  • *
  • Posts: 15
  • Karma: 1
Re: Temporary Name Change? - Need Command Help
« Reply #5 on: April 07, 2015, 11:42:35 am »
This would hide the name if you set ply.FakeName to a new name.  It will not however hide your group from anyone (especially if your group displays on the scoreboard).  An old gamemode I used to help with used this to hide staff from the public eye.
Code: Lua
  1. local META = FindMetaTable("Player")
  2.  
  3. local OldNick = META.Nick
  4.  
  5. function META:Nick()
  6.         return self.FakeName or OldNick(self)
  7. end

EDIT:  It will also not hide you from the status command.
The code runs correctly with the command (No errors unless I intentionally put something in to make it throw an error) but does not change the players name on the scoreboard.

I did however remove "or OldNick(self)" and it sent "[playername]<steamid>:changed their name to nil" which is quite interesting and maybe could lead to something?

EDIT: Well I found out what the whole "changed their name to" thing does, it changes what their in-game name is, like if I called it on a bot and the name was ThatGuy their name on scoreboard doesn't change but they are authenticated by the server as ThatGuy, so if you had to !slap or !slay them you would have to type ThatGuy to target them.
« Last Edit: April 07, 2015, 12:40:08 pm by Zoeo »

Offline Aaron113

  • Hero Member
  • *****
  • Posts: 803
  • Karma: 102
Re: Temporary Name Change? - Need Command Help
« Reply #6 on: April 07, 2015, 12:57:43 pm »
The code runs correctly with the command (No errors unless I intentionally put something in to make it throw an error) but does not change the players name on the scoreboard.

I did however remove "or OldNick(self)" and it sent "[playername]<steamid>:changed their name to nil" which is quite interesting and maybe could lead to something?

EDIT: Well I found out what the whole "changed their name to" thing does, it changes what their in-game name is, like if I called it on a bot and the name was ThatGuy their name on scoreboard doesn't change but they are authenticated by the server as ThatGuy, so if you had to !slap or !slay them you would have to type ThatGuy to target them.
Your scoreboard probably uses a different function to get the name.  This works perfectly for sandbox.  Perhaps try doing the same with Name()

EDIT:  Also, the name change in chat is probably a feature of ULX/ULib.
« Last Edit: April 07, 2015, 01:03:21 pm by Aaron113 »

Offline Zoeo

  • Newbie
  • *
  • Posts: 15
  • Karma: 1
Re: Temporary Name Change? - Need Command Help
« Reply #7 on: April 07, 2015, 02:07:09 pm »
Your scoreboard probably uses a different function to get the name.  This works perfectly for sandbox.  Perhaps try doing the same with Name()

EDIT:  Also, the name change in chat is probably a feature of ULX/ULib.
I tested it in sandbox and the same thing happened. The server is using the default scoreboard from TTT and sandbox, I also tested it in singleplayer with the exact same result.

Screenshot:


Here is a snipit of how I integrated it into my code:
Code: [Select]
else
if ran == 1 then
v:SetUserGroup( "member" )
end
if ran == 2 then
v:SetUserGroup( "user" )
end
function META:Nick()
return "AbsoluteAwesome" or OldNick(self)
end
end
The "If ran blah blah blah" stuff is for another part of the code.

What outputs in the server console:
Code: [Select]
Zoeo<> changed their name to AbsoluteAwesome
Bot01<BOT> changed their name to AbsoluteAwesome
(SILENT) AbsoluteAwesome Made AbsoluteAwesome go into Hiding.
ServerLog: [ULX] (SILENT) AbsoluteAwesome Made AbsoluteAwesome go into Hiding.
L 04/07/2015 - 16:17:20: [ULX] (SILENT) AbsoluteAwesome Made AbsoluteAwesome go into Hiding.

Making it return "name" is the only way for it to even make it change the target name, other wise it won't do anything.  But that also causes a really annoying bug where it changes the name of every player in the game to whatever is in the quotation marks.
« Last Edit: April 07, 2015, 02:11:08 pm by Zoeo »

Offline Aaron113

  • Hero Member
  • *****
  • Posts: 803
  • Karma: 102
Re: Temporary Name Change? - Need Command Help
« Reply #8 on: April 07, 2015, 03:20:44 pm »
You're only running the code on the server.  The client has no idea you changed the function.  That's what it looks like to me.  Just do the same on the client.

Offline Zoeo

  • Newbie
  • *
  • Posts: 15
  • Karma: 1
Re: Temporary Name Change? - Need Command Help
« Reply #9 on: April 08, 2015, 06:39:31 am »
You're only running the code on the server.  The client has no idea you changed the function.  That's what it looks like to me.  Just do the same on the client.
Great, now I just need to figure out how to do that right... I racked my brain all day yesterday and tried many different ways to accomplish it, but it didn't seem to want to work right X_X.  I added a lua file in a cl folder, like the ulx does for xgui and other things, it did call the function but if I use "self.newname" or something else to replace newname it won't do anything and will return the name as nil.  Another annoying thing is it will call the function as soon as the server starts, so that means if I take away the "self." and just put "newname" as soon as the server starts anyone who joins the server is named "newname".

I'm still learning Gmod Lua, so I don't know a whole lot about it, just basic basics, the fact that I even got it to change a player's group back to it's original state after being put into a new group baffles me.  And Google is of no help when it comes to something like this X_X.

Offline Aaron113

  • Hero Member
  • *****
  • Posts: 803
  • Karma: 102
Re: Temporary Name Change? - Need Command Help
« Reply #10 on: April 08, 2015, 08:19:38 am »
Don't modify this code at all and run it shared.  Then all you have to do is set the FakeName from the server.  (I'll let you figure that one out)  Your problem with setting everyone's name came from you using a string in replace of self.FakeName.  A string will always exists, so it will always go to the string instead of calling the OldNick function.
Code: Lua
  1. local META = FindMetaTable("Player")
  2.  
  3. local OldNick = META.Nick
  4.  
  5. function META:Nick()
  6.         return self:GetNWString("FakeName", false) or OldNick(self)
  7. end

Offline Zoeo

  • Newbie
  • *
  • Posts: 15
  • Karma: 1
Re: Temporary Name Change? - Need Command Help
« Reply #11 on: April 08, 2015, 10:59:07 am »
Don't modify this code at all and run it shared.  Then all you have to do is set the FakeName from the server.  (I'll let you figure that one out)  Your problem with setting everyone's name came from you using a string in replace of self.FakeName.  A string will always exists, so it will always go to the string instead of calling the OldNick function.
Code: Lua
  1. local META = FindMetaTable("Player")
  2.  
  3. local OldNick = META.Nick
  4.  
  5. function META:Nick()
  6.         return self:GetNWString("FakeName", false) or OldNick(self)
  7. end
YOU sir, are an amazing person. It works fully functional with my command and updates the name.

All that's left is to make a randomizer to pick from a pool of random names and it will be complete, I thank you wholeheartedly because without your help I would have never been able to fix it xD

Offline Aaron113

  • Hero Member
  • *****
  • Posts: 803
  • Karma: 102
Re: Temporary Name Change? - Need Command Help
« Reply #12 on: April 08, 2015, 11:32:17 am »
If I were you, I would let the user set their fake name or have the option to at least.  Trust me people will pick up on the status command fast enough, if you have a limited number of fake names, they will catch on even faster.

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: Temporary Name Change? - Need Command Help
« Reply #13 on: April 08, 2015, 06:37:55 pm »
Aaron, make a ulx release out of fake name.
Sure, it's cute, fun and tiny (and over-rides standard GM data), but, it's something many might look for.
I've always disliked since Gmod went 'steam name only'
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline Aaron113

  • Hero Member
  • *****
  • Posts: 803
  • Karma: 102
Re: Temporary Name Change? - Need Command Help
« Reply #14 on: April 08, 2015, 07:19:10 pm »
Aaron, make a ulx release out of fake name.
Sure, it's cute, fun and tiny (and over-rides standard GM data), but, it's something many might look for.
I've always disliked since Gmod went 'steam name only'
Wow, hahaha.... I was seriously considering that already with this topic.  I could honestly whip it out really fast.  The only trouble I would have is setting a fake temporary group.  I would have to look into that a bit.

  • Print