Skip to content

Commit d4a7fd5

Browse files
authored
Merge pull request #25 from Y-Less/Branch_printf
Try include console.inc
2 parents 6124e82 + 775cb4f commit d4a7fd5

File tree

2 files changed

+64
-58
lines changed

2 files changed

+64
-58
lines changed

a_npc.inc

Lines changed: 32 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,7 @@ public const SAMP_INCLUDES_VERSION = 0x037030;
176176
#include <file>
177177
#include <time>
178178
#include <datagram>
179+
#tryinclude <console>
179180

180181
/*
181182
@@ -234,35 +235,37 @@ open.mp releases can use `A` as the first digit.
234235

235236
// Util
236237

237-
/// <summary>Prints a string to the server console (not in-game chat) and logs (server_log.txt).</summary>
238-
/// <param name="string">The string to print</param>
239-
/// <seealso name="printf"/>
240-
native print(const string[]);
241-
242-
/// <summary>Outputs a formatted string on the console (the server window, not the in-game chat).</summary>
243-
/// <param name="format">The format string</param>
244-
/// <param name="">Indefinite number of arguments of any tag</param>
245-
/// <seealso name="print"/>
246-
/// <seealso name="format"/>
247-
/// <remarks>The format string or its output should not exceed 1024 characters. Anything beyond that length can lead to a server to crash.</remarks>
248-
/// <remarks>This function doesn't support <a href="#strpack">packed</a> strings.</remarks>
249-
/// <remarks>
250-
/// <b>Format Specifiers:</b><p/>
251-
/// <ul>
252-
/// <li><b><c>%i</c></b> - integer (whole number)</li>
253-
/// <li><b><c>%d</c></b> - integer (whole number).</li>
254-
/// <li><b><c>%s</c></b> - string</li>
255-
/// <li><b><c>%f</c></b> - floating-point number (Float: tag)</li>
256-
/// <li><b><c>%c</c></b> - ASCII character</li>
257-
/// <li><b><c>%x</c></b> - hexadecimal number</li>
258-
/// <li><b><c>%b</c></b> - binary number</li>
259-
/// <li><b><c>%%</c></b> - literal <b><c>%</c></b></li>
260-
/// <li><b><c>%q</c></b> - escape a text for SQLite. (Added in <b>0.3.7 R2</b>)</li>
261-
/// </ul>
262-
/// </remarks>
263-
/// <remarks>The values for the placeholders follow in the exact same order as parameters in the call. For example, <b><c>"I am %i years old"</c></b> - the <b><c>%i</c></b> will be replaced with an Integer variable, which is the person's age.</remarks>
264-
/// <remarks>You may optionally put a number between the <b><c>%</c></b> and the letter of the placeholder code. This number indicates the field width; if the size of the parameter to print at the position of the placeholder is smaller than the field width, the field is expanded with spaces. To cut the number of decimal places beeing shown of a float, you can add <b><c>.&lt;max number&gt;</c></b> between the <b><c>%</c></b> and the <b><c>f</c></b>. (example: <b><c>%.2f</c></b>)</remarks>
265-
native printf(const format[], {Float,_}:...);
238+
#if !defined _console_included
239+
/// <summary>Prints a string to the server console (not in-game chat) and logs (server_log.txt).</summary>
240+
/// <param name="string">The string to print</param>
241+
/// <seealso name="printf"/>
242+
native print(const string[]);
243+
244+
/// <summary>Outputs a formatted string on the console (the server window, not the in-game chat).</summary>
245+
/// <param name="format">The format string</param>
246+
/// <param name="">Indefinite number of arguments of any tag</param>
247+
/// <seealso name="print"/>
248+
/// <seealso name="format"/>
249+
/// <remarks>The format string or its output should not exceed 1024 characters. Anything beyond that length can lead to a server to crash.</remarks>
250+
/// <remarks>This function doesn't support <a href="#strpack">packed</a> strings.</remarks>
251+
/// <remarks>
252+
/// <b>Format Specifiers:</b><p/>
253+
/// <ul>
254+
/// <li><b><c>%i</c></b> - integer (whole number)</li>
255+
/// <li><b><c>%d</c></b> - integer (whole number).</li>
256+
/// <li><b><c>%s</c></b> - string</li>
257+
/// <li><b><c>%f</c></b> - floating-point number (Float: tag)</li>
258+
/// <li><b><c>%c</c></b> - ASCII character</li>
259+
/// <li><b><c>%x</c></b> - hexadecimal number</li>
260+
/// <li><b><c>%b</c></b> - binary number</li>
261+
/// <li><b><c>%%</c></b> - literal <b><c>%</c></b></li>
262+
/// <li><b><c>%q</c></b> - escape a text for SQLite. (Added in <b>0.3.7 R2</b>)</li>
263+
/// </ul>
264+
/// </remarks>
265+
/// <remarks>The values for the placeholders follow in the exact same order as parameters in the call. For example, <b><c>"I am %i years old"</c></b> - the <b><c>%i</c></b> will be replaced with an Integer variable, which is the person's age.</remarks>
266+
/// <remarks>You may optionally put a number between the <b><c>%</c></b> and the letter of the placeholder code. This number indicates the field width; if the size of the parameter to print at the position of the placeholder is smaller than the field width, the field is expanded with spaces. To cut the number of decimal places beeing shown of a float, you can add <b><c>.&lt;max number&gt;</c></b> between the <b><c>%</c></b> and the <b><c>f</c></b>. (example: <b><c>%.2f</c></b>)</remarks>
267+
native printf(const format[], {Float,_}:...);
268+
#endif
266269

267270
/// <summary>Formats a string to include variables and other strings inside it.</summary>
268271
/// <param name="output">The string to output the result to</param>

a_samp.inc

Lines changed: 32 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,7 @@ public const SAMP_INCLUDES_VERSION = 0x037030;
267267
#include <file>
268268
#include <time>
269269
#include <datagram>
270+
#tryinclude <console>
270271
#include <a_players>
271272
#include <a_vehicles>
272273
#include <a_objects>
@@ -331,35 +332,37 @@ open.mp releases can use `A` as the first digit.
331332

332333
// Util
333334

334-
/// <summary>Prints a string to the server console (not in-game chat) and logs (server_log.txt).</summary>
335-
/// <param name="string">The string to print</param>
336-
/// <seealso name="printf"/>
337-
native print(const string[]);
338-
339-
/// <summary>Outputs a formatted string on the console (the server window, not the in-game chat).</summary>
340-
/// <param name="format">The format string</param>
341-
/// <param name="">Indefinite number of arguments of any tag</param>
342-
/// <seealso name="print"/>
343-
/// <seealso name="format"/>
344-
/// <remarks>The format string or its output should not exceed 1024 characters. Anything beyond that length can lead to a server to crash.</remarks>
345-
/// <remarks>This function doesn't support <a href="#strpack">packed</a> strings.</remarks>
346-
/// <remarks>
347-
/// <b>Format Specifiers:</b><p/>
348-
/// <ul>
349-
/// <li><b><c>%i</c></b> - integer (whole number)</li>
350-
/// <li><b><c>%d</c></b> - integer (whole number).</li>
351-
/// <li><b><c>%s</c></b> - string</li>
352-
/// <li><b><c>%f</c></b> - floating-point number (Float: tag)</li>
353-
/// <li><b><c>%c</c></b> - ASCII character</li>
354-
/// <li><b><c>%x</c></b> - hexadecimal number</li>
355-
/// <li><b><c>%b</c></b> - binary number</li>
356-
/// <li><b><c>%%</c></b> - literal <b><c>%</c></b></li>
357-
/// <li><b><c>%q</c></b> - escape a text for SQLite. (Added in <b>0.3.7 R2</b>)</li>
358-
/// </ul>
359-
/// </remarks>
360-
/// <remarks>The values for the placeholders follow in the exact same order as parameters in the call. For example, <b><c>"I am %i years old"</c></b> - the <b><c>%i</c></b> will be replaced with an Integer variable, which is the person's age.</remarks>
361-
/// <remarks>You may optionally put a number between the <b><c>%</c></b> and the letter of the placeholder code. This number indicates the field width; if the size of the parameter to print at the position of the placeholder is smaller than the field width, the field is expanded with spaces. To cut the number of decimal places beeing shown of a float, you can add <b><c>.&lt;max number&gt;</c></b> between the <b><c>%</c></b> and the <b><c>f</c></b>. (example: <b><c>%.2f</c></b>)</remarks>
362-
native printf(const format[], {Float,_}:...);
335+
#if !defined _console_included
336+
/// <summary>Prints a string to the server console (not in-game chat) and logs (server_log.txt).</summary>
337+
/// <param name="string">The string to print</param>
338+
/// <seealso name="printf"/>
339+
native print(const string[]);
340+
341+
/// <summary>Outputs a formatted string on the console (the server window, not the in-game chat).</summary>
342+
/// <param name="format">The format string</param>
343+
/// <param name="">Indefinite number of arguments of any tag</param>
344+
/// <seealso name="print"/>
345+
/// <seealso name="format"/>
346+
/// <remarks>The format string or its output should not exceed 1024 characters. Anything beyond that length can lead to a server to crash.</remarks>
347+
/// <remarks>This function doesn't support <a href="#strpack">packed</a> strings.</remarks>
348+
/// <remarks>
349+
/// <b>Format Specifiers:</b><p/>
350+
/// <ul>
351+
/// <li><b><c>%i</c></b> - integer (whole number)</li>
352+
/// <li><b><c>%d</c></b> - integer (whole number).</li>
353+
/// <li><b><c>%s</c></b> - string</li>
354+
/// <li><b><c>%f</c></b> - floating-point number (Float: tag)</li>
355+
/// <li><b><c>%c</c></b> - ASCII character</li>
356+
/// <li><b><c>%x</c></b> - hexadecimal number</li>
357+
/// <li><b><c>%b</c></b> - binary number</li>
358+
/// <li><b><c>%%</c></b> - literal <b><c>%</c></b></li>
359+
/// <li><b><c>%q</c></b> - escape a text for SQLite. (Added in <b>0.3.7 R2</b>)</li>
360+
/// </ul>
361+
/// </remarks>
362+
/// <remarks>The values for the placeholders follow in the exact same order as parameters in the call. For example, <b><c>"I am %i years old"</c></b> - the <b><c>%i</c></b> will be replaced with an Integer variable, which is the person's age.</remarks>
363+
/// <remarks>You may optionally put a number between the <b><c>%</c></b> and the letter of the placeholder code. This number indicates the field width; if the size of the parameter to print at the position of the placeholder is smaller than the field width, the field is expanded with spaces. To cut the number of decimal places beeing shown of a float, you can add <b><c>.&lt;max number&gt;</c></b> between the <b><c>%</c></b> and the <b><c>f</c></b>. (example: <b><c>%.2f</c></b>)</remarks>
364+
native printf(const format[], {Float,_}:...);
365+
#endif
363366

364367
/// <summary>Formats a string to include variables and other strings inside it.</summary>
365368
/// <param name="output">The string to output the result to</param>

0 commit comments

Comments
 (0)