• Print

Author Topic: Ulx Silent Echo  (Read 6803 times)

0 Members and 1 Guest are viewing this topic.

Offline Toxic_Terrorists

  • Newbie
  • *
  • Posts: 17
  • Karma: 0
Ulx Silent Echo
« on: February 28, 2015, 08:34:30 am »
Is there a way to change a ulx Silent echo to show up only for the person that did the command?

The command in question is:
Code: [Select]
if (SERVER) then

util.AddNetworkString("target_ply")
    util.AddNetworkString("friendlist")

    net.Receive( "friendlist", function(len, ply)
            local friends = net.ReadTable()
            local friendstring = table.concat(  friends, ", " )
            ulx.fancyLogAdmin( nil, true,  "#T is friends with: #s ", ply, friendstring )
    end)
end
if CLIENT then
    net.Receive("friendlist", function()
                local friends = {}
                for k, v in pairs(player.GetAll()) do
                        if v:GetFriendStatus() == "friend" then
                            table.insert( friends, v:Nick() )
                            end
                end
                net.Start("friendlist")
                   net.WriteTable(friends)
                net.SendToServer()
    end)
end


function ulx.listfriends(calling_ply, target_ply)

        net.Start("friendlist")
        net.Send(target_ply)
end
local listfriends = ulx.command("Essentials", "ulx listfriends", ulx.listfriends, "!friends",true)
listfriends:addParam{ type=ULib.cmds.PlayerArg }
listfriends:defaultAccess( ULib.ACCESS_ADMIN )
listfriends:help( "Check for friends playing on the server." )

Instead of:
            ulx.fancyLogAdmin( nil, true,  "#T is friends with: #s ", ply, friendstring )

Can it be changed to use:
            self.Owner:ChatPrint("")
« Last Edit: February 28, 2015, 08:48:47 am by Toxic_Terrorists »

Offline XxLMM13xX

  • Sr. Member
  • ****
  • Posts: 265
  • Karma: -51
  • New to lua development
    • Twitch
Re: Ulx Silent Echo
« Reply #1 on: March 02, 2015, 03:00:23 pm »
Did you try it? Did you get any errors if you did?

Offline Bytewave

  • Respected Community Member
  • Hero Member
  • *****
  • Posts: 718
  • Karma: 116
  • :)
    • My Homepage
Re: Ulx Silent Echo
« Reply #2 on: March 02, 2015, 08:29:35 pm »
It's just as simple as this:
Code: Lua
  1. calling_ply:ChatPrint(<message>)
Do that instead of FancyLogAdmin.
bw81@ulysses-forums ~ % whoami
Homepage

Offline Toxic_Terrorists

  • Newbie
  • *
  • Posts: 17
  • Karma: 0
Re: Ulx Silent Echo
« Reply #3 on: March 05, 2015, 12:54:18 pm »
That didn't work I tried:
Code: [Select]
calling_ply:ChatPrint( "#T is friends with: #s ", ply, friendstring )
and:
Code: [Select]
calling_ply:ChatPrint("#T is friends with: #s ")
Both didn't work

Offline Bytewave

  • Respected Community Member
  • Hero Member
  • *****
  • Posts: 718
  • Karma: 116
  • :)
    • My Homepage
Re: Ulx Silent Echo
« Reply #4 on: March 05, 2015, 04:59:28 pm »
That didn't work I tried:
Code: [Select]
calling_ply:ChatPrint( "#T is friends with: #s ", ply, friendstring )
and:
Code: [Select]
calling_ply:ChatPrint("#T is friends with: #s ")
Both didn't work

Because you're trying to pass proprietary formatting strings into a Garry's Mod vanilla function.

Try this:
Code: Lua
  1. name = target_ply:Nick()
  2. calling_ply:ChatPrint(string.format("%s is friends with %s", name, friendstring))
bw81@ulysses-forums ~ % whoami
Homepage

Offline Toxic_Terrorists

  • Newbie
  • *
  • Posts: 17
  • Karma: 0
Re: Ulx Silent Echo
« Reply #5 on: March 06, 2015, 07:44:40 pm »
I replaced the ulx fancy log with that and it didn't fix the issue. It still only showed with Silent Echos.

Offline Bytewave

  • Respected Community Member
  • Hero Member
  • *****
  • Posts: 718
  • Karma: 116
  • :)
    • My Homepage
Re: Ulx Silent Echo
« Reply #6 on: March 06, 2015, 07:55:06 pm »
I replaced the ulx fancy log with that and it didn't fix the issue. It still only showed with Silent Echos.
Not sure what you're talking about there. Mind explaining a little bit further?

Also, one little critique:
Code: Lua
  1. net.Start("friendlist")
  2.     net.WriteTable(friends)
  3. net.SendToServer()
  4.  
Why network the entire table when you can have the client do it for you?

Code: Lua
  1. if CLIENT then
  2.     -- ...
  3.     local friendstring = table.concat(  friends, ", " )
  4.  
  5.     net.Start("friendlist")
  6.         net.WriteString(friendstring)
  7.     net.SendToServer()
  8. end
  9.  
then on the client, just ReadString to get the returned string.
bw81@ulysses-forums ~ % whoami
Homepage

Offline Toxic_Terrorists

  • Newbie
  • *
  • Posts: 17
  • Karma: 0
Re: Ulx Silent Echo
« Reply #7 on: June 09, 2015, 01:52:08 pm »
Because you're trying to pass proprietary formatting strings into a Garry's Mod vanilla function.

Try this:
Code: Lua
  1. name = target_ply:Nick()
  2. calling_ply:ChatPrint(string.format("%s is friends with %s", name, friendstring))

Alright so I tried that and got this error:
Code: [Select]
Lua Error: [ERROR] addons/ulx/lua/ulx/modules/sh/essentials.lua:47: attempt to index global 'target_ply' (a nil value) 1. func - addons/ulx/lua/ulx/modules/sh/essentials.lua:47 2. unknown - lua/includes/extensions/net.lua:32
Here is the code that I am using:
Code: [Select]
if (SERVER) then

util.AddNetworkString("target_ply")
    util.AddNetworkString("friendlist")

    net.Receive( "friendlist", function(len, ply)
            local friends = net.ReadTable()
            local friendstring = table.concat(  friends, ", " )
name = target_ply:Nick()
calling_ply:ChatPrint(string.format("%s is friends with %s", name, friendstring))
            ulx.fancyLogAdmin( nil, true,  "#T is friends with: #s ", ply, friendstring )
    end)
end
if CLIENT then
    net.Receive("friendlist", function()
                local friends = {}
                for k, v in pairs(player.GetAll()) do
                        if v:GetFriendStatus() == "friend" then
                            table.insert( friends, v:Nick() )
                            end
                end
                net.Start("friendlist")
                   net.WriteTable(friends)
                net.SendToServer()
    end)
end


function ulx.listfriends(calling_ply, target_ply)

        net.Start("friendlist")
        net.Send(target_ply)
end
local listfriends = ulx.command("Essentials", "ulx listfriends", ulx.listfriends, "!friends",true)
listfriends:addParam{ type=ULib.cmds.PlayerArg }
listfriends:defaultAccess( ULib.ACCESS_ADMIN )
listfriends:help( "Check for friends playing on the server." )

I am also unsure exactly what you meant by your last message. I'm not the best at coding with ULX. Sorry for the noobishness.

  • Print