Author Topic: ULX Chat Coding Problem. Help!  (Read 4567 times)

0 Members and 1 Guest are viewing this topic.

Offline battlerat

  • Newbie
  • *
  • Posts: 3
  • Karma: 0
ULX Chat Coding Problem. Help!
« on: July 30, 2012, 01:05:30 PM »
Code: [Select]
local seeasayAccess = "ulx seeasay"
if SERVER then ULib.ucl.registerAccess( seeasayAccess, ULib.ACCESS_OPERATOR, "Ability to see 'ulx asay'", "Other" ) end -- Give operators access to see asays echoes by default

function ulx.asay( calling_ply, message )
local format
local me = "/me "
if message:sub( 1, me:len() ) == me then
format = "(ADMINS) *** #P " .. message:sub( me:len() + 1 )
else
format = "#P to admins: " .. message
end

local players = player.GetAll()
for i=#players, 1, -1 do
local v = players[ i ]
if not ULib.ucl.query( v, seeasayAccess ) and v ~= calling_ply then -- Calling player always gets to see the echo
table.remove( players, i )
end
end

ulx.fancyLog( players, format, calling_ply )
end
local asay = ulx.command( CATEGORY_NAME, "ulx asay", ulx.asay, "@", true, true )
asay:addParam{ type=ULib.cmds.StringArg, hint="message", ULib.cmds.takeRestOfLine }
asay:defaultAccess( ULib.ACCESS_ALL )
asay:help( "Send a message to currently connected admins." )


This is the code i have in ULX. The lua file is chat. This code is used for the admin chat "@" .
When a non admin player in game uses the @ <message> command it says <player> to admins: <message>
But, when an admin does the @ <massage> command it does the same thing... even though in the code it says that an admin -admin convo should be (ADMINS) <player>: <Messsage>

I just wanted to know, is there something wrong with my code?
If you have the code please help me. Thanks

Offline Megiddo

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 6214
  • Karma: 394
  • Project Lead
Re: ULX Chat Coding Problem. Help!
« Reply #1 on: July 30, 2012, 04:05:48 PM »
I don't see any changes from default ULX that would make this "your code"? Did you post the wrong code? Otherwise, this default code is acting exactly as it should. It's only when you say "@/me blah blah" that it shows the "(ADMINS)" bit.
Experiencing God's grace one day at a time.

Offline battlerat

  • Newbie
  • *
  • Posts: 3
  • Karma: 0
Re: ULX Chat Coding Problem. Help!
« Reply #2 on: July 30, 2012, 04:35:31 PM »
This is not my code, it is a code in ulx.
BUT, I saw in a server which I was admin in that wen an admin did @ <message it said (ADMINS) <PLAYER>: <message>
and when a player did @ <message> it said <player> to ADMINS: <message>

I just want to know how I would change this code to where it would work that way...

Offline Megiddo

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 6214
  • Karma: 394
  • Project Lead
Re: ULX Chat Coding Problem. Help!
« Reply #3 on: July 30, 2012, 06:11:08 PM »
Why not just ask the admin of this server to share it with you?
Experiencing God's grace one day at a time.

Offline battlerat

  • Newbie
  • *
  • Posts: 3
  • Karma: 0
Re: ULX Chat Coding Problem. Help!
« Reply #4 on: July 31, 2012, 02:27:26 PM »
I did, and he did not want to share it with me...

Would you be able to help?

Offline MrPresident

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 2728
  • Karma: 430
    • |G4P| Gman4President
Re: ULX Chat Coding Problem. Help!
« Reply #5 on: July 31, 2012, 03:31:20 PM »
It literally only took a couple of lines of code to achieve this. Did you bother to even look at it to see if you could figure it out on your own? I understand not everyone can be masters of lua, but simple modifications should be within the capacity of understanding for anyone who wishes to run a decent server.

This is not a personal attack, but if you want to run a decent gmod server I highly highly suggest you learn some basic lua so that you can at a very minimum be able to modify and fix code that you find or download from other sources.

Code: [Select]
local seeasayAccess = "ulx seeasay"
if SERVER then ULib.ucl.registerAccess( seeasayAccess, ULib.ACCESS_OPERATOR, "Ability to see 'ulx asay'", "Other" ) end -- Give operators access to see asays echoes by default

function ulx.asay( calling_ply, message )
local format
local me = "/me "
if message:sub( 1, me:len() ) == me then
format = "(ADMINS) *** #P " .. message:sub( me:len() + 1 )
else
if calling_ply:IsAdmin() then
format = "#P to admins: " .. message
else
format = "(ADMINS) #P: " .. message
end

end

local players = player.GetAll()
for i=#players, 1, -1 do
local v = players[ i ]
if not ULib.ucl.query( v, seeasayAccess ) and v ~= calling_ply then -- Calling player always gets to see the echo
table.remove( players, i )
end
end

ulx.fancyLog( players, format, calling_ply )
end
local asay = ulx.command( CATEGORY_NAME, "ulx asay", ulx.asay, "@", true, true )
asay:addParam{ type=ULib.cmds.StringArg, hint="message", ULib.cmds.takeRestOfLine }
asay:defaultAccess( ULib.ACCESS_ALL )
asay:help( "Send a message to currently connected admins." )