General > Developers Corner

ULX Commands

(1/6) > >>

Aaron113:
Can I have an example of how to create an advanced ULX command?  (Logging, prints in chat, every argument)


I have been working on ULX commands lately and it would be nice to know how some of this works.  I have no been able to use logString or get it to print into chat without using ULib.tsayColor() or filex.Append().

JamminR:
Though long and drawn out, I did a article comparing old to new ULX command structure a while back.
Maybe it can help you a bit.
http://forums.ulyssesmod.net/index.php/topic,4464.0.html
It's quite heavily commented in the code examples.

There's also the docs for ULib, which of course, those code examples use much of for the commands.
http://www.ulyssesmod.net/docs

Aaron113:
Mind explaining the logging part to me?

--- Code: ---explode:logString( "#1s exploded #2s with #3i damage in a #4i radius blast area" )
--- End code ---


Whats with the s changing to an i?

JamminR:
s = string
i = integer
There are others I think. I forget what they are.
Megiddo/Stickly Man, others around here who have taken formal coding classes can probably tell you the name of that style of string/variable substitution.
I've seen it used in other scripting languages when it comes to string output.
Megiddo used it (to much less extent) in older ULX string manipulation. Was usually #T for target.

In relation to current (SVN) ULib command objects and that 'rocket' example,
#1 is (always?) person who ran the command.
2,3,4... equals each additional "addparam" value.
#2s (string) in that example is the player(s) that the command was performed on.
#3i (integer) is set as damag.
#4i (integer) is radius.
In the actual log command, you could change it to " with a #4i radius and #3i damage".
Those numbers don't have to be in order in the logString command.
They just have to match what parameter order you give the command object.

Megiddo:
You're right on JamminR. It's just a slight variation on string.format().

Navigation

[0] Message Index

[#] Next page

Go to full version