General > Developers Corner

How does fancyLogAdmin work?


I'm making some ULX commands and I've been having trouble with is fancyLogAdmin... how exactly do you use it? I've been guessing based off of what other ULX commands do. Some commands do it really simple, like whip:

--- Code: ---ulx.fancyLogAdmin( calling_ply, "#A whipped #T #i times with #i damage", affected_plys, times, dmg )
--- End code ---
But then you look at something like the ban command and it's just... really weird. Mostly the last half:

--- Code: ---ulx.fancyLogAdmin( calling_ply, str, target_ply, minutes ~= 0 and ULib.secondsToStringTime( minutes * 60 ) or reason, reason )
--- End code ---

Is there a reference on how to use it? I'm still not 100% on lua so I could be missing some concept that makes this function super obvious to people that understand it.

There's a tiny bit of reference.

Summarized, FancyLogAdmin can be passed various strings that can then be filled in with table info.
Depending on what the first bits of information are, it deciphers what to output using normal Lua capability.
That example within ban you're having trouble with is evaluated mid-process. Break it down.
Looking closer, you'll see that what you're confused about is actually being turned into most of your example you somewhat understand - "#A banned #T " (permanently) OR (for #S) " in lines 92 to 95 of the ban command.

str becomes the string from 92 to 95.
minutes ~= 0 and ULib.secondsToStringTime (minutes = 60) becomes a string of the number someone typed, IF someone typed a number else it's set to default ban and the reason is used,  else the time and the reason are passed.
If someone typed a number, the ban command then uses that number to replace #S in what becomes "for #S".

I could see as a beginner in Lua how that might be confusing.
Though there is no 'indepth' reference, you may find the function ulx.fancyLogAdmin code helpful.


[0] Message Index

Go to full version