To use a command normally entered in the client, use printf(“issue 1 1[output string]”) followed by fflush(stdout). printf writes the output string in stdout, which is read by the client and interpreted. fflush(stdout) flushes or clears stdout1), readying it for more data.
An explanation of “issue 1 1 ” can be found here, in an introduction to scripting overall. Essentially, the first integer is the number of times to repeat an action. For debugging and information purposes, it's generally a good idea to leave it as 1 and create a loop in C++. The second 1 should always be set as 1.
Example:
#include <cstdio> int main(){ printf("issue 1 1 use_skill praying"); fflush(stdout); return 0; }
This would make the character pray once.
To write to the screen, use printf(“[output string]”) followed by fflush(stdout). printf writes the output string in stdout, which is read by the client and interpreted. fflush(stdout) flushes or clears stdout2), readying it for more data.
Example:
#include <cstdio> int main(){ printf("draw 4 Hello world\n"); fflush(stdout); return 0; }
This would return [color=#FF0000]Hello world[/color].
There are several ways to achieve this.
printf("draw [number] [string]");
draw allows you to output data to the client's screen in several different colors. draw should almost be used when debugging or outputting script data to the user, as the majority of the other output options use the server's chat features.
draw Colors | ||||
---|---|---|---|---|
# | color | # | color | |
1 | black (#000000) | 7 | light green (#2E8B57) | |
2 | dark blue (#000080) | 8 | very light green (#8FBC8F) | |
3 | red (#FF0000) | 9 | grey (#7F7F7F) | |
4 | dark yellow (#FFA500) | 10 | brown (#A0522D) | |
5 | light blue (#1E90FF) | 11 | yellow (#FFD700) | |
6 | orange (#EE7600) | 12 | tan (#F0E68C) |
This was written on a Linux machine. I have yet to run Crossfire on Windows, but I assume the syntax for coding will be the same. Running the scripts, on the other hand, might not be.