Add ChatFilter2, OverheadChat, EventGreeting and update several plugins
New plugins: ChatFilter2, OverheadChat, EventGreeting. Updated: HostnameManager, Leader3 (chat and markers), NameFilter2 (plugin and config), PlayerRankings_nohlstats (rank display modes), custom-chatcolors (plugin and ccc.inc), Extend (sm_settimeleft). Add shared includes the plugins build against: Break, ChatFilter2, Couch, EventNotifier, TransmitManager, leader, ripext, unloze_playtime.
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
#if defined _Break_include
|
||||
#endinput
|
||||
#endif
|
||||
#define _Break_include
|
||||
|
||||
/**
|
||||
* Called when a break is started
|
||||
*
|
||||
* @return None
|
||||
*/
|
||||
forward void Break_OnBreakStarted();
|
||||
|
||||
/**
|
||||
* Called when a break is finished
|
||||
*
|
||||
* @return None
|
||||
*/
|
||||
forward void Break_OnBreakFinished();
|
||||
|
||||
/**
|
||||
* Called when a break is cancelled
|
||||
*
|
||||
* @return None
|
||||
*/
|
||||
forward void Break_OnBreakCancelled();
|
||||
|
||||
/**
|
||||
* Returns if a break is active
|
||||
*
|
||||
* @return True when in break, false otherwise
|
||||
*/
|
||||
native bool Break_IsBreakActive();
|
||||
|
||||
public SharedPlugin __pl_Break =
|
||||
{
|
||||
name = "Break",
|
||||
file = "Break.smx",
|
||||
|
||||
#if defined REQUIRE_PLUGIN
|
||||
required = 1
|
||||
#else
|
||||
required = 0
|
||||
#endif
|
||||
};
|
||||
|
||||
#if !defined REQUIRE_PLUGIN
|
||||
public void __pl_Break_SetNTVOptional()
|
||||
{
|
||||
MarkNativeAsOptional("Break_IsBreakActive");
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,50 @@
|
||||
#if defined _ChatFilter2_included_
|
||||
#endinput
|
||||
#endif
|
||||
#define _ChatFilter2_included_
|
||||
|
||||
/**
|
||||
* Censors bad words in a string the same way safe chat does, with every category.
|
||||
*
|
||||
* @param text String to censor in place
|
||||
* @param maxlen Size of text
|
||||
* @return True if anything was censored
|
||||
*/
|
||||
native bool ChatFilter2_CensorText(char[] text, int maxlen);
|
||||
|
||||
/**
|
||||
* Checks if a client has safe chat enabled.
|
||||
*
|
||||
* @param client Client index
|
||||
* @return True if safe chat is enabled
|
||||
*/
|
||||
native bool ChatFilter2_IsSafeChatEnabled(int client);
|
||||
|
||||
/**
|
||||
* Called when a client toggles safe chat, and when their cookies load with safe chat enabled.
|
||||
*
|
||||
* @param client Client index
|
||||
* @param enabled True if safe chat is now enabled
|
||||
*/
|
||||
forward void ChatFilter2_OnSafeChatChanged(int client, bool enabled);
|
||||
|
||||
#if !defined CHATFILTER2_CORE
|
||||
public SharedPlugin __pl_ChatFilter2 =
|
||||
{
|
||||
name = "ChatFilter2",
|
||||
file = "ChatFilter2.smx",
|
||||
#if defined REQUIRE_PLUGIN
|
||||
required = 1,
|
||||
#else
|
||||
required = 0,
|
||||
#endif
|
||||
};
|
||||
|
||||
#if !defined REQUIRE_PLUGIN
|
||||
public void __pl_ChatFilter2_SetNTVOptional()
|
||||
{
|
||||
MarkNativeAsOptional("ChatFilter2_CensorText");
|
||||
MarkNativeAsOptional("ChatFilter2_IsSafeChatEnabled");
|
||||
}
|
||||
#endif
|
||||
#endif // CHATFILTER2_CORE
|
||||
Symlink
+1
@@ -0,0 +1 @@
|
||||
../Couch/scripting/include/Couch.inc
|
||||
@@ -0,0 +1,159 @@
|
||||
#if defined _EventNotifier_included
|
||||
#endinput
|
||||
#endif
|
||||
|
||||
#define _EventNotifier_included
|
||||
|
||||
#define EVENT_STR_LEN 128
|
||||
#define EVENT_URL_LEN 192
|
||||
#define EVENT_MAPS_LEN 1024
|
||||
|
||||
enum struct EventInfo
|
||||
{
|
||||
int number;
|
||||
int start; // unix timestamp (UTC), 0 if unknown
|
||||
int end; // unix timestamp (UTC), 0 if unknown
|
||||
char url[EVENT_URL_LEN]; // forum thread URL, empty if unknown
|
||||
char name[EVENT_STR_LEN];
|
||||
char server[EVENT_STR_LEN];
|
||||
char rewards[EVENT_STR_LEN];
|
||||
char leader[EVENT_STR_LEN];
|
||||
char kickers[EVENT_STR_LEN];
|
||||
char maps[EVENT_MAPS_LEN]; // ", "-joined list
|
||||
}
|
||||
|
||||
#if !defined EVENTNOTIFIER_CORE
|
||||
|
||||
/**
|
||||
* Number of events in the last successful fetch (0 before the first fetch).
|
||||
*
|
||||
* @return Event count.
|
||||
*/
|
||||
native int EventNotifier_GetEventCount();
|
||||
|
||||
/**
|
||||
* Whether at least one fetch has succeeded since the plugin loaded.
|
||||
*
|
||||
* @return True once the event list has been fetched.
|
||||
*/
|
||||
native bool EventNotifier_HasFetched();
|
||||
|
||||
/**
|
||||
* Finds an event by its event number.
|
||||
*
|
||||
* @param number Event number.
|
||||
* @return Index into the event list, or -1 if not found.
|
||||
*/
|
||||
native int EventNotifier_FindEventByNumber(int number);
|
||||
|
||||
/**
|
||||
* Copies an event into the caller's EventInfo.
|
||||
*
|
||||
* @param index Index into the event list.
|
||||
* @param ev EventInfo to fill.
|
||||
* @param size Size of ev, must be sizeof(EventInfo).
|
||||
* @return True on success, false if index is out of range.
|
||||
* @error Buffer smaller than sizeof(EventInfo).
|
||||
*/
|
||||
native bool EventNotifier_GetEvent(int index, any[] ev, int size = sizeof(EventInfo));
|
||||
|
||||
/**
|
||||
* Starts a fetch of the event list now. No-op if a fetch is already running.
|
||||
*/
|
||||
native void EventNotifier_Refresh();
|
||||
|
||||
/**
|
||||
* Formats a timestamp in the client's own timezone (looked up via GeoIP),
|
||||
* e.g. "Thu 01 Oct 2026, 20:00 BST". Clients whose timezone is unknown get
|
||||
* sm_event_fallback_timezone.
|
||||
*
|
||||
* @param client Client index, 0 for the fallback timezone.
|
||||
* @param timestamp Unix timestamp (UTC).
|
||||
* @param buffer Destination buffer.
|
||||
* @param maxlen Size of buffer.
|
||||
* @param withYear Whether to include the year.
|
||||
* @error Invalid client index.
|
||||
*/
|
||||
native void EventNotifier_FormatClientTime(int client, int timestamp, char[] buffer, int maxlen, bool withYear = true);
|
||||
|
||||
/**
|
||||
* Called after every successful fetch, once the event list has been replaced.
|
||||
*/
|
||||
forward void EventNotifier_OnEventsUpdated();
|
||||
|
||||
#endif // EVENTNOTIFIER_CORE
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Display helpers
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Formats a duration in seconds as "1d 2h 3m", "2h 3m" or "3m".
|
||||
*/
|
||||
stock void EventNotifier_FormatDuration(int seconds, char[] buffer, int maxlen)
|
||||
{
|
||||
int days = seconds / 86400;
|
||||
int hours = (seconds % 86400) / 3600;
|
||||
int minutes = (seconds % 3600) / 60;
|
||||
|
||||
if (days > 0)
|
||||
Format(buffer, maxlen, "%dd %dh %dm", days, hours, minutes);
|
||||
else if (hours > 0)
|
||||
Format(buffer, maxlen, "%dh %dm", hours, minutes);
|
||||
else
|
||||
Format(buffer, maxlen, "%dm", minutes);
|
||||
}
|
||||
|
||||
/**
|
||||
* Formats an event's status relative to now as a "Status: ..." line.
|
||||
*/
|
||||
stock void EventNotifier_FormatRelativeTime(int start, int end, char[] buffer, int maxlen)
|
||||
{
|
||||
int now = GetTime();
|
||||
|
||||
if (end > 0 && now >= start && now < end)
|
||||
{
|
||||
strcopy(buffer, maxlen, "Status: In progress now!");
|
||||
return;
|
||||
}
|
||||
|
||||
char span[32];
|
||||
if (now >= start)
|
||||
{
|
||||
EventNotifier_FormatDuration(now - start, span, sizeof(span));
|
||||
Format(buffer, maxlen, "Status: Started %s ago", span);
|
||||
}
|
||||
else
|
||||
{
|
||||
EventNotifier_FormatDuration(start - now, span, sizeof(span));
|
||||
Format(buffer, maxlen, "Status: Starts in %s", span);
|
||||
}
|
||||
}
|
||||
|
||||
#if !defined EVENTNOTIFIER_CORE
|
||||
|
||||
public SharedPlugin __pl_EventNotifier =
|
||||
{
|
||||
name = "EventNotifier",
|
||||
file = "EventNotifier.smx",
|
||||
|
||||
#if defined REQUIRE_PLUGIN
|
||||
required = 1
|
||||
#else
|
||||
required = 0
|
||||
#endif
|
||||
};
|
||||
|
||||
#if !defined REQUIRE_PLUGIN
|
||||
public void __pl_EventNotifier_SetNTVOptional()
|
||||
{
|
||||
MarkNativeAsOptional("EventNotifier_GetEventCount");
|
||||
MarkNativeAsOptional("EventNotifier_HasFetched");
|
||||
MarkNativeAsOptional("EventNotifier_FindEventByNumber");
|
||||
MarkNativeAsOptional("EventNotifier_GetEvent");
|
||||
MarkNativeAsOptional("EventNotifier_Refresh");
|
||||
MarkNativeAsOptional("EventNotifier_FormatClientTime");
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // EVENTNOTIFIER_CORE
|
||||
@@ -0,0 +1,30 @@
|
||||
#if defined _TransmitManager_included
|
||||
#endinput
|
||||
#endif
|
||||
#define _TransmitManager_included
|
||||
|
||||
native void TransmitManager_AddEntityHooks(int entity);
|
||||
native bool TransmitManager_SetEntityOwner(int entity, int target);
|
||||
native bool TransmitManager_SetEntityState(int entity, int client, bool can);
|
||||
native bool TransmitManager_GetEntityState(int entity, int client);
|
||||
native bool TransmitManager_IsEntityHooked(int entity);
|
||||
|
||||
/**
|
||||
* _________________Do not edit below this line!_______________________
|
||||
*/
|
||||
public Extension __ext_transmit =
|
||||
{
|
||||
name = "TransmitManager",
|
||||
file = "TransmitManager.ext",
|
||||
#if defined AUTOLOAD_EXTENSIONS
|
||||
autoload = 1,
|
||||
#else
|
||||
autoload = 0,
|
||||
#endif
|
||||
#if defined REQUIRE_EXTENSIONS
|
||||
required = 1,
|
||||
#else
|
||||
required = 0,
|
||||
#endif
|
||||
};
|
||||
|
||||
@@ -0,0 +1,90 @@
|
||||
#if defined _leader_included_
|
||||
#endinput
|
||||
#endif
|
||||
#define _leader_included_
|
||||
|
||||
/**
|
||||
* Returns the current PRIMARY leader.
|
||||
*
|
||||
* @return Client index of the primary leader (-1 = no leader)
|
||||
*/
|
||||
native int Leader_CurrentLeader();
|
||||
|
||||
/**
|
||||
* Makes a client the PRIMARY leader. If another primary exists, they are
|
||||
* demoted to sub-leader. If the client is already a sub-leader, they are
|
||||
* promoted.
|
||||
*
|
||||
* @param client Client index to be set as primary leader
|
||||
*/
|
||||
native void Leader_SetLeader(int client);
|
||||
|
||||
/**
|
||||
* Checks if a client is currently a leader (primary or sub-leader).
|
||||
*
|
||||
* @param client Client index to check
|
||||
* @return True if the client is a leader
|
||||
*/
|
||||
native bool Leader_Is(int client);
|
||||
|
||||
/**
|
||||
* Returns the number of current leaders (primary + sub-leaders).
|
||||
*
|
||||
* @return Leader count
|
||||
*/
|
||||
native int Leader_GetLeaderCount();
|
||||
|
||||
/**
|
||||
* Returns the leader at the given roster index.
|
||||
*
|
||||
* @param index Roster index (0 = primary)
|
||||
* @return Client index, or -1 if no leader at that index
|
||||
*/
|
||||
native int Leader_GetLeader(int index);
|
||||
|
||||
/**
|
||||
* Called after a client becomes a leader.
|
||||
*
|
||||
* @param client The new leader
|
||||
* @param primary True if they became the primary leader
|
||||
*/
|
||||
forward void Leader_OnLeaderAdded(int client, bool primary);
|
||||
|
||||
/**
|
||||
* Called after a client stops being a leader.
|
||||
*
|
||||
* @param client The removed leader
|
||||
*/
|
||||
forward void Leader_OnLeaderRemoved(int client);
|
||||
|
||||
/**
|
||||
* Called when the primary leader changes.
|
||||
*
|
||||
* @param oldLeader Previous primary (-1 = none)
|
||||
* @param newLeader New primary (-1 = none)
|
||||
*/
|
||||
forward void Leader_OnPrimaryChanged(int oldLeader, int newLeader);
|
||||
|
||||
#if !defined LEADER3_CORE
|
||||
public SharedPlugin __pl_leader =
|
||||
{
|
||||
name = "leader",
|
||||
file = "Leader3.smx",
|
||||
#if defined REQUIRE_PLUGIN
|
||||
required = 1,
|
||||
#else
|
||||
required = 0,
|
||||
#endif
|
||||
};
|
||||
|
||||
#if !defined REQUIRE_PLUGIN
|
||||
public void __pl_leader_SetNTVOptional()
|
||||
{
|
||||
MarkNativeAsOptional("Leader_CurrentLeader");
|
||||
MarkNativeAsOptional("Leader_SetLeader");
|
||||
MarkNativeAsOptional("Leader_Is");
|
||||
MarkNativeAsOptional("Leader_GetLeaderCount");
|
||||
MarkNativeAsOptional("Leader_GetLeader");
|
||||
}
|
||||
#endif
|
||||
#endif // LEADER3_CORE
|
||||
@@ -0,0 +1,26 @@
|
||||
#if defined _ripext_included_
|
||||
#endinput
|
||||
#endif
|
||||
#define _ripext_included_
|
||||
|
||||
#include <ripext/json>
|
||||
#include <ripext/http>
|
||||
|
||||
/**
|
||||
* Do not edit below this line!
|
||||
*/
|
||||
public Extension __ext_rip =
|
||||
{
|
||||
name = "REST in Pawn",
|
||||
file = "rip.ext",
|
||||
#if defined AUTOLOAD_EXTENSIONS
|
||||
autoload = 1,
|
||||
#else
|
||||
autoload = 0,
|
||||
#endif
|
||||
#if defined REQUIRE_EXTENSIONS
|
||||
required = 1,
|
||||
#else
|
||||
required = 0,
|
||||
#endif
|
||||
};
|
||||
@@ -0,0 +1,359 @@
|
||||
enum HTTPStatus
|
||||
{
|
||||
HTTPStatus_Invalid = 0,
|
||||
|
||||
// 1xx Informational
|
||||
HTTPStatus_Continue = 100,
|
||||
HTTPStatus_SwitchingProtocols = 101,
|
||||
|
||||
// 2xx Success
|
||||
HTTPStatus_OK = 200,
|
||||
HTTPStatus_Created = 201,
|
||||
HTTPStatus_Accepted = 202,
|
||||
HTTPStatus_NonAuthoritativeInformation = 203,
|
||||
HTTPStatus_NoContent = 204,
|
||||
HTTPStatus_ResetContent = 205,
|
||||
HTTPStatus_PartialContent = 206,
|
||||
|
||||
// 3xx Redirection
|
||||
HTTPStatus_MultipleChoices = 300,
|
||||
HTTPStatus_MovedPermanently = 301,
|
||||
HTTPStatus_Found = 302,
|
||||
HTTPStatus_SeeOther = 303,
|
||||
HTTPStatus_NotModified = 304,
|
||||
HTTPStatus_UseProxy = 305,
|
||||
HTTPStatus_TemporaryRedirect = 307,
|
||||
HTTPStatus_PermanentRedirect = 308,
|
||||
|
||||
// 4xx Client Error
|
||||
HTTPStatus_BadRequest = 400,
|
||||
HTTPStatus_Unauthorized = 401,
|
||||
HTTPStatus_PaymentRequired = 402,
|
||||
HTTPStatus_Forbidden = 403,
|
||||
HTTPStatus_NotFound = 404,
|
||||
HTTPStatus_MethodNotAllowed = 405,
|
||||
HTTPStatus_NotAcceptable = 406,
|
||||
HTTPStatus_ProxyAuthenticationRequired = 407,
|
||||
HTTPStatus_RequestTimeout = 408,
|
||||
HTTPStatus_Conflict = 409,
|
||||
HTTPStatus_Gone = 410,
|
||||
HTTPStatus_LengthRequired = 411,
|
||||
HTTPStatus_PreconditionFailed = 412,
|
||||
HTTPStatus_RequestEntityTooLarge = 413,
|
||||
HTTPStatus_RequestURITooLong = 414,
|
||||
HTTPStatus_UnsupportedMediaType = 415,
|
||||
HTTPStatus_RequestedRangeNotSatisfiable = 416,
|
||||
HTTPStatus_ExpectationFailed = 417,
|
||||
HTTPStatus_MisdirectedRequest = 421,
|
||||
HTTPStatus_TooEarly = 425,
|
||||
HTTPStatus_UpgradeRequired = 426,
|
||||
HTTPStatus_PreconditionRequired = 428,
|
||||
HTTPStatus_TooManyRequests = 429,
|
||||
HTTPStatus_RequestHeaderFieldsTooLarge = 431,
|
||||
HTTPStatus_UnavailableForLegalReasons = 451,
|
||||
|
||||
// 5xx Server Error
|
||||
HTTPStatus_InternalServerError = 500,
|
||||
HTTPStatus_NotImplemented = 501,
|
||||
HTTPStatus_BadGateway = 502,
|
||||
HTTPStatus_ServiceUnavailable = 503,
|
||||
HTTPStatus_GatewayTimeout = 504,
|
||||
HTTPStatus_HTTPVersionNotSupported = 505,
|
||||
HTTPStatus_VariantAlsoNegotiates = 506,
|
||||
HTTPStatus_NotExtended = 510,
|
||||
HTTPStatus_NetworkAuthenticationRequired = 511,
|
||||
};
|
||||
|
||||
typeset HTTPRequestCallback
|
||||
{
|
||||
function void (HTTPResponse response, any value);
|
||||
function void (HTTPResponse response, any value, const char[] error);
|
||||
};
|
||||
|
||||
typeset HTTPFileCallback
|
||||
{
|
||||
function void (HTTPStatus status, any value);
|
||||
function void (HTTPStatus status, any value, const char[] error);
|
||||
};
|
||||
|
||||
methodmap HTTPRequest < Handle
|
||||
{
|
||||
// Creates an HTTP request.
|
||||
//
|
||||
// The Handle is automatically freed when the request is performed.
|
||||
// Otherwise, the Handle must be freed via delete or CloseHandle().
|
||||
//
|
||||
// @param url URL to the REST API endpoint.
|
||||
public native HTTPRequest(const char[] url);
|
||||
|
||||
// Appends a parameter to the form data.
|
||||
//
|
||||
// The parameter name and value are encoded according to RFC 3986.
|
||||
//
|
||||
// @param name Parameter name.
|
||||
// @param format Formatting rules.
|
||||
// @param ... Variable number of format parameters.
|
||||
public native void AppendFormParam(const char[] name, const char[] format, any ...);
|
||||
|
||||
// Appends a query parameter to the URL.
|
||||
//
|
||||
// The parameter name and value are encoded according to RFC 3986.
|
||||
//
|
||||
// @param name Parameter name.
|
||||
// @param format Formatting rules.
|
||||
// @param ... Variable number of format parameters.
|
||||
public native void AppendQueryParam(const char[] name, const char[] format, any ...);
|
||||
|
||||
// Sets the credentials for HTTP Basic authentication.
|
||||
//
|
||||
// @param username Username to use.
|
||||
// @param password Password to use.
|
||||
public native void SetBasicAuth(const char[] username, const char[] password);
|
||||
|
||||
// Sets an HTTP header.
|
||||
//
|
||||
// @param name Header name.
|
||||
// @param format Formatting rules.
|
||||
// @param ... Variable number of format parameters.
|
||||
public native void SetHeader(const char[] name, const char[] format, any ...);
|
||||
|
||||
// Performs an HTTP GET request.
|
||||
//
|
||||
// This function closes the request Handle after completing.
|
||||
//
|
||||
// @param callback A function to use as a callback when the request has finished.
|
||||
// @param value Optional value to pass to the callback function.
|
||||
public native void Get(HTTPRequestCallback callback, any value = 0);
|
||||
|
||||
// Performs an HTTP POST request.
|
||||
//
|
||||
// This function closes the request Handle after completing.
|
||||
//
|
||||
// @param data JSON data to send.
|
||||
// @param callback A function to use as a callback when the request has finished.
|
||||
// @param value Optional value to pass to the callback function.
|
||||
public native void Post(JSON data, HTTPRequestCallback callback, any value = 0);
|
||||
|
||||
// Performs an HTTP PUT request.
|
||||
//
|
||||
// This function closes the request Handle after completing.
|
||||
//
|
||||
// @param data JSON data to send.
|
||||
// @param callback A function to use as a callback when the request has finished.
|
||||
// @param value Optional value to pass to the callback function.
|
||||
public native void Put(JSON data, HTTPRequestCallback callback, any value = 0);
|
||||
|
||||
// Performs an HTTP PATCH request.
|
||||
//
|
||||
// This function closes the request Handle after completing.
|
||||
//
|
||||
// @param data JSON data to send.
|
||||
// @param callback A function to use as a callback when the request has finished.
|
||||
// @param value Optional value to pass to the callback function.
|
||||
public native void Patch(JSON data, HTTPRequestCallback callback, any value = 0);
|
||||
|
||||
// Performs an HTTP DELETE request.
|
||||
//
|
||||
// This function closes the request Handle after completing.
|
||||
//
|
||||
// @param callback A function to use as a callback when the request has finished.
|
||||
// @param value Optional value to pass to the callback function.
|
||||
public native void Delete(HTTPRequestCallback callback, any value = 0);
|
||||
|
||||
// Downloads a file.
|
||||
//
|
||||
// This function closes the request Handle after completing.
|
||||
//
|
||||
// @param path File path to write to.
|
||||
// @param callback A function to use as a callback when the download has finished.
|
||||
// @param value Optional value to pass to the callback function.
|
||||
public native void DownloadFile(const char[] path, HTTPFileCallback callback, any value = 0);
|
||||
|
||||
// Uploads a file.
|
||||
//
|
||||
// This function performs an HTTP PUT request. The file contents are sent in the request body.
|
||||
// This function closes the request Handle after completing.
|
||||
//
|
||||
// @param path File path to read from.
|
||||
// @param callback A function to use as a callback when the upload has finished.
|
||||
// @param value Optional value to pass to the callback function.
|
||||
public native void UploadFile(const char[] path, HTTPFileCallback callback, any value = 0);
|
||||
|
||||
// Performs an HTTP POST request with form data.
|
||||
//
|
||||
// This function closes the request Handle after completing.
|
||||
//
|
||||
// @param callback A function to use as a callback when the request has finished.
|
||||
// @param value Optional value to pass to the callback function.
|
||||
public native void PostForm(HTTPRequestCallback callback, any value = 0);
|
||||
|
||||
// Connect timeout in seconds. Defaults to 10.
|
||||
property int ConnectTimeout {
|
||||
public native get();
|
||||
public native set(int connectTimeout);
|
||||
}
|
||||
|
||||
// Maximum number of redirects to follow. Defaults to 5.
|
||||
property int MaxRedirects {
|
||||
public native get();
|
||||
public native set(int maxRedirects);
|
||||
}
|
||||
|
||||
// Maximum download speed in bytes per second. Defaults to unlimited speed.
|
||||
property int MaxRecvSpeed {
|
||||
public native get();
|
||||
public native set(int maxSpeed);
|
||||
}
|
||||
|
||||
// Maximum upload speed in bytes per second. Defaults to unlimited speed.
|
||||
property int MaxSendSpeed {
|
||||
public native get();
|
||||
public native set(int maxSpeed);
|
||||
}
|
||||
|
||||
// Timeout in seconds. Defaults to 30.
|
||||
property int Timeout {
|
||||
public native get();
|
||||
public native set(int timeout);
|
||||
}
|
||||
}
|
||||
|
||||
methodmap HTTPResponse
|
||||
{
|
||||
// Retrieves an HTTP header from the response.
|
||||
//
|
||||
// @param name Header name.
|
||||
// @param buffer String buffer to store value.
|
||||
// @param maxlength Maximum length of the string buffer.
|
||||
// @return True on success, false if the header was not found.
|
||||
public native bool GetHeader(const char[] name, char[] buffer, int maxlength);
|
||||
|
||||
// Retrieves the JSON data of the response.
|
||||
//
|
||||
// @error Invalid JSON response.
|
||||
property JSON Data {
|
||||
public native get();
|
||||
}
|
||||
|
||||
// Retrieves the HTTP status of the response.
|
||||
property HTTPStatus Status {
|
||||
public native get();
|
||||
}
|
||||
};
|
||||
|
||||
// Deprecated. Use HTTPRequest instead.
|
||||
methodmap HTTPClient < Handle
|
||||
{
|
||||
// Creates an HTTP client.
|
||||
//
|
||||
// The HTTPClient must be freed via delete or CloseHandle().
|
||||
//
|
||||
// @param baseURL Base URL to the REST API.
|
||||
#pragma deprecated Use HTTPRequest instead.
|
||||
public native HTTPClient(const char[] baseURL);
|
||||
|
||||
// Sets an HTTP header to be used for all requests.
|
||||
//
|
||||
// @param name Header name.
|
||||
// @param value String value to set.
|
||||
#pragma deprecated Use HTTPRequest.SetHeader() instead.
|
||||
public native void SetHeader(const char[] name, const char[] value);
|
||||
|
||||
// Performs an HTTP GET request.
|
||||
//
|
||||
// @param endpoint API endpoint to request.
|
||||
// @param callback A function to use as a callback when the request has finished.
|
||||
// @param value Optional value to pass to the callback function.
|
||||
#pragma deprecated Use HTTPRequest.Get() instead.
|
||||
public native void Get(const char[] endpoint, HTTPRequestCallback callback, any value = 0);
|
||||
|
||||
// Performs an HTTP POST request.
|
||||
//
|
||||
// @param endpoint API endpoint to request.
|
||||
// @param data JSON data to send.
|
||||
// @param callback A function to use as a callback when the request has finished.
|
||||
// @param value Optional value to pass to the callback function.
|
||||
#pragma deprecated Use HTTPRequest.Post() instead.
|
||||
public native void Post(const char[] endpoint, JSON data, HTTPRequestCallback callback, any value = 0);
|
||||
|
||||
// Performs an HTTP PUT request.
|
||||
//
|
||||
// @param endpoint API endpoint to request.
|
||||
// @param data JSON data to send.
|
||||
// @param callback A function to use as a callback when the request has finished.
|
||||
// @param value Optional value to pass to the callback function.
|
||||
#pragma deprecated Use HTTPRequest.Put() instead.
|
||||
public native void Put(const char[] endpoint, JSON data, HTTPRequestCallback callback, any value = 0);
|
||||
|
||||
// Performs an HTTP PATCH request.
|
||||
//
|
||||
// @param endpoint API endpoint to request.
|
||||
// @param data JSON data to send.
|
||||
// @param callback A function to use as a callback when the request has finished.
|
||||
// @param value Optional value to pass to the callback function.
|
||||
#pragma deprecated Use HTTPRequest.Patch() instead.
|
||||
public native void Patch(const char[] endpoint, JSON data, HTTPRequestCallback callback, any value = 0);
|
||||
|
||||
// Performs an HTTP DELETE request.
|
||||
//
|
||||
// @param endpoint API endpoint to request.
|
||||
// @param callback A function to use as a callback when the request has finished.
|
||||
// @param value Optional value to pass to the callback function.
|
||||
#pragma deprecated Use HTTPRequest.Delete() instead.
|
||||
public native void Delete(const char[] endpoint, HTTPRequestCallback callback, any value = 0);
|
||||
|
||||
// Downloads a file.
|
||||
//
|
||||
// @param endpoint API endpoint to download from.
|
||||
// @param path File path to write to.
|
||||
// @param callback A function to use as a callback when the download has finished.
|
||||
// @param value Optional value to pass to the callback function.
|
||||
#pragma deprecated Use HTTPRequest.DownloadFile() instead.
|
||||
public native void DownloadFile(const char[] endpoint, const char[] path, HTTPFileCallback callback, any value = 0);
|
||||
|
||||
// Uploads a file.
|
||||
//
|
||||
// This function performs an HTTP PUT request. The file contents are sent in the request body.
|
||||
//
|
||||
// @param endpoint API endpoint to upload to.
|
||||
// @param path File path to read from.
|
||||
// @param callback A function to use as a callback when the upload has finished.
|
||||
// @param value Optional value to pass to the callback function.
|
||||
#pragma deprecated Use HTTPRequest.UploadFile() instead.
|
||||
public native void UploadFile(const char[] endpoint, const char[] path, HTTPFileCallback callback, any value = 0);
|
||||
|
||||
// Connect timeout in seconds. Defaults to 10.
|
||||
#pragma deprecated Use HTTPRequest.ConnectTimeout instead.
|
||||
property int ConnectTimeout {
|
||||
public native get();
|
||||
public native set(int connectTimeout);
|
||||
}
|
||||
|
||||
// Follow HTTP 3xx redirects. Defaults to true.
|
||||
#pragma deprecated Use HTTPRequest.MaxRedirects instead.
|
||||
property bool FollowLocation {
|
||||
public native get();
|
||||
public native set(bool followLocation);
|
||||
}
|
||||
|
||||
// Timeout in seconds. Defaults to 30.
|
||||
#pragma deprecated Use HTTPRequest.Timeout instead.
|
||||
property int Timeout {
|
||||
public native get();
|
||||
public native set(int timeout);
|
||||
}
|
||||
|
||||
// Maximum upload speed in bytes per second. Defaults to unlimited speed.
|
||||
#pragma deprecated Use HTTPRequest.MaxSendSpeed instead.
|
||||
property int MaxSendSpeed {
|
||||
public native get();
|
||||
public native set(int speed);
|
||||
}
|
||||
|
||||
// Maximum download speed in bytes per second. Defaults to unlimited speed.
|
||||
#pragma deprecated Use HTTPRequest.MaxRecvSpeed instead.
|
||||
property int MaxRecvSpeed {
|
||||
public native get();
|
||||
public native set(int speed);
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,400 @@
|
||||
// Decoding flags
|
||||
enum
|
||||
{
|
||||
JSON_REJECT_DUPLICATES = 0x1, /**< Error if any JSON object contains duplicate keys */
|
||||
JSON_DISABLE_EOF_CHECK = 0x2, /**< Allow extra data after a valid JSON array or object */
|
||||
JSON_DECODE_ANY = 0x4, /**< Decode any value */
|
||||
JSON_DECODE_INT_AS_REAL = 0x8, /**< Interpret all numbers as floats */
|
||||
JSON_ALLOW_NUL = 0x10 /**< Allow \u0000 escape inside string values */
|
||||
};
|
||||
|
||||
// Encoding flags
|
||||
enum
|
||||
{
|
||||
JSON_COMPACT = 0x20, /**< Compact representation */
|
||||
JSON_ENSURE_ASCII = 0x40, /**< Escape all Unicode characters outside the ASCII range */
|
||||
JSON_SORT_KEYS = 0x80, /**< Sort object keys */
|
||||
JSON_ENCODE_ANY = 0x200, /**< Encode any value */
|
||||
JSON_ESCAPE_SLASH = 0x400, /**< Escape / with \/ */
|
||||
JSON_EMBED = 0x10000 /**< Omit opening and closing braces of the top-level object */
|
||||
};
|
||||
|
||||
// Maximum indentation
|
||||
static const int JSON_MAX_INDENT = 0x1F;
|
||||
|
||||
// Pretty-print the result, indenting with n spaces
|
||||
stock int JSON_INDENT(int n)
|
||||
{
|
||||
return n & JSON_MAX_INDENT;
|
||||
}
|
||||
|
||||
// Output floats with at most n digits of precision
|
||||
stock int JSON_REAL_PRECISION(int n)
|
||||
{
|
||||
return (n & 0x1F) << 11;
|
||||
}
|
||||
|
||||
// Generic type for encoding JSON.
|
||||
methodmap JSON < Handle
|
||||
{
|
||||
// Writes the JSON string representation to a file.
|
||||
//
|
||||
// @param file File to write to.
|
||||
// @param flags Encoding flags.
|
||||
// @return True on success, false on failure.
|
||||
public native bool ToFile(const char[] file, int flags = 0);
|
||||
|
||||
// Retrieves the JSON string representation.
|
||||
//
|
||||
// @param buffer String buffer to write to.
|
||||
// @param maxlength Maximum length of the string buffer.
|
||||
// @param flags Encoding flags.
|
||||
// @return True on success, false on failure.
|
||||
public native bool ToString(char[] buffer, int maxlength, int flags = 0);
|
||||
};
|
||||
|
||||
methodmap JSONObject < JSON
|
||||
{
|
||||
// Creates a JSON object. A JSON object maps strings (called "keys") to values. Keys in a
|
||||
// JSON object are unique. That is, there is at most one entry in the map for a given key.
|
||||
//
|
||||
// The JSONObject must be freed via delete or CloseHandle().
|
||||
public native JSONObject();
|
||||
|
||||
// Loads a JSON object from a file.
|
||||
//
|
||||
// @param file File to read from.
|
||||
// @param flags Decoding flags.
|
||||
// @return Object handle, or null on failure.
|
||||
// @error Invalid JSON.
|
||||
public static native JSONObject FromFile(const char[] file, int flags = 0);
|
||||
|
||||
// Loads a JSON object from a string.
|
||||
//
|
||||
// @param buffer String buffer to load into the JSON object.
|
||||
// @param flags Decoding flags.
|
||||
// @return Object handle, or null on failure.
|
||||
// @error Invalid JSON.
|
||||
public static native JSONObject FromString(const char[] buffer, int flags = 0);
|
||||
|
||||
// Retrieves an array or object value from the object.
|
||||
//
|
||||
// The JSON must be freed via delete or CloseHandle().
|
||||
//
|
||||
// @param key Key string.
|
||||
// @return Value read.
|
||||
// @error Invalid key.
|
||||
public native JSON Get(const char[] key);
|
||||
|
||||
// Retrieves a boolean value from the object.
|
||||
//
|
||||
// @param key Key string.
|
||||
// @return Value read.
|
||||
// @error Invalid key.
|
||||
public native bool GetBool(const char[] key);
|
||||
|
||||
// Retrieves a float value from the object.
|
||||
//
|
||||
// @param key Key string.
|
||||
// @return Value read.
|
||||
// @error Invalid key.
|
||||
public native float GetFloat(const char[] key);
|
||||
|
||||
// Retrieves an integer value from the object.
|
||||
//
|
||||
// @param key Key string.
|
||||
// @return Value read.
|
||||
// @error Invalid key.
|
||||
public native int GetInt(const char[] key);
|
||||
|
||||
// Retrieves a 64-bit integer value from the object.
|
||||
//
|
||||
// @param key Key string.
|
||||
// @param buffer String buffer to store value.
|
||||
// @param maxlength Maximum length of the string buffer.
|
||||
// @return True on success, false if the key was not found.
|
||||
public native bool GetInt64(const char[] key, char[] buffer, int maxlength);
|
||||
|
||||
// Retrieves a string value from the object.
|
||||
//
|
||||
// @param key Key string.
|
||||
// @param buffer String buffer to store value.
|
||||
// @param maxlength Maximum length of the string buffer.
|
||||
// @return True on success. False if the key was not found, or the value is not a string.
|
||||
public native bool GetString(const char[] key, char[] buffer, int maxlength);
|
||||
|
||||
// Returns whether or not a value in the object is null.
|
||||
//
|
||||
// @param key Key string.
|
||||
// @return True if the value is null, false otherwise.
|
||||
// @error Invalid key.
|
||||
public native bool IsNull(const char[] key);
|
||||
|
||||
// Returns whether or not a key exists in the object.
|
||||
//
|
||||
// @param key Key string.
|
||||
// @return True if the key exists, false otherwise.
|
||||
public native bool HasKey(const char[] key);
|
||||
|
||||
// Sets an array or object value in the object, either inserting a new entry or replacing an old one.
|
||||
//
|
||||
// @param key Key string.
|
||||
// @param value Value to store at this key.
|
||||
// @return True on success, false on failure.
|
||||
public native bool Set(const char[] key, JSON value);
|
||||
|
||||
// Sets a boolean value in the object, either inserting a new entry or replacing an old one.
|
||||
//
|
||||
// @param key Key string.
|
||||
// @param value Value to store at this key.
|
||||
// @return True on success, false on failure.
|
||||
public native bool SetBool(const char[] key, bool value);
|
||||
|
||||
// Sets a float value in the object, either inserting a new entry or replacing an old one.
|
||||
//
|
||||
// @param key Key string.
|
||||
// @param value Value to store at this key.
|
||||
// @return True on success, false on failure.
|
||||
public native bool SetFloat(const char[] key, float value);
|
||||
|
||||
// Sets an integer value in the object, either inserting a new entry or replacing an old one.
|
||||
//
|
||||
// @param key Key string.
|
||||
// @param value Value to store at this key.
|
||||
// @return True on success, false on failure.
|
||||
public native bool SetInt(const char[] key, int value);
|
||||
|
||||
// Sets a 64-bit integer value in the object, either inserting a new entry or replacing an old one.
|
||||
//
|
||||
// @param key Key string.
|
||||
// @param value Value to store at this key.
|
||||
// @return True on success, false on failure.
|
||||
public native bool SetInt64(const char[] key, const char[] value);
|
||||
|
||||
// Sets a null value in the object, either inserting a new entry or replacing an old one.
|
||||
//
|
||||
// @param key Key string.
|
||||
// @return True on success, false on failure.
|
||||
public native bool SetNull(const char[] key);
|
||||
|
||||
// Sets a string value in the object, either inserting a new entry or replacing an old one.
|
||||
//
|
||||
// @param key Key string.
|
||||
// @param value Value to store at this key.
|
||||
// @return True on success, false on failure.
|
||||
public native bool SetString(const char[] key, const char[] value);
|
||||
|
||||
// Removes an entry from the object.
|
||||
//
|
||||
// @param key Key string.
|
||||
// @return True on success, false if the key was not found.
|
||||
public native bool Remove(const char[] key);
|
||||
|
||||
// Clears the object of all entries.
|
||||
// @return True on success, false on failure.
|
||||
public native bool Clear();
|
||||
|
||||
// Returns an iterator for the object's keys. See JSONObjectKeys.
|
||||
public native JSONObjectKeys Keys();
|
||||
|
||||
// Retrieves the size of the object.
|
||||
property int Size {
|
||||
public native get();
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* A JSONObjectKeys is created via JSONObject.Keys(). It allows the keys of an
|
||||
* object to be iterated. The JSONObjectKeys must be freed with delete or
|
||||
* CloseHandle().
|
||||
*/
|
||||
methodmap JSONObjectKeys < Handle
|
||||
{
|
||||
// Reads an object key, then advances to the next key if any.
|
||||
//
|
||||
// @param buffer String buffer to store key.
|
||||
// @param maxlength Maximum length of the string buffer.
|
||||
// @return True on success, false if there are no more keys.
|
||||
public native bool ReadKey(char[] buffer, int maxlength);
|
||||
};
|
||||
|
||||
methodmap JSONArray < JSON
|
||||
{
|
||||
// Creates a JSON array.
|
||||
//
|
||||
// The JSONArray must be freed via delete or CloseHandle().
|
||||
public native JSONArray();
|
||||
|
||||
// Loads a JSON array from a file.
|
||||
//
|
||||
// @param file File to read from.
|
||||
// @param flags Decoding flags.
|
||||
// @return Array handle, or null on failure.
|
||||
// @error Invalid JSON.
|
||||
public static native JSONArray FromFile(const char[] file, int flags = 0);
|
||||
|
||||
// Loads a JSON array from a string.
|
||||
//
|
||||
// @param buffer String buffer to load into the JSON array.
|
||||
// @param flags Decoding flags.
|
||||
// @return Array handle, or null on failure.
|
||||
// @error Invalid JSON.
|
||||
public static native JSONArray FromString(const char[] buffer, int flags = 0);
|
||||
|
||||
// Retrieves an array or object value from the array.
|
||||
//
|
||||
// The JSON must be freed via delete or CloseHandle().
|
||||
//
|
||||
// @param index Index in the array.
|
||||
// @return Value read.
|
||||
// @error Invalid index.
|
||||
public native JSON Get(int index);
|
||||
|
||||
// Retrieves a boolean value from the array.
|
||||
//
|
||||
// @param index Index in the array.
|
||||
// @return Value read.
|
||||
// @error Invalid index.
|
||||
public native bool GetBool(int index);
|
||||
|
||||
// Retrieves a float value from the array.
|
||||
//
|
||||
// @param index Index in the array.
|
||||
// @return Value read.
|
||||
// @error Invalid index.
|
||||
public native float GetFloat(int index);
|
||||
|
||||
// Retrieves an integer value from the array.
|
||||
//
|
||||
// @param index Index in the array.
|
||||
// @return Value read.
|
||||
// @error Invalid index.
|
||||
public native int GetInt(int index);
|
||||
|
||||
// Retrieves an 64-bit integer value from the array.
|
||||
//
|
||||
// @param index Index in the array.
|
||||
// @param buffer Buffer to copy to.
|
||||
// @param maxlength Maximum size of the buffer.
|
||||
// @error Invalid index.
|
||||
public native void GetInt64(int index, char[] buffer, int maxlength);
|
||||
|
||||
// Retrieves a string value from the array.
|
||||
//
|
||||
// @param index Index in the array.
|
||||
// @param buffer Buffer to copy to.
|
||||
// @param maxlength Maximum size of the buffer.
|
||||
// @return True on success, false if the value is not a string.
|
||||
// @error Invalid index.
|
||||
public native bool GetString(int index, char[] buffer, int maxlength);
|
||||
|
||||
// Returns whether or not a value in the array is null.
|
||||
//
|
||||
// @param index Index in the array.
|
||||
// @return True if the value is null, false otherwise.
|
||||
// @error Invalid index.
|
||||
public native bool IsNull(int index);
|
||||
|
||||
// Sets an array or object value in the array.
|
||||
//
|
||||
// @param index Index in the array.
|
||||
// @param value Value to set.
|
||||
// @return True on success, false on failure.
|
||||
public native bool Set(int index, JSON value);
|
||||
|
||||
// Sets a boolean value in the array.
|
||||
//
|
||||
// @param index Index in the array.
|
||||
// @param value Value to set.
|
||||
// @return True on success, false on failure.
|
||||
public native bool SetBool(int index, bool value);
|
||||
|
||||
// Sets a float value in the array.
|
||||
//
|
||||
// @param index Index in the array.
|
||||
// @param value Value to set.
|
||||
// @return True on success, false on failure.
|
||||
public native bool SetFloat(int index, float value);
|
||||
|
||||
// Sets an integer value in the array.
|
||||
//
|
||||
// @param index Index in the array.
|
||||
// @param value Value to set.
|
||||
// @return True on success, false on failure.
|
||||
public native bool SetInt(int index, int value);
|
||||
|
||||
// Sets a 64 bit integer value in the array.
|
||||
//
|
||||
// @param index Index in the array.
|
||||
// @param value 64-bit integer value to set.
|
||||
// @return True on success, false on failure.
|
||||
public native bool SetInt64(int index, const char[] value);
|
||||
|
||||
// Sets a null value in the array.
|
||||
//
|
||||
// @param index Index in the array.
|
||||
// @return True on success, false on failure.
|
||||
public native bool SetNull(int index);
|
||||
|
||||
// Sets a string value in the array.
|
||||
//
|
||||
// @param index Index in the array.
|
||||
// @param value String value to set.
|
||||
// @return True on success, false on failure.
|
||||
public native bool SetString(int index, const char[] value);
|
||||
|
||||
// Pushes an array or object value onto the end of the array, adding a new index.
|
||||
//
|
||||
// @param value Value to push.
|
||||
// @return True on success, false on failure.
|
||||
public native bool Push(JSON value);
|
||||
|
||||
// Pushes a boolean value onto the end of the array, adding a new index.
|
||||
//
|
||||
// @param value Value to push.
|
||||
// @return True on success, false on failure.
|
||||
public native bool PushBool(bool value);
|
||||
|
||||
// Pushes a float value onto the end of the array, adding a new index.
|
||||
//
|
||||
// @param value Value to push.
|
||||
// @return True on success, false on failure.
|
||||
public native bool PushFloat(float value);
|
||||
|
||||
// Pushes an integer value onto the end of the array, adding a new index.
|
||||
//
|
||||
// @param value Value to push.
|
||||
// @return True on success, false on failure.
|
||||
public native bool PushInt(int value);
|
||||
|
||||
// Pushes a 64-bit integer value onto the end of the array, adding a new index.
|
||||
//
|
||||
// @param value 64-bit integer value to push.
|
||||
// @return True on success, false on failure.
|
||||
public native bool PushInt64(const char[] value);
|
||||
|
||||
// Pushes a null value onto the end of the array, adding a new index.
|
||||
// @return True on success, false on failure.
|
||||
public native bool PushNull();
|
||||
|
||||
// Pushes a string value onto the end of the array, adding a new index.
|
||||
//
|
||||
// @param value String value to push.
|
||||
// @return True on success, false on failure.
|
||||
public native bool PushString(const char[] value);
|
||||
|
||||
// Removes an entry from the array.
|
||||
//
|
||||
// @param index Index in the array to remove.
|
||||
// @return True on success, false on invalid index.
|
||||
public native bool Remove(int index);
|
||||
|
||||
// Clears the array of all entries.
|
||||
// @return True on success, false on failure.
|
||||
public native bool Clear();
|
||||
|
||||
// Retrieves the size of the array.
|
||||
property int Length {
|
||||
public native get();
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,26 @@
|
||||
#if defined _unloze_playtime_included_
|
||||
#endinput
|
||||
#endif
|
||||
#define _unloze_playtime_included_
|
||||
|
||||
/**
|
||||
* @returns the average playtime of all connected players excluding autism bots, fakeclients, AFKS and nosteamers
|
||||
*/
|
||||
native int GetAveragePlayerTimeOnServer();
|
||||
|
||||
/**
|
||||
* @returns the players rtv amount boost
|
||||
*/
|
||||
native int GetPlayerWorthRTV_boost_(int client);
|
||||
|
||||
/**
|
||||
* returns a players hours for a specific server
|
||||
*
|
||||
* @int the actual client
|
||||
* @int Game time hours that the client has on the server.
|
||||
* @int Game time minutes the client has on the server.
|
||||
*/
|
||||
|
||||
native int GetPlayerTier_native(int client); //just the clients tier
|
||||
forward void GetPlayerHoursServer(int client, int hours, int minutes);
|
||||
forward void GetPlayerTier(int client, int tier);
|
||||
Reference in New Issue
Block a user