General > Developers Corner
ulx asay
JamminR:
Other than you keep changing up variables that may or may not be defined in the rest of the script, I really don't kow.
See this. Untested, but should work in theory, if it were replacing the original asay command in the original chat.lua file (becuase there's other setup of variables not included in this example)
I've commented the area that changed (some lines are still original, but commented because lines changed after)
--- Code: ---function ulx.asay( calling_ply, message )
local format
local me = "/me "
if message:sub( 1, me:len() ) == me then -- test if person used "@ /me <action>"
if ULib.ucl.query ( calling_ply, seeasayAccess ) == true then -- test if calling player has (previously defined) seeasayAccess
format = "(ADMINS) *** #P #s" -- player had it, they're an "admin" (or at least have access), do normal
else -- player isn't an "admin" (no seeasay)
format = "(ADMINS REPORT) *** #P #s" -- therefore player is making report
end -- end of checking if calling player can see asay
message = message:sub( me:len() + 1 ) -- change of message to remove "/me" if calling player used it
else -- end of "/me" replacement, they didn't use /me, use normal non-action formatting
if ULib.ucl.query ( calling_ply, seeasayAccess ) == true then -- test if calling player has (previously defined) seeasayAccess
format = "#P to admins: #s" -- player had it, they're an "admin" (or at least have access), do normal
else -- player isn't an "admin" (no seeasay)
format = "#P ADMINS REPORT: #s" -- therefore player is making report
end -- end of checking if calling player can see asay
end -- end of checking if player used /me and formatting as such or not
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, message )
end
--- End code ---
Sweepyoface:
Even that exact code doesn't work. It goes to ADMINS REPORT no matter if I have access to seeasay or not. That's odd..
Megiddo:
Try debugging your code -- put print statements between statements with the values of the variables so you can see what's going on.
JamminR:
You keep saying 'I' as though your testing instead of having a regular player.
Besides what Megiddo suggests,
1) make sure the group you are in isn't inheriting another group that has it.
2) Make sure you aren't testing in listen server or single player (You have access to all in that manner).
Make sure you've restarted server after editing code (A) again, we're not recommending you even edit, but, if you just must try yourself then (B) we recommend not having server even running when editing code)
And, last, make sure your editing your server's code and not your local (unless of course it's listen server, but then again, see 2).
Navigation
[0] Message Index
[*] Previous page
Go to full version