Update compiler and includes to version 1.7.0.
This commit is contained in:
parent
743d17e05a
commit
5ec3694535
4
Makefile
4
Makefile
|
@ -4,8 +4,8 @@
|
||||||
SOURCEDIR=src
|
SOURCEDIR=src
|
||||||
SMINCLUDES=env/include
|
SMINCLUDES=env/include
|
||||||
BUILDDIR=build
|
BUILDDIR=build
|
||||||
SPCOMP_LINUX=env/linux/bin/spcomp-1.6.0
|
SPCOMP_LINUX=env/linux/bin/spcomp-1.7.0
|
||||||
SPCOMP_DARWIN=env/darwin/bin/spcomp-1.6.0
|
SPCOMP_DARWIN=env/darwin/bin/spcomp-1.7.0
|
||||||
DOS2UNIX_LINUX=dos2unix -p
|
DOS2UNIX_LINUX=dos2unix -p
|
||||||
DOS2UNIX_DARWIN=env/darwin/bin/dos2unix -p
|
DOS2UNIX_DARWIN=env/darwin/bin/dos2unix -p
|
||||||
VERSIONDUMP=./updateversion.sh
|
VERSIONDUMP=./updateversion.sh
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
set SOURCEDIR=src
|
set SOURCEDIR=src
|
||||||
set SMINCLUDES=env\include
|
set SMINCLUDES=env\include
|
||||||
set BUILDDIR=build
|
set BUILDDIR=build
|
||||||
set SPCOMP=env\win32\bin\spcomp-1.6.0.exe
|
set SPCOMP=env\win32\bin\spcomp-1.7.0.exe
|
||||||
set VERSIONDUMP=updateversion.bat
|
set VERSIONDUMP=updateversion.bat
|
||||||
|
|
||||||
:: Dump version and revision information first.
|
:: Dump version and revision information first.
|
||||||
|
|
BIN
env/darwin/bin/spcomp-1.7.0
vendored
Executable file
BIN
env/darwin/bin/spcomp-1.7.0
vendored
Executable file
Binary file not shown.
2
env/include/admin.inc
vendored
2
env/include/admin.inc
vendored
|
@ -356,7 +356,7 @@ native GetAdminUsername(AdminId:id, String:name[], maxlength);
|
||||||
* @param auth Auth method to use, predefined or from RegisterAuthIdentType().
|
* @param auth Auth method to use, predefined or from RegisterAuthIdentType().
|
||||||
* @param ident String containing the arbitrary, unique identity.
|
* @param ident String containing the arbitrary, unique identity.
|
||||||
* @return True on success, false if the auth method was not found,
|
* @return True on success, false if the auth method was not found,
|
||||||
* or ident was already taken.
|
* ident was already taken, or ident invalid for auth method.
|
||||||
*/
|
*/
|
||||||
native bool:BindAdminIdentity(AdminId:id, const String:auth[], const String:ident[]);
|
native bool:BindAdminIdentity(AdminId:id, const String:auth[], const String:ident[]);
|
||||||
|
|
||||||
|
|
6
env/include/adminmenu.inc
vendored
6
env/include/adminmenu.inc
vendored
|
@ -65,7 +65,7 @@
|
||||||
* @param topmenu Handle to the admin menu's TopMenu.
|
* @param topmenu Handle to the admin menu's TopMenu.
|
||||||
* @noreturn
|
* @noreturn
|
||||||
*/
|
*/
|
||||||
forward OnAdminMenuCreated(Handle:topmenu);
|
forward OnAdminMenuCreated(Handle topmenu);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when the admin menu is ready to have items added.
|
* Called when the admin menu is ready to have items added.
|
||||||
|
@ -73,7 +73,7 @@ forward OnAdminMenuCreated(Handle:topmenu);
|
||||||
* @param topmenu Handle to the admin menu's TopMenu.
|
* @param topmenu Handle to the admin menu's TopMenu.
|
||||||
* @noreturn
|
* @noreturn
|
||||||
*/
|
*/
|
||||||
forward OnAdminMenuReady(Handle:topmenu);
|
forward OnAdminMenuReady(Handle topmenu);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieves the Handle to the admin top menu.
|
* Retrieves the Handle to the admin top menu.
|
||||||
|
@ -81,7 +81,7 @@ forward OnAdminMenuReady(Handle:topmenu);
|
||||||
* @return Handle to the admin menu's TopMenu,
|
* @return Handle to the admin menu's TopMenu,
|
||||||
* or INVALID_HANDLE if not created yet.
|
* or INVALID_HANDLE if not created yet.
|
||||||
*/
|
*/
|
||||||
native Handle:GetAdminTopMenu();
|
native TopMenu GetAdminTopMenu();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds targets to an admin menu.
|
* Adds targets to an admin menu.
|
||||||
|
|
212
env/include/adt_array.inc
vendored
212
env/include/adt_array.inc
vendored
|
@ -1,7 +1,7 @@
|
||||||
/**
|
/**
|
||||||
* vim: set ts=4 :
|
* vim: set ts=4 sw=4 tw=99 noet :
|
||||||
* =============================================================================
|
* =============================================================================
|
||||||
* SourceMod (C)2004-2008 AlliedModders LLC. All rights reserved.
|
* SourceMod (C)2004-2014 AlliedModders LLC. All rights reserved.
|
||||||
* =============================================================================
|
* =============================================================================
|
||||||
*
|
*
|
||||||
* This file is part of the SourceMod/SourcePawn SDK.
|
* This file is part of the SourceMod/SourcePawn SDK.
|
||||||
|
@ -45,13 +45,172 @@
|
||||||
stock ByteCountToCells(size)
|
stock ByteCountToCells(size)
|
||||||
{
|
{
|
||||||
if (!size)
|
if (!size)
|
||||||
{
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
|
||||||
|
|
||||||
return (size + 3) / 4;
|
return (size + 3) / 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
methodmap ArrayList < Handle {
|
||||||
|
// Creates a dynamic global cell array. While slower than a normal array,
|
||||||
|
// it can be used globally AND dynamically, which is otherwise impossible.
|
||||||
|
//
|
||||||
|
// The contents of the array are uniform; i.e. storing a string at index X
|
||||||
|
// and then retrieving it as an integer is NOT the same as StringToInt()!
|
||||||
|
// The "blocksize" determines how many cells each array slot has; it cannot
|
||||||
|
// be changed after creation.
|
||||||
|
//
|
||||||
|
// @param blocksize The number of cells each member of the array can
|
||||||
|
// hold. For example, 32 cells is equivalent to:
|
||||||
|
// new Array[X][32]
|
||||||
|
// @param startsize Initial size of the array. Note that data will
|
||||||
|
// NOT be auto-intialized.
|
||||||
|
// @return New Handle to the array object.
|
||||||
|
public native ArrayList(int blocksize=1, int startsize=0);
|
||||||
|
|
||||||
|
// Clears an array of all entries. This is the same as Resize(0).
|
||||||
|
public native void Clear();
|
||||||
|
|
||||||
|
// Clones an array, returning a new handle with the same size and data.
|
||||||
|
// This should NOT be confused with CloneHandle. This is a completely new
|
||||||
|
// handle with the same data but no relation to the original. It should
|
||||||
|
// closed when no longer needed.
|
||||||
|
//
|
||||||
|
// @return New handle to the cloned array object
|
||||||
|
public native ArrayList Clone();
|
||||||
|
|
||||||
|
// Resizes an array. If the size is smaller than the current size, the
|
||||||
|
// array is truncated.
|
||||||
|
//
|
||||||
|
// @param newsize New size.
|
||||||
|
public native void Resize(int newsize);
|
||||||
|
|
||||||
|
// Pushes a value onto the end of an array, adding a new index.
|
||||||
|
//
|
||||||
|
// This may safely be used even if the array has a blocksize greater
|
||||||
|
// than 1.
|
||||||
|
//
|
||||||
|
// @param value Value to push.
|
||||||
|
// @return Index of the new entry.
|
||||||
|
// @error Invalid Handle or out of memory.
|
||||||
|
//
|
||||||
|
public native int Push(any value);
|
||||||
|
|
||||||
|
// Pushes a string onto the end of an array, truncating it if it is too big.
|
||||||
|
//
|
||||||
|
// @param value String to push.
|
||||||
|
// @return Index of the new entry.
|
||||||
|
public native int PushString(const char[] value);
|
||||||
|
|
||||||
|
// Pushes an array of cells onto the end of an array. The cells
|
||||||
|
// are pushed as a block (i.e. the entire array sits at the index),
|
||||||
|
// rather than pushing each cell individually.
|
||||||
|
//
|
||||||
|
// @param values Block of values to copy.
|
||||||
|
// @param size If not set, the number of elements copied from the array
|
||||||
|
// will be equal to the blocksize. If set higher than the
|
||||||
|
// blocksize, the operation will be truncated.
|
||||||
|
// @return Index of the new entry.
|
||||||
|
public native int PushArray(const any[] values, int size=-1);
|
||||||
|
|
||||||
|
// Retrieves a cell value from an array.
|
||||||
|
//
|
||||||
|
// @param index Index in the array.
|
||||||
|
// @param block Optionally specify which block to read from
|
||||||
|
// (useful if the blocksize > 0).
|
||||||
|
// @param asChar Optionally read as a byte instead of a cell.
|
||||||
|
// @return Value read.
|
||||||
|
// @error Invalid index.
|
||||||
|
public native any Get(int index, int block=0, bool asChar=false);
|
||||||
|
|
||||||
|
// Retrieves a string value from an array.
|
||||||
|
//
|
||||||
|
// @param index Index in the array.
|
||||||
|
// @param buffer Buffer to copy to.
|
||||||
|
// @param maxlength Maximum size of the buffer.
|
||||||
|
// @return Number of characters copied.
|
||||||
|
// @error Invalid index.
|
||||||
|
public native int GetString(int index, char[] buffer, maxlength);
|
||||||
|
|
||||||
|
// Retrieves an array of cells from an array.
|
||||||
|
//
|
||||||
|
// @param index Index in the array.
|
||||||
|
// @param buffer Buffer to store the array in.
|
||||||
|
// @param size If not set, assumes the buffer size is equal to the
|
||||||
|
// blocksize. Otherwise, the size passed is used.
|
||||||
|
// @return Number of cells copied.
|
||||||
|
// @error Invalid index.
|
||||||
|
public native int GetArray(int index, any[] buffer, int size=-1);
|
||||||
|
|
||||||
|
// Sets a cell value in an array.
|
||||||
|
//
|
||||||
|
// @param index Index in the array.
|
||||||
|
// @param value Cell value to set.
|
||||||
|
// @param block Optionally specify which block to write to
|
||||||
|
// (useful if the blocksize > 0).
|
||||||
|
// @param asChar Optionally set as a byte instead of a cell.
|
||||||
|
// @error Invalid index, or invalid block.
|
||||||
|
public native void Set(int index, any value, int block=0, bool asChar=false);
|
||||||
|
|
||||||
|
// Sets a string value in an array.
|
||||||
|
//
|
||||||
|
// @param index Index in the array.
|
||||||
|
// @param value String value to set.
|
||||||
|
// @return Number of characters copied.
|
||||||
|
// @error Invalid index.
|
||||||
|
public native void SetString(int index, const char[] value);
|
||||||
|
|
||||||
|
// Sets an array of cells in an array.
|
||||||
|
//
|
||||||
|
// @param index Index in the array.
|
||||||
|
// @param values Array to copy.
|
||||||
|
// @param size If not set, assumes the buffer size is equal to the
|
||||||
|
// blocksize. Otherwise, the size passed is used.
|
||||||
|
// @return Number of cells copied.
|
||||||
|
// @error Invalid index.
|
||||||
|
public native void SetArray(int index, const any[] values, int size=-1);
|
||||||
|
|
||||||
|
// Shifts an array up. All array contents after and including the given
|
||||||
|
// index are shifted up by one, and the given index is then "free."
|
||||||
|
// After shifting, the contents of the given index is undefined.
|
||||||
|
//
|
||||||
|
// @param index Index in the array to shift up from.
|
||||||
|
// @error Invalid index.
|
||||||
|
public native void ShiftUp(int index);
|
||||||
|
|
||||||
|
// Removes an array index, shifting the entire array down from that position
|
||||||
|
// on. For example, if item 8 of 10 is removed, the last 3 items will then be
|
||||||
|
// (6,7,8) instead of (7,8,9), and all indexes before 8 will remain unchanged.
|
||||||
|
//
|
||||||
|
// @param index Index in the array to remove at.
|
||||||
|
// @error Invalid index.
|
||||||
|
public native void Erase(int index);
|
||||||
|
|
||||||
|
// Swaps two items in the array.
|
||||||
|
//
|
||||||
|
// @param index1 First index.
|
||||||
|
// @param index2 Second index.
|
||||||
|
// @error Invalid index.
|
||||||
|
public native void SwapAt(int index1, int index2);
|
||||||
|
|
||||||
|
// Returns the index for the first occurance of the provided string. If
|
||||||
|
// the string cannot be located, -1 will be returned.
|
||||||
|
//
|
||||||
|
// @param item String to search for
|
||||||
|
// @return Array index, or -1 on failure
|
||||||
|
public native int FindString(const char[] item);
|
||||||
|
|
||||||
|
// Returns the index for the first occurance of the provided value. If the
|
||||||
|
// value cannot be located, -1 will be returned.
|
||||||
|
//
|
||||||
|
// @param item Value to search for
|
||||||
|
// @return Array index, or -1 on failure
|
||||||
|
public native int FindValue(any item);
|
||||||
|
|
||||||
|
// Retrieve the size of the array.
|
||||||
|
property int Length {
|
||||||
|
public native get();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a dynamic global cell array. While slower than a normal array,
|
* Creates a dynamic global cell array. While slower than a normal array,
|
||||||
* it can be used globally AND dynamically, which is otherwise impossible.
|
* it can be used globally AND dynamically, which is otherwise impossible.
|
||||||
|
@ -68,16 +227,15 @@ stock ByteCountToCells(size)
|
||||||
* NOT be auto-intialized.
|
* NOT be auto-intialized.
|
||||||
* @return New Handle to the array object.
|
* @return New Handle to the array object.
|
||||||
*/
|
*/
|
||||||
native Handle:CreateArray(blocksize=1, startsize=0);
|
native ArrayList CreateArray(int blocksize=1, int startsize=0);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Clears an array of all entries. This is the same as ResizeArray(0).
|
* Clears an array of all entries. This is the same as ResizeArray(0).
|
||||||
*
|
*
|
||||||
* @param array Array Handle.
|
* @param array Array Handle.
|
||||||
* @noreturn
|
|
||||||
* @error Invalid Handle.
|
* @error Invalid Handle.
|
||||||
*/
|
*/
|
||||||
native ClearArray(Handle:array);
|
native void ClearArray(Handle array);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Clones an array, returning a new handle with the same size and data. This should NOT
|
* Clones an array, returning a new handle with the same size and data. This should NOT
|
||||||
|
@ -88,7 +246,7 @@ native ClearArray(Handle:array);
|
||||||
* @return New handle to the cloned array object
|
* @return New handle to the cloned array object
|
||||||
* @error Invalid Handle
|
* @error Invalid Handle
|
||||||
*/
|
*/
|
||||||
native Handle:CloneArray(Handle:array);
|
native Handle CloneArray(Handle array);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Resizes an array. If the size is smaller than the current size,
|
* Resizes an array. If the size is smaller than the current size,
|
||||||
|
@ -99,7 +257,7 @@ native Handle:CloneArray(Handle:array);
|
||||||
* @noreturn
|
* @noreturn
|
||||||
* @error Invalid Handle or out of memory.
|
* @error Invalid Handle or out of memory.
|
||||||
*/
|
*/
|
||||||
native bool:ResizeArray(Handle:array, newsize);
|
native bool ResizeArray(Handle array, int newsize);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the array size.
|
* Returns the array size.
|
||||||
|
@ -108,7 +266,7 @@ native bool:ResizeArray(Handle:array, newsize);
|
||||||
* @return Number of elements in the array.
|
* @return Number of elements in the array.
|
||||||
* @error Invalid Handle.
|
* @error Invalid Handle.
|
||||||
*/
|
*/
|
||||||
native GetArraySize(Handle:array);
|
native int GetArraySize(Handle array);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Pushes a value onto the end of an array, adding a new index.
|
* Pushes a value onto the end of an array, adding a new index.
|
||||||
|
@ -121,7 +279,7 @@ native GetArraySize(Handle:array);
|
||||||
* @return Index of the new entry.
|
* @return Index of the new entry.
|
||||||
* @error Invalid Handle or out of memory.
|
* @error Invalid Handle or out of memory.
|
||||||
*/
|
*/
|
||||||
native PushArrayCell(Handle:array, any:value);
|
native int PushArrayCell(Handle array, any value);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Pushes a string onto the end of an array, truncating it
|
* Pushes a string onto the end of an array, truncating it
|
||||||
|
@ -132,7 +290,7 @@ native PushArrayCell(Handle:array, any:value);
|
||||||
* @return Index of the new entry.
|
* @return Index of the new entry.
|
||||||
* @error Invalid Handle or out of memory.
|
* @error Invalid Handle or out of memory.
|
||||||
*/
|
*/
|
||||||
native PushArrayString(Handle:array, const String:value[]);
|
native int PushArrayString(Handle array, const char[] value);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Pushes an array of cells onto the end of an array. The cells
|
* Pushes an array of cells onto the end of an array. The cells
|
||||||
|
@ -147,7 +305,7 @@ native PushArrayString(Handle:array, const String:value[]);
|
||||||
* @return Index of the new entry.
|
* @return Index of the new entry.
|
||||||
* @error Invalid Handle or out of memory.
|
* @error Invalid Handle or out of memory.
|
||||||
*/
|
*/
|
||||||
native PushArrayArray(Handle:array, const any:values[], size=-1);
|
native int PushArrayArray(Handle array, const any[] values, int size=-1);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieves a cell value from an array.
|
* Retrieves a cell value from an array.
|
||||||
|
@ -160,7 +318,7 @@ native PushArrayArray(Handle:array, const any:values[], size=-1);
|
||||||
* @return Value read.
|
* @return Value read.
|
||||||
* @error Invalid Handle, invalid index, or invalid block.
|
* @error Invalid Handle, invalid index, or invalid block.
|
||||||
*/
|
*/
|
||||||
native any:GetArrayCell(Handle:array, index, block=0, bool:asChar=false);
|
native any GetArrayCell(Handle array, int index, int block=0, bool asChar=false);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieves a string value from an array.
|
* Retrieves a string value from an array.
|
||||||
|
@ -172,7 +330,7 @@ native any:GetArrayCell(Handle:array, index, block=0, bool:asChar=false);
|
||||||
* @return Number of characters copied.
|
* @return Number of characters copied.
|
||||||
* @error Invalid Handle or invalid index.
|
* @error Invalid Handle or invalid index.
|
||||||
*/
|
*/
|
||||||
native GetArrayString(Handle:array, index, String:buffer[], maxlength);
|
native int GetArrayString(Handle array, int index, char[] buffer, maxlength);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieves an array of cells from an array.
|
* Retrieves an array of cells from an array.
|
||||||
|
@ -185,7 +343,7 @@ native GetArrayString(Handle:array, index, String:buffer[], maxlength);
|
||||||
* @return Number of cells copied.
|
* @return Number of cells copied.
|
||||||
* @error Invalid Handle or invalid index.
|
* @error Invalid Handle or invalid index.
|
||||||
*/
|
*/
|
||||||
native GetArrayArray(Handle:array, index, any:buffer[], size=-1);
|
native int GetArrayArray(Handle array, int index, any[] buffer, int size=-1);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets a cell value in an array.
|
* Sets a cell value in an array.
|
||||||
|
@ -196,10 +354,9 @@ native GetArrayArray(Handle:array, index, any:buffer[], size=-1);
|
||||||
* @param block Optionally specify which block to write to
|
* @param block Optionally specify which block to write to
|
||||||
* (useful if the blocksize > 0).
|
* (useful if the blocksize > 0).
|
||||||
* @param asChar Optionally set as a byte instead of a cell.
|
* @param asChar Optionally set as a byte instead of a cell.
|
||||||
* @noreturn
|
|
||||||
* @error Invalid Handle, invalid index, or invalid block.
|
* @error Invalid Handle, invalid index, or invalid block.
|
||||||
*/
|
*/
|
||||||
native SetArrayCell(Handle:array, index, any:value, block=0, bool:asChar=false);
|
native void SetArrayCell(Handle array, int index, any value, int block=0, bool asChar=false);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets a string value in an array.
|
* Sets a string value in an array.
|
||||||
|
@ -210,7 +367,7 @@ native SetArrayCell(Handle:array, index, any:value, block=0, bool:asChar=false);
|
||||||
* @return Number of characters copied.
|
* @return Number of characters copied.
|
||||||
* @error Invalid Handle or invalid index.
|
* @error Invalid Handle or invalid index.
|
||||||
*/
|
*/
|
||||||
native SetArrayString(Handle:array, index, const String:value[]);
|
native int SetArrayString(Handle array, int index, const char[] value);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets an array of cells in an array.
|
* Sets an array of cells in an array.
|
||||||
|
@ -223,7 +380,7 @@ native SetArrayString(Handle:array, index, const String:value[]);
|
||||||
* @return Number of cells copied.
|
* @return Number of cells copied.
|
||||||
* @error Invalid Handle or invalid index.
|
* @error Invalid Handle or invalid index.
|
||||||
*/
|
*/
|
||||||
native SetArrayArray(Handle:array, index, const any:values[], size=-1);
|
native int SetArrayArray(Handle array, int index, const any[] values, int size=-1);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Shifts an array up. All array contents after and including the given
|
* Shifts an array up. All array contents after and including the given
|
||||||
|
@ -232,10 +389,9 @@ native SetArrayArray(Handle:array, index, const any:values[], size=-1);
|
||||||
*
|
*
|
||||||
* @param array Array Handle.
|
* @param array Array Handle.
|
||||||
* @param index Index in the array to shift up from.
|
* @param index Index in the array to shift up from.
|
||||||
* @noreturn
|
|
||||||
* @error Invalid Handle or invalid index.
|
* @error Invalid Handle or invalid index.
|
||||||
*/
|
*/
|
||||||
native ShiftArrayUp(Handle:array, index);
|
native void ShiftArrayUp(Handle array, int index);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Removes an array index, shifting the entire array down from that position
|
* Removes an array index, shifting the entire array down from that position
|
||||||
|
@ -244,10 +400,9 @@ native ShiftArrayUp(Handle:array, index);
|
||||||
*
|
*
|
||||||
* @param array Array Handle.
|
* @param array Array Handle.
|
||||||
* @param index Index in the array to remove at.
|
* @param index Index in the array to remove at.
|
||||||
* @noreturn
|
|
||||||
* @error Invalid Handle or invalid index.
|
* @error Invalid Handle or invalid index.
|
||||||
*/
|
*/
|
||||||
native RemoveFromArray(Handle:array, index);
|
native void RemoveFromArray(Handle array, int index);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Swaps two items in the array.
|
* Swaps two items in the array.
|
||||||
|
@ -255,10 +410,9 @@ native RemoveFromArray(Handle:array, index);
|
||||||
* @param array Array Handle.
|
* @param array Array Handle.
|
||||||
* @param index1 First index.
|
* @param index1 First index.
|
||||||
* @param index2 Second index.
|
* @param index2 Second index.
|
||||||
* @noreturn
|
|
||||||
* @error Invalid Handle or invalid index.
|
* @error Invalid Handle or invalid index.
|
||||||
*/
|
*/
|
||||||
native SwapArrayItems(Handle:array, index1, index2);
|
native void SwapArrayItems(Handle array, int index1, int index2);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the index for the first occurance of the provided string. If the string
|
* Returns the index for the first occurance of the provided string. If the string
|
||||||
|
@ -269,7 +423,7 @@ native SwapArrayItems(Handle:array, index1, index2);
|
||||||
* @return Array index, or -1 on failure
|
* @return Array index, or -1 on failure
|
||||||
* @error Invalid Handle
|
* @error Invalid Handle
|
||||||
*/
|
*/
|
||||||
native FindStringInArray(Handle:array, const String:item[]);
|
native int FindStringInArray(Handle array, const char[] item);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the index for the first occurance of the provided value. If the value
|
* Returns the index for the first occurance of the provided value. If the value
|
||||||
|
@ -280,4 +434,4 @@ native FindStringInArray(Handle:array, const String:item[]);
|
||||||
* @return Array index, or -1 on failure
|
* @return Array index, or -1 on failure
|
||||||
* @error Invalid Handle
|
* @error Invalid Handle
|
||||||
*/
|
*/
|
||||||
native FindValueInArray(Handle:array, any:item);
|
native int FindValueInArray(Handle array, any item);
|
||||||
|
|
106
env/include/adt_stack.inc
vendored
106
env/include/adt_stack.inc
vendored
|
@ -1,7 +1,7 @@
|
||||||
/**
|
/**
|
||||||
* vim: set ts=4 :
|
* vim: set ts=4 sw=4 tw=99 noet :
|
||||||
* =============================================================================
|
* =============================================================================
|
||||||
* SourceMod (C)2004-2008 AlliedModders LLC. All rights reserved.
|
* SourceMod (C)2004-2014 AlliedModders LLC. All rights reserved.
|
||||||
* =============================================================================
|
* =============================================================================
|
||||||
*
|
*
|
||||||
* This file is part of the SourceMod/SourcePawn SDK.
|
* This file is part of the SourceMod/SourcePawn SDK.
|
||||||
|
@ -35,6 +35,82 @@
|
||||||
#endif
|
#endif
|
||||||
#define _adt_stack_included
|
#define _adt_stack_included
|
||||||
|
|
||||||
|
methodmap ArrayStack < Handle
|
||||||
|
{
|
||||||
|
// Creates a stack structure. A stack is a LIFO (last in, first out)
|
||||||
|
// vector (array) of items. It has O(1) insertion and O(1) removal.
|
||||||
|
//
|
||||||
|
// Stacks have two operations: Push (adding an item) and Pop (removes
|
||||||
|
// items in reverse-push order).
|
||||||
|
//
|
||||||
|
// The contents of the stack are uniform; i.e. storing a string and then
|
||||||
|
// retrieving it as an integer is NOT the same as StringToInt()!
|
||||||
|
//
|
||||||
|
// The "blocksize" determines how many cells each slot has; it cannot
|
||||||
|
// be changed after creation.
|
||||||
|
//
|
||||||
|
// @param blocksize The number of cells each entry in the stack can
|
||||||
|
// hold. For example, 32 cells is equivalent to:
|
||||||
|
// new Array[X][32]
|
||||||
|
public native ArrayStack(int blocksize=1);
|
||||||
|
|
||||||
|
// Pushes a value onto the end of the stack, adding a new index.
|
||||||
|
//
|
||||||
|
// This may safely be used even if the stack has a blocksize
|
||||||
|
// greater than 1.
|
||||||
|
//
|
||||||
|
// @param value Value to push.
|
||||||
|
public native void Push(any value);
|
||||||
|
|
||||||
|
// Pushes a copy of a string onto the end of a stack, truncating it if it
|
||||||
|
// is too big.
|
||||||
|
//
|
||||||
|
// @param value String to push.
|
||||||
|
public native void PushString(const char[] value);
|
||||||
|
|
||||||
|
// Pushes a copy of an array of cells onto the end of a stack. The cells
|
||||||
|
// are pushed as a block (i.e. the entire array takes up one stack slot),
|
||||||
|
// rather than pushing each cell individually.
|
||||||
|
//
|
||||||
|
// @param stack Stack Handle.
|
||||||
|
// @param values Block of values to copy.
|
||||||
|
// @param size If not set, the number of elements copied from the array
|
||||||
|
// will be equal to the blocksize. If set higher than the
|
||||||
|
// blocksize, the operation will be truncated.
|
||||||
|
public native void PushArray(const any[] values, int size=-1);
|
||||||
|
|
||||||
|
// Pops a cell value from a stack.
|
||||||
|
//
|
||||||
|
// @param block Optionally specify which block to read from
|
||||||
|
// (useful if the blocksize > 0).
|
||||||
|
// @param asChar Optionally read as a byte instead of a cell.
|
||||||
|
// @return True on success, false if the stack is empty.
|
||||||
|
// @error The stack is empty.
|
||||||
|
public native any Pop(int block=0, bool asChar=false);
|
||||||
|
|
||||||
|
// Pops a string value from a stack.
|
||||||
|
//
|
||||||
|
// @param buffer Buffer to store string.
|
||||||
|
// @param maxlength Maximum size of the buffer.
|
||||||
|
// @oaram written Number of characters written to buffer, not including
|
||||||
|
// the null terminator.
|
||||||
|
// @error The stack is empty.
|
||||||
|
public native void PopString(char[] buffer, int maxlength, int &written = 0);
|
||||||
|
|
||||||
|
// Pops an array of cells from a stack.
|
||||||
|
//
|
||||||
|
// @param buffer Buffer to store the array in.
|
||||||
|
// @param size If not set, assumes the buffer size is equal to the
|
||||||
|
// blocksize. Otherwise, the size passed is used.
|
||||||
|
// @error The stack is empty.
|
||||||
|
public native void PopArray(any[] buffer, int size=-1);
|
||||||
|
|
||||||
|
// Returns true if the stack is empty, false otherwise.
|
||||||
|
property bool Empty {
|
||||||
|
public native get();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a stack structure. A stack is a LIFO (last in, first out)
|
* Creates a stack structure. A stack is a LIFO (last in, first out)
|
||||||
* vector (array) of items. It has O(1) insertion and O(1) removal.
|
* vector (array) of items. It has O(1) insertion and O(1) removal.
|
||||||
|
@ -53,7 +129,7 @@
|
||||||
* new Array[X][32]
|
* new Array[X][32]
|
||||||
* @return New stack Handle.
|
* @return New stack Handle.
|
||||||
*/
|
*/
|
||||||
native Handle:CreateStack(blocksize=1);
|
native ArrayStack CreateStack(int blocksize=1);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Pushes a value onto the end of the stack, adding a new index.
|
* Pushes a value onto the end of the stack, adding a new index.
|
||||||
|
@ -63,24 +139,22 @@ native Handle:CreateStack(blocksize=1);
|
||||||
*
|
*
|
||||||
* @param stack Stack Handle.
|
* @param stack Stack Handle.
|
||||||
* @param value Value to push.
|
* @param value Value to push.
|
||||||
* @noreturn
|
|
||||||
* @error Invalid Handle or out of memory.
|
* @error Invalid Handle or out of memory.
|
||||||
*/
|
*/
|
||||||
native PushStackCell(Handle:stack, any:value);
|
native void PushStackCell(Handle stack, any value);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Pushes a string onto the end of a stack, truncating it if it is
|
* Pushes a copy of a string onto the end of a stack, truncating it if it is
|
||||||
* too big.
|
* too big.
|
||||||
*
|
*
|
||||||
* @param stack Stack Handle.
|
* @param stack Stack Handle.
|
||||||
* @param value String to push.
|
* @param value String to push.
|
||||||
* @noreturn
|
|
||||||
* @error Invalid Handle or out of memory.
|
* @error Invalid Handle or out of memory.
|
||||||
*/
|
*/
|
||||||
native PushStackString(Handle:stack, const String:value[]);
|
native void PushStackString(Handle stack, const char[] value);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Pushes an array of cells onto the end of a stack. The cells
|
* Pushes a copy of an array of cells onto the end of a stack. The cells
|
||||||
* are pushed as a block (i.e. the entire array takes up one stack slot),
|
* are pushed as a block (i.e. the entire array takes up one stack slot),
|
||||||
* rather than pushing each cell individually.
|
* rather than pushing each cell individually.
|
||||||
*
|
*
|
||||||
|
@ -89,10 +163,9 @@ native PushStackString(Handle:stack, const String:value[]);
|
||||||
* @param size If not set, the number of elements copied from the array
|
* @param size If not set, the number of elements copied from the array
|
||||||
* will be equal to the blocksize. If set higher than the
|
* will be equal to the blocksize. If set higher than the
|
||||||
* blocksize, the operation will be truncated.
|
* blocksize, the operation will be truncated.
|
||||||
* @noreturn
|
|
||||||
* @error Invalid Handle or out of memory.
|
* @error Invalid Handle or out of memory.
|
||||||
*/
|
*/
|
||||||
native PushStackArray(Handle:stack, const any:values[], size=-1);
|
native void PushStackArray(Handle stack, const any[] values, int size=-1);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Pops a cell value from a stack.
|
* Pops a cell value from a stack.
|
||||||
|
@ -105,7 +178,7 @@ native PushStackArray(Handle:stack, const any:values[], size=-1);
|
||||||
* @return True on success, false if the stack is empty.
|
* @return True on success, false if the stack is empty.
|
||||||
* @error Invalid Handle.
|
* @error Invalid Handle.
|
||||||
*/
|
*/
|
||||||
native bool:PopStackCell(Handle:stack, &any:value, block=0, bool:asChar=false);
|
native bool PopStackCell(Handle stack, any &value, int block=0, bool asChar=false);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Pops a string value from a stack.
|
* Pops a string value from a stack.
|
||||||
|
@ -116,7 +189,7 @@ native bool:PopStackCell(Handle:stack, &any:value, block=0, bool:asChar=false);
|
||||||
* @return True on success, false if the stack is empty.
|
* @return True on success, false if the stack is empty.
|
||||||
* @error Invalid Handle.
|
* @error Invalid Handle.
|
||||||
*/
|
*/
|
||||||
native bool:PopStackString(Handle:stack, String:buffer[], maxlength, &written=0);
|
native bool PopStackString(Handle stack, char[] buffer, int maxlength, int &written=0);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Pops an array of cells from a stack.
|
* Pops an array of cells from a stack.
|
||||||
|
@ -128,7 +201,7 @@ native bool:PopStackString(Handle:stack, String:buffer[], maxlength, &written=0)
|
||||||
* @return True on success, false if the stack is empty.
|
* @return True on success, false if the stack is empty.
|
||||||
* @error Invalid Handle.
|
* @error Invalid Handle.
|
||||||
*/
|
*/
|
||||||
native bool:PopStackArray(Handle:stack, any:buffer[], size=-1);
|
native bool PopStackArray(Handle stack, any[] buffer, int size=-1);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if a stack is empty.
|
* Checks if a stack is empty.
|
||||||
|
@ -137,7 +210,7 @@ native bool:PopStackArray(Handle:stack, any:buffer[], size=-1);
|
||||||
* @return True if empty, false if not empty.
|
* @return True if empty, false if not empty.
|
||||||
* @error Invalid Handle.
|
* @error Invalid Handle.
|
||||||
*/
|
*/
|
||||||
native bool:IsStackEmpty(Handle:stack);
|
native bool IsStackEmpty(Handle stack);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Pops a value off a stack, ignoring it completely.
|
* Pops a value off a stack, ignoring it completely.
|
||||||
|
@ -146,9 +219,8 @@ native bool:IsStackEmpty(Handle:stack);
|
||||||
* @return True if something was popped, false otherwise.
|
* @return True if something was popped, false otherwise.
|
||||||
* @error Invalid Handle.
|
* @error Invalid Handle.
|
||||||
*/
|
*/
|
||||||
stock PopStack(Handle:stack)
|
stock bool PopStack(Handle stack)
|
||||||
{
|
{
|
||||||
new value;
|
new value;
|
||||||
|
|
||||||
return PopStackCell(stack, value);
|
return PopStackCell(stack, value);
|
||||||
}
|
}
|
||||||
|
|
183
env/include/adt_trie.inc
vendored
183
env/include/adt_trie.inc
vendored
|
@ -1,7 +1,7 @@
|
||||||
/**
|
/**
|
||||||
* vim: set ts=4 sw=4 tw=99 noet :
|
* vim: set ts=4 sw=4 tw=99 noet :
|
||||||
* =============================================================================
|
* =============================================================================
|
||||||
* SourceMod (C)2004-2008 AlliedModders LLC. All rights reserved.
|
* SourceMod (C)2004-2014 AlliedModders LLC. All rights reserved.
|
||||||
* =============================================================================
|
* =============================================================================
|
||||||
*
|
*
|
||||||
* This file is part of the SourceMod/SourcePawn SDK.
|
* This file is part of the SourceMod/SourcePawn SDK.
|
||||||
|
@ -35,6 +35,123 @@
|
||||||
#endif
|
#endif
|
||||||
#define _adt_trie_included
|
#define _adt_trie_included
|
||||||
|
|
||||||
|
/* Object-oriented wrapper for maps. */
|
||||||
|
methodmap StringMap < Handle
|
||||||
|
{
|
||||||
|
// Creates a hash map. A hash map is a container that can map strings (called
|
||||||
|
// "keys") to arbitrary values (cells, arrays, or strings). Keys in a hash map
|
||||||
|
// are unique. That is, there is at most one entry in the map for a given key.
|
||||||
|
//
|
||||||
|
// Insertion, deletion, and lookup in a hash map are all considered to be fast
|
||||||
|
// operations, amortized to O(1), or constant time.
|
||||||
|
//
|
||||||
|
// The word "Trie" in this API is historical. As of SourceMod 1.6, tries have
|
||||||
|
// been internally replaced with hash tables, which have O(1) insertion time
|
||||||
|
// instead of O(n).
|
||||||
|
//
|
||||||
|
// The StringMap must be freed via delete or CloseHandle().
|
||||||
|
public native StringMap();
|
||||||
|
|
||||||
|
// Sets a value in a hash map, either inserting a new entry or replacing an old one.
|
||||||
|
//
|
||||||
|
// @param key Key string.
|
||||||
|
// @param value Value to store at this key.
|
||||||
|
// @param replace If false, operation will fail if the key is already set.
|
||||||
|
// @return True on success, false on failure.
|
||||||
|
public native bool SetValue(const char[] key, any value, bool replace=true);
|
||||||
|
|
||||||
|
// Sets an array value in a Map, either inserting a new entry or replacing an old one.
|
||||||
|
//
|
||||||
|
// @param key Key string.
|
||||||
|
// @param array Array to store.
|
||||||
|
// @param num_items Number of items in the array.
|
||||||
|
// @param replace If false, operation will fail if the key is already set.
|
||||||
|
// @return True on success, false on failure.
|
||||||
|
public native bool SetArray(const char[] key, const any[] array, int num_items, bool replace=true);
|
||||||
|
|
||||||
|
// Sets a string value in a Map, either inserting a new entry or replacing an old one.
|
||||||
|
//
|
||||||
|
// @param key Key string.
|
||||||
|
// @param value String to store.
|
||||||
|
// @param replace If false, operation will fail if the key is already set.
|
||||||
|
// @return True on success, false on failure.
|
||||||
|
public native bool SetString(const char[] key, const char[] value, bool replace=true);
|
||||||
|
|
||||||
|
// Retrieves a value in a Map.
|
||||||
|
//
|
||||||
|
// @param key Key string.
|
||||||
|
// @param value Variable to store value.
|
||||||
|
// @return True on success. False if the key is not set, or the key is set
|
||||||
|
// as an array or string (not a value).
|
||||||
|
public native bool GetValue(const char[] key, any &value);
|
||||||
|
|
||||||
|
// Retrieves an array in a Map.
|
||||||
|
//
|
||||||
|
// @param map Map Handle.
|
||||||
|
// @param key Key string.
|
||||||
|
// @param array Buffer to store array.
|
||||||
|
// @param max_size Maximum size of array buffer.
|
||||||
|
// @param size Optional parameter to store the number of elements written to the buffer.
|
||||||
|
// @return True on success. False if the key is not set, or the key is set
|
||||||
|
// as a value or string (not an array).
|
||||||
|
public native bool GetArray(const char[] key, any[] array, int max_size, int &size=0);
|
||||||
|
|
||||||
|
// Retrieves a string in a Map.
|
||||||
|
//
|
||||||
|
// @param key Key string.
|
||||||
|
// @param value Buffer to store value.
|
||||||
|
// @param max_size Maximum size of string buffer.
|
||||||
|
// @param size Optional parameter to store the number of bytes written to the buffer.
|
||||||
|
// @return True on success. False if the key is not set, or the key is set
|
||||||
|
// as a value or array (not a string).
|
||||||
|
public native bool GetString(const char[] key, char[] value, int max_size, int &size=0);
|
||||||
|
|
||||||
|
// Removes a key entry from a Map.
|
||||||
|
//
|
||||||
|
// @param key Key string.
|
||||||
|
// @return True on success, false if the value was never set.
|
||||||
|
public native bool Remove(const char[] key);
|
||||||
|
|
||||||
|
// Clears all entries from a Map.
|
||||||
|
public native void Clear();
|
||||||
|
|
||||||
|
// Create a snapshot of the map's keys. See StringMapSnapshot.
|
||||||
|
public native StringMapSnapshot Snapshot();
|
||||||
|
|
||||||
|
// Retrieves the number of elements in a map.
|
||||||
|
property int Size {
|
||||||
|
public native get();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// A StringMapSnapshot is created via StringMap.Snapshot(). It captures the
|
||||||
|
// keys on a map so they can be read. Snapshots must be freed with delete or
|
||||||
|
// CloseHandle().
|
||||||
|
methodmap StringMapSnapshot < Handle
|
||||||
|
{
|
||||||
|
// Returns the number of keys in the map snapshot.
|
||||||
|
property int Length {
|
||||||
|
public native get();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Returns the buffer size required to store a given key. That is, it
|
||||||
|
// returns the length of the key plus one.
|
||||||
|
//
|
||||||
|
// @param index Key index (starting from 0).
|
||||||
|
// @return Buffer size required to store the key string.
|
||||||
|
// @error Index out of range.
|
||||||
|
public native int KeyBufferSize(int index);
|
||||||
|
|
||||||
|
// Retrieves the key string of a given key in a map snapshot.
|
||||||
|
//
|
||||||
|
// @param index Key index (starting from 0).
|
||||||
|
// @param buffer String buffer.
|
||||||
|
// @param maxlength Maximum buffer length.
|
||||||
|
// @return Number of bytes written to the buffer.
|
||||||
|
// @error Index out of range.
|
||||||
|
public native int GetKey(int index, char[] buffer, int maxlength);
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a hash map. A hash map is a container that can map strings (called
|
* Creates a hash map. A hash map is a container that can map strings (called
|
||||||
* "keys") to arbitrary values (cells, arrays, or strings). Keys in a hash map
|
* "keys") to arbitrary values (cells, arrays, or strings). Keys in a hash map
|
||||||
|
@ -49,7 +166,7 @@
|
||||||
*
|
*
|
||||||
* @return New Map Handle, which must be freed via CloseHandle().
|
* @return New Map Handle, which must be freed via CloseHandle().
|
||||||
*/
|
*/
|
||||||
native Handle:CreateTrie();
|
native StringMap:CreateTrie();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets a value in a hash map, either inserting a new entry or replacing an old one.
|
* Sets a value in a hash map, either inserting a new entry or replacing an old one.
|
||||||
|
@ -61,7 +178,7 @@ native Handle:CreateTrie();
|
||||||
* @return True on success, false on failure.
|
* @return True on success, false on failure.
|
||||||
* @error Invalid Handle.
|
* @error Invalid Handle.
|
||||||
*/
|
*/
|
||||||
native bool:SetTrieValue(Handle:map, const String:key[], any:value, bool:replace=true);
|
native bool SetTrieValue(Handle map, const char[] key, any value, bool replace=true);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets an array value in a Map, either inserting a new entry or replacing an old one.
|
* Sets an array value in a Map, either inserting a new entry or replacing an old one.
|
||||||
|
@ -74,7 +191,7 @@ native bool:SetTrieValue(Handle:map, const String:key[], any:value, bool:replace
|
||||||
* @return True on success, false on failure.
|
* @return True on success, false on failure.
|
||||||
* @error Invalid Handle.
|
* @error Invalid Handle.
|
||||||
*/
|
*/
|
||||||
native bool:SetTrieArray(Handle:map, const String:key[], const any:array[], num_items, bool:replace=true);
|
native bool SetTrieArray(Handle map, const char[] key, const any[] array, int num_items, bool replace=true);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets a string value in a Map, either inserting a new entry or replacing an old one.
|
* Sets a string value in a Map, either inserting a new entry or replacing an old one.
|
||||||
|
@ -86,7 +203,7 @@ native bool:SetTrieArray(Handle:map, const String:key[], const any:array[], num_
|
||||||
* @return True on success, false on failure.
|
* @return True on success, false on failure.
|
||||||
* @error Invalid Handle.
|
* @error Invalid Handle.
|
||||||
*/
|
*/
|
||||||
native bool:SetTrieString(Handle:map, const String:key[], const String:value[], bool:replace=true);
|
native bool SetTrieString(Handle map, const char[] key, const char[] value, bool replace=true);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieves a value in a Map.
|
* Retrieves a value in a Map.
|
||||||
|
@ -98,7 +215,7 @@ native bool:SetTrieString(Handle:map, const String:key[], const String:value[],
|
||||||
* as an array or string (not a value).
|
* as an array or string (not a value).
|
||||||
* @error Invalid Handle.
|
* @error Invalid Handle.
|
||||||
*/
|
*/
|
||||||
native bool:GetTrieValue(Handle:map, const String:key[], &any:value);
|
native bool GetTrieValue(Handle map, const char[] key, any &value);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieves an array in a Map.
|
* Retrieves an array in a Map.
|
||||||
|
@ -112,7 +229,7 @@ native bool:GetTrieValue(Handle:map, const String:key[], &any:value);
|
||||||
* as a value or string (not an array).
|
* as a value or string (not an array).
|
||||||
* @error Invalid Handle.
|
* @error Invalid Handle.
|
||||||
*/
|
*/
|
||||||
native bool:GetTrieArray(Handle:map, const String:key[], any:array[], max_size, &size=0);
|
native bool GetTrieArray(Handle map, const char[] key, any[] array, int max_size, int &size=0);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieves a string in a Map.
|
* Retrieves a string in a Map.
|
||||||
|
@ -126,7 +243,7 @@ native bool:GetTrieArray(Handle:map, const String:key[], any:array[], max_size,
|
||||||
* as a value or array (not a string).
|
* as a value or array (not a string).
|
||||||
* @error Invalid Handle.
|
* @error Invalid Handle.
|
||||||
*/
|
*/
|
||||||
native bool:GetTrieString(Handle:map, const String:key[], String:value[], max_size, &size=0);
|
native bool GetTrieString(Handle map, const char[] key, char[] value, int max_size, int &size=0);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Removes a key entry from a Map.
|
* Removes a key entry from a Map.
|
||||||
|
@ -136,7 +253,7 @@ native bool:GetTrieString(Handle:map, const String:key[], String:value[], max_si
|
||||||
* @return True on success, false if the value was never set.
|
* @return True on success, false if the value was never set.
|
||||||
* @error Invalid Handle.
|
* @error Invalid Handle.
|
||||||
*/
|
*/
|
||||||
native RemoveFromTrie(Handle:map, const String:key[]);
|
native RemoveFromTrie(Handle map, const char[] key);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Clears all entries from a Map.
|
* Clears all entries from a Map.
|
||||||
|
@ -144,7 +261,7 @@ native RemoveFromTrie(Handle:map, const String:key[]);
|
||||||
* @param map Map Handle.
|
* @param map Map Handle.
|
||||||
* @error Invalid Handle.
|
* @error Invalid Handle.
|
||||||
*/
|
*/
|
||||||
native ClearTrie(Handle:map);
|
native ClearTrie(Handle map);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieves the number of elements in a map.
|
* Retrieves the number of elements in a map.
|
||||||
|
@ -153,4 +270,48 @@ native ClearTrie(Handle:map);
|
||||||
* @return Number of elements in the trie.
|
* @return Number of elements in the trie.
|
||||||
* @error Invalid Handle.
|
* @error Invalid Handle.
|
||||||
*/
|
*/
|
||||||
native GetTrieSize(Handle:map);
|
native GetTrieSize(Handle map);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a snapshot of all keys in the map. If the map is changed after this
|
||||||
|
* call, the changes are not reflected in the snapshot. Keys are not sorted.
|
||||||
|
*
|
||||||
|
* @param map Map Handle.
|
||||||
|
* @return New Map Snapshot Handle, which must be closed via CloseHandle().
|
||||||
|
* @error Invalid Handle.
|
||||||
|
*/
|
||||||
|
native Handle CreateTrieSnapshot(Handle map);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the number of keys in a map snapshot. Note that this may be
|
||||||
|
* different from the size of the map, since the map can change after the
|
||||||
|
* snapshot of its keys was taken.
|
||||||
|
*
|
||||||
|
* @param snapshot Map snapshot.
|
||||||
|
* @return Number of keys.
|
||||||
|
* @error Invalid Handle.
|
||||||
|
*/
|
||||||
|
native TrieSnapshotLength(Handle snapshot);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the buffer size required to store a given key. That is, it returns
|
||||||
|
* the length of the key plus one.
|
||||||
|
*
|
||||||
|
* @param snapshot Map snapshot.
|
||||||
|
* @param index Key index (starting from 0).
|
||||||
|
* @return Buffer size required to store the key string.
|
||||||
|
* @error Invalid Handle or index out of range.
|
||||||
|
*/
|
||||||
|
native TrieSnapshotKeyBufferSize(Handle snapshot, int index);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieves the key string of a given key in a map snapshot.
|
||||||
|
*
|
||||||
|
* @param snapshot Map snapshot.
|
||||||
|
* @param index Key index (starting from 0).
|
||||||
|
* @param buffer String buffer.
|
||||||
|
* @param maxlength Maximum buffer length.
|
||||||
|
* @return Number of bytes written to the buffer.
|
||||||
|
* @error Invalid Handle or index out of range.
|
||||||
|
*/
|
||||||
|
native GetTrieSnapshotKey(Handle snapshot, int index, char[] buffer, int maxlength);
|
||||||
|
|
240
env/include/bitbuffer.inc
vendored
240
env/include/bitbuffer.inc
vendored
|
@ -1,7 +1,7 @@
|
||||||
/**
|
/**
|
||||||
* vim: set ts=4 :
|
* vim: set ts=4 sw=4 tw=99 noet :
|
||||||
* =============================================================================
|
* =============================================================================
|
||||||
* SourceMod (C)2004-2008 AlliedModders LLC. All rights reserved.
|
* SourceMod (C)2004-2014 AlliedModders LLC. All rights reserved.
|
||||||
* =============================================================================
|
* =============================================================================
|
||||||
*
|
*
|
||||||
* This file is part of the SourceMod/SourcePawn SDK.
|
* This file is part of the SourceMod/SourcePawn SDK.
|
||||||
|
@ -35,85 +35,239 @@
|
||||||
#endif
|
#endif
|
||||||
#define _bitbuffer_included
|
#define _bitbuffer_included
|
||||||
|
|
||||||
|
methodmap BfWrite < Handle
|
||||||
|
{
|
||||||
|
// Writes a single bit to a writable bitbuffer (bf_write).
|
||||||
|
//
|
||||||
|
// @param bit Bit to write (true for 1, false for 0).
|
||||||
|
public native void WriteBool(bool bit);
|
||||||
|
|
||||||
|
// Writes a byte to a writable bitbuffer (bf_write).
|
||||||
|
//
|
||||||
|
// @param byte Byte to write (value will be written as 8bit).
|
||||||
|
public native void WriteByte(int byte);
|
||||||
|
|
||||||
|
// Writes a byte to a writable bitbuffer (bf_write).
|
||||||
|
//
|
||||||
|
// @param chr Character to write.
|
||||||
|
public native void WriteChar(int chr);
|
||||||
|
|
||||||
|
// Writes a 16bit integer to a writable bitbuffer (bf_write).
|
||||||
|
//
|
||||||
|
// @param num Integer to write (value will be written as 16bit).
|
||||||
|
public native void WriteShort(int num);
|
||||||
|
|
||||||
|
// Writes a 16bit unsigned integer to a writable bitbuffer (bf_write).
|
||||||
|
//
|
||||||
|
// @param num Integer to write (value will be written as 16bit).
|
||||||
|
public native void WriteWord(int num);
|
||||||
|
|
||||||
|
// Writes a normal integer to a writable bitbuffer (bf_write).
|
||||||
|
//
|
||||||
|
// @param num Integer to write (value will be written as 32bit).
|
||||||
|
public native void WriteNum(int num);
|
||||||
|
|
||||||
|
// Writes a floating point number to a writable bitbuffer (bf_write).
|
||||||
|
//
|
||||||
|
// @param num Number to write.
|
||||||
|
public native void WriteFloat(float num);
|
||||||
|
|
||||||
|
// Writes a string to a writable bitbuffer (bf_write).
|
||||||
|
//
|
||||||
|
// @param string Text string to write.
|
||||||
|
public native void WriteString(const char[] string);
|
||||||
|
|
||||||
|
// Writes an entity to a writable bitbuffer (bf_write).
|
||||||
|
//
|
||||||
|
// @param ent Entity index to write.
|
||||||
|
public native void WriteEntity(int ent);
|
||||||
|
|
||||||
|
// Writes a bit angle to a writable bitbuffer (bf_write).
|
||||||
|
//
|
||||||
|
// @param angle Angle to write.
|
||||||
|
// @param numBits Optional number of bits to use.
|
||||||
|
public native void WriteAngle(float angle, int numBits=8);
|
||||||
|
|
||||||
|
// Writes a coordinate to a writable bitbuffer (bf_write).
|
||||||
|
//
|
||||||
|
// @param coord Coordinate to write.
|
||||||
|
public native void WriteCoord(float coord);
|
||||||
|
|
||||||
|
// Writes a 3D vector of coordinates to a writable bitbuffer (bf_write).
|
||||||
|
//
|
||||||
|
// @param coord Coordinate array to write.
|
||||||
|
public native void WriteVecCoord(float coord[3]);
|
||||||
|
|
||||||
|
// Writes a 3D normal vector to a writable bitbuffer (bf_write).
|
||||||
|
//
|
||||||
|
// @param vec Vector to write.
|
||||||
|
public native void WriteVecNormal(float vec[3]);
|
||||||
|
|
||||||
|
// Writes a 3D angle vector to a writable bitbuffer (bf_write).
|
||||||
|
//
|
||||||
|
// @param angles Angle vector to write.
|
||||||
|
public native void WriteAngles(float angles[3]);
|
||||||
|
};
|
||||||
|
|
||||||
|
methodmap BfRead < Handle
|
||||||
|
{
|
||||||
|
// Reads a single bit from a readable bitbuffer (bf_read).
|
||||||
|
//
|
||||||
|
// @return Bit value read.
|
||||||
|
public native bool ReadBool();
|
||||||
|
|
||||||
|
// Reads a byte from a readable bitbuffer (bf_read).
|
||||||
|
//
|
||||||
|
// @return Byte value read (read as 8bit).
|
||||||
|
public native int ReadByte();
|
||||||
|
|
||||||
|
// Reads a character from a readable bitbuffer (bf_read).
|
||||||
|
//
|
||||||
|
// @return Character value read.
|
||||||
|
public native int ReadChar();
|
||||||
|
|
||||||
|
// Reads a 16bit integer from a readable bitbuffer (bf_read).
|
||||||
|
//
|
||||||
|
// @param bf bf_read handle to read from.
|
||||||
|
// @return Integer value read (read as 16bit).
|
||||||
|
public native int ReadShort();
|
||||||
|
|
||||||
|
// Reads a 16bit unsigned integer from a readable bitbuffer (bf_read).
|
||||||
|
//
|
||||||
|
// @param bf bf_read handle to read from.
|
||||||
|
// @return Integer value read (read as 16bit).
|
||||||
|
public native int ReadWord();
|
||||||
|
|
||||||
|
// Reads a normal integer to a readable bitbuffer (bf_read).
|
||||||
|
//
|
||||||
|
// @return Integer value read (read as 32bit).
|
||||||
|
public native int ReadNum();
|
||||||
|
|
||||||
|
// Reads a floating point number from a readable bitbuffer (bf_read).
|
||||||
|
//
|
||||||
|
// @return Floating point value read.
|
||||||
|
public native float ReadFloat();
|
||||||
|
|
||||||
|
// Reads a string from a readable bitbuffer (bf_read).
|
||||||
|
//
|
||||||
|
// @param buffer Destination string buffer.
|
||||||
|
// @param maxlength Maximum length of output string buffer.
|
||||||
|
// @param line If true the buffer will be copied until it reaches a '\n' or a null terminator.
|
||||||
|
// @return Number of bytes written to the buffer. If the bitbuffer stream overflowed,
|
||||||
|
// that is, had no terminator before the end of the stream, then a negative
|
||||||
|
// number will be returned equal to the number of characters written to the
|
||||||
|
// buffer minus 1. The buffer will be null terminated regardless of the
|
||||||
|
// return value.
|
||||||
|
public native int ReadString(char[] buffer, int maxlength, bool line=false);
|
||||||
|
|
||||||
|
// Reads an entity from a readable bitbuffer (bf_read).
|
||||||
|
//
|
||||||
|
// @return Entity index read.
|
||||||
|
public native int ReadEntity();
|
||||||
|
|
||||||
|
// Reads a bit angle from a readable bitbuffer (bf_read).
|
||||||
|
//
|
||||||
|
// @param numBits Optional number of bits to use.
|
||||||
|
// @return Angle read.
|
||||||
|
public native float ReadAngle(int numBits=8);
|
||||||
|
|
||||||
|
// Reads a coordinate from a readable bitbuffer (bf_read).
|
||||||
|
//
|
||||||
|
// @return Coordinate read.
|
||||||
|
public native float ReadCoord();
|
||||||
|
|
||||||
|
// Reads a 3D vector of coordinates from a readable bitbuffer (bf_read).
|
||||||
|
//
|
||||||
|
// @param coord Destination coordinate array.
|
||||||
|
public native void ReadVecCoord(float coord[3]);
|
||||||
|
|
||||||
|
// Reads a 3D normal vector from a readable bitbuffer (bf_read).
|
||||||
|
//
|
||||||
|
// @param vec Destination vector array.
|
||||||
|
public native void ReadVecNormal(float vec[3]);
|
||||||
|
|
||||||
|
// Reads a 3D angle vector from a readable bitbuffer (bf_read).
|
||||||
|
//
|
||||||
|
// @param angles Destination angle vector.
|
||||||
|
public native void ReadAngles(float angles[3]);
|
||||||
|
|
||||||
|
// Returns the number of bytes left in a readable bitbuffer (bf_read).
|
||||||
|
property int BytesLeft {
|
||||||
|
public native get();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Writes a single bit to a writable bitbuffer (bf_write).
|
* Writes a single bit to a writable bitbuffer (bf_write).
|
||||||
*
|
*
|
||||||
* @param bf bf_write handle to write to.
|
* @param bf bf_write handle to write to.
|
||||||
* @param bit Bit to write (true for 1, false for 0).
|
* @param bit Bit to write (true for 1, false for 0).
|
||||||
* @noreturn
|
|
||||||
* @error Invalid or incorrect Handle.
|
* @error Invalid or incorrect Handle.
|
||||||
*/
|
*/
|
||||||
native BfWriteBool(Handle:bf, bool:bit);
|
native void BfWriteBool(Handle bf, bool bit);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Writes a byte to a writable bitbuffer (bf_write).
|
* Writes a byte to a writable bitbuffer (bf_write).
|
||||||
*
|
*
|
||||||
* @param bf bf_write handle to write to.
|
* @param bf bf_write handle to write to.
|
||||||
* @param byte Byte to write (value will be written as 8bit).
|
* @param byte Byte to write (value will be written as 8bit).
|
||||||
* @noreturn
|
|
||||||
* @error Invalid or incorrect Handle.
|
* @error Invalid or incorrect Handle.
|
||||||
*/
|
*/
|
||||||
native BfWriteByte(Handle:bf, byte);
|
native void BfWriteByte(Handle bf, int byte);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Writes a byte to a writable bitbuffer (bf_write).
|
* Writes a byte to a writable bitbuffer (bf_write).
|
||||||
*
|
*
|
||||||
* @param bf bf_write handle to write to.
|
* @param bf bf_write handle to write to.
|
||||||
* @param chr Character to write.
|
* @param chr Character to write.
|
||||||
* @noreturn
|
|
||||||
* @error Invalid or incorrect Handle.
|
* @error Invalid or incorrect Handle.
|
||||||
*/
|
*/
|
||||||
native BfWriteChar(Handle:bf, chr);
|
native void BfWriteChar(Handle bf, int chr);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Writes a 16bit integer to a writable bitbuffer (bf_write).
|
* Writes a 16bit integer to a writable bitbuffer (bf_write).
|
||||||
*
|
*
|
||||||
* @param bf bf_write handle to write to.
|
* @param bf bf_write handle to write to.
|
||||||
* @param num Integer to write (value will be written as 16bit).
|
* @param num Integer to write (value will be written as 16bit).
|
||||||
* @noreturn
|
|
||||||
* @error Invalid or incorrect Handle.
|
* @error Invalid or incorrect Handle.
|
||||||
*/
|
*/
|
||||||
native BfWriteShort(Handle:bf, num);
|
native void BfWriteShort(Handle bf, int num);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Writes a 16bit unsigned integer to a writable bitbuffer (bf_write).
|
* Writes a 16bit unsigned integer to a writable bitbuffer (bf_write).
|
||||||
*
|
*
|
||||||
* @param bf bf_write handle to write to.
|
* @param bf bf_write handle to write to.
|
||||||
* @param num Integer to write (value will be written as 16bit).
|
* @param num Integer to write (value will be written as 16bit).
|
||||||
* @noreturn
|
|
||||||
* @error Invalid or incorrect Handle.
|
* @error Invalid or incorrect Handle.
|
||||||
*/
|
*/
|
||||||
native BfWriteWord(Handle:bf, num);
|
native void BfWriteWord(Handle bf, int num);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Writes a normal integer to a writable bitbuffer (bf_write).
|
* Writes a normal integer to a writable bitbuffer (bf_write).
|
||||||
*
|
*
|
||||||
* @param bf bf_write handle to write to.
|
* @param bf bf_write handle to write to.
|
||||||
* @param num Integer to write (value will be written as 32bit).
|
* @param num Integer to write (value will be written as 32bit).
|
||||||
* @noreturn
|
|
||||||
* @error Invalid or incorrect Handle.
|
* @error Invalid or incorrect Handle.
|
||||||
*/
|
*/
|
||||||
native BfWriteNum(Handle:bf, num);
|
native void BfWriteNum(Handle bf, int num);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Writes a floating point number to a writable bitbuffer (bf_write).
|
* Writes a floating point number to a writable bitbuffer (bf_write).
|
||||||
*
|
*
|
||||||
* @param bf bf_write handle to write to.
|
* @param bf bf_write handle to write to.
|
||||||
* @param num Number to write.
|
* @param num Number to write.
|
||||||
* @noreturn
|
|
||||||
* @error Invalid or incorrect Handle.
|
* @error Invalid or incorrect Handle.
|
||||||
*/
|
*/
|
||||||
native BfWriteFloat(Handle:bf, Float:num);
|
native void BfWriteFloat(Handle bf, float num);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Writes a string to a writable bitbuffer (bf_write).
|
* Writes a string to a writable bitbuffer (bf_write).
|
||||||
*
|
*
|
||||||
* @param bf bf_write handle to write to.
|
* @param bf bf_write handle to write to.
|
||||||
* @param string Text string to write.
|
* @param string Text string to write.
|
||||||
* @noreturn
|
|
||||||
* @error Invalid or incorrect Handle.
|
* @error Invalid or incorrect Handle.
|
||||||
*/
|
*/
|
||||||
native BfWriteString(Handle:bf, const String:string[]);
|
native void BfWriteString(Handle bf, const char[] string);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Writes an entity to a writable bitbuffer (bf_write).
|
* Writes an entity to a writable bitbuffer (bf_write).
|
||||||
|
@ -121,10 +275,9 @@ native BfWriteString(Handle:bf, const String:string[]);
|
||||||
*
|
*
|
||||||
* @param bf bf_write handle to write to.
|
* @param bf bf_write handle to write to.
|
||||||
* @param ent Entity index to write.
|
* @param ent Entity index to write.
|
||||||
* @noreturn
|
|
||||||
* @error Invalid or incorrect Handle, or invalid entity.
|
* @error Invalid or incorrect Handle, or invalid entity.
|
||||||
*/
|
*/
|
||||||
native BfWriteEntity(Handle:bf, ent);
|
native void BfWriteEntity(Handle bf, int ent);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Writes a bit angle to a writable bitbuffer (bf_write).
|
* Writes a bit angle to a writable bitbuffer (bf_write).
|
||||||
|
@ -132,30 +285,27 @@ native BfWriteEntity(Handle:bf, ent);
|
||||||
* @param bf bf_write handle to write to.
|
* @param bf bf_write handle to write to.
|
||||||
* @param angle Angle to write.
|
* @param angle Angle to write.
|
||||||
* @param numBits Optional number of bits to use.
|
* @param numBits Optional number of bits to use.
|
||||||
* @noreturn
|
|
||||||
* @error Invalid or incorrect Handle.
|
* @error Invalid or incorrect Handle.
|
||||||
*/
|
*/
|
||||||
native BfWriteAngle(Handle:bf, Float:angle, numBits=8);
|
native void BfWriteAngle(Handle bf, float angle, int numBits=8);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Writes a coordinate to a writable bitbuffer (bf_write).
|
* Writes a coordinate to a writable bitbuffer (bf_write).
|
||||||
*
|
*
|
||||||
* @param bf bf_write handle to write to.
|
* @param bf bf_write handle to write to.
|
||||||
* @param coord Coordinate to write.
|
* @param coord Coordinate to write.
|
||||||
* @noreturn
|
|
||||||
* @error Invalid or incorrect Handle.
|
* @error Invalid or incorrect Handle.
|
||||||
*/
|
*/
|
||||||
native BfWriteCoord(Handle:bf, Float:coord);
|
native void BfWriteCoord(Handle bf, float coord);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Writes a 3D vector of coordinates to a writable bitbuffer (bf_write).
|
* Writes a 3D vector of coordinates to a writable bitbuffer (bf_write).
|
||||||
*
|
*
|
||||||
* @param bf bf_write handle to write to.
|
* @param bf bf_write handle to write to.
|
||||||
* @param coord Coordinate array to write.
|
* @param coord Coordinate array to write.
|
||||||
* @noreturn
|
|
||||||
* @error Invalid or incorrect Handle.
|
* @error Invalid or incorrect Handle.
|
||||||
*/
|
*/
|
||||||
native BfWriteVecCoord(Handle:bf, Float:coord[3]);
|
native void BfWriteVecCoord(Handle bf, float coord[3]);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Writes a 3D normal vector to a writable bitbuffer (bf_write).
|
* Writes a 3D normal vector to a writable bitbuffer (bf_write).
|
||||||
|
@ -165,17 +315,16 @@ native BfWriteVecCoord(Handle:bf, Float:coord[3]);
|
||||||
* @noreturn
|
* @noreturn
|
||||||
* @error Invalid or incorrect Handle.
|
* @error Invalid or incorrect Handle.
|
||||||
*/
|
*/
|
||||||
native BfWriteVecNormal(Handle:bf, Float:vec[3]);
|
native void BfWriteVecNormal(Handle bf, float vec[3]);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Writes a 3D angle vector to a writable bitbuffer (bf_write).
|
* Writes a 3D angle vector to a writable bitbuffer (bf_write).
|
||||||
*
|
*
|
||||||
* @param bf bf_write handle to write to.
|
* @param bf bf_write handle to write to.
|
||||||
* @param angles Angle vector to write.
|
* @param angles Angle vector to write.
|
||||||
* @noreturn
|
|
||||||
* @error Invalid or incorrect Handle.
|
* @error Invalid or incorrect Handle.
|
||||||
*/
|
*/
|
||||||
native BfWriteAngles(Handle:bf, Float:angles[3]);
|
native void BfWriteAngles(Handle bf, float angles[3]);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reads a single bit from a readable bitbuffer (bf_read).
|
* Reads a single bit from a readable bitbuffer (bf_read).
|
||||||
|
@ -184,7 +333,7 @@ native BfWriteAngles(Handle:bf, Float:angles[3]);
|
||||||
* @return Bit value read.
|
* @return Bit value read.
|
||||||
* @error Invalid or incorrect Handle.
|
* @error Invalid or incorrect Handle.
|
||||||
*/
|
*/
|
||||||
native bool:BfReadBool(Handle:bf);
|
native bool BfReadBool(Handle bf);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reads a byte from a readable bitbuffer (bf_read).
|
* Reads a byte from a readable bitbuffer (bf_read).
|
||||||
|
@ -193,7 +342,7 @@ native bool:BfReadBool(Handle:bf);
|
||||||
* @return Byte value read (read as 8bit).
|
* @return Byte value read (read as 8bit).
|
||||||
* @error Invalid or incorrect Handle.
|
* @error Invalid or incorrect Handle.
|
||||||
*/
|
*/
|
||||||
native BfReadByte(Handle:bf);
|
native int BfReadByte(Handle bf);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reads a character from a readable bitbuffer (bf_read).
|
* Reads a character from a readable bitbuffer (bf_read).
|
||||||
|
@ -202,7 +351,7 @@ native BfReadByte(Handle:bf);
|
||||||
* @return Character value read.
|
* @return Character value read.
|
||||||
* @error Invalid or incorrect Handle.
|
* @error Invalid or incorrect Handle.
|
||||||
*/
|
*/
|
||||||
native BfReadChar(Handle:bf);
|
native int BfReadChar(Handle bf);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reads a 16bit integer from a readable bitbuffer (bf_read).
|
* Reads a 16bit integer from a readable bitbuffer (bf_read).
|
||||||
|
@ -211,7 +360,7 @@ native BfReadChar(Handle:bf);
|
||||||
* @return Integer value read (read as 16bit).
|
* @return Integer value read (read as 16bit).
|
||||||
* @error Invalid or incorrect Handle.
|
* @error Invalid or incorrect Handle.
|
||||||
*/
|
*/
|
||||||
native BfReadShort(Handle:bf);
|
native int BfReadShort(Handle bf);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reads a 16bit unsigned integer from a readable bitbuffer (bf_read).
|
* Reads a 16bit unsigned integer from a readable bitbuffer (bf_read).
|
||||||
|
@ -220,7 +369,7 @@ native BfReadShort(Handle:bf);
|
||||||
* @return Integer value read (read as 16bit).
|
* @return Integer value read (read as 16bit).
|
||||||
* @error Invalid or incorrect Handle.
|
* @error Invalid or incorrect Handle.
|
||||||
*/
|
*/
|
||||||
native BfReadWord(Handle:bf);
|
native int BfReadWord(Handle bf);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reads a normal integer to a readable bitbuffer (bf_read).
|
* Reads a normal integer to a readable bitbuffer (bf_read).
|
||||||
|
@ -229,7 +378,7 @@ native BfReadWord(Handle:bf);
|
||||||
* @return Integer value read (read as 32bit).
|
* @return Integer value read (read as 32bit).
|
||||||
* @error Invalid or incorrect Handle.
|
* @error Invalid or incorrect Handle.
|
||||||
*/
|
*/
|
||||||
native BfReadNum(Handle:bf);
|
native int BfReadNum(Handle bf);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reads a floating point number from a readable bitbuffer (bf_read).
|
* Reads a floating point number from a readable bitbuffer (bf_read).
|
||||||
|
@ -238,7 +387,7 @@ native BfReadNum(Handle:bf);
|
||||||
* @return Floating point value read.
|
* @return Floating point value read.
|
||||||
* @error Invalid or incorrect Handle.
|
* @error Invalid or incorrect Handle.
|
||||||
*/
|
*/
|
||||||
native Float:BfReadFloat(Handle:bf);
|
native float BfReadFloat(Handle bf);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reads a string from a readable bitbuffer (bf_read).
|
* Reads a string from a readable bitbuffer (bf_read).
|
||||||
|
@ -254,7 +403,7 @@ native Float:BfReadFloat(Handle:bf);
|
||||||
* return value.
|
* return value.
|
||||||
* @error Invalid or incorrect Handle.
|
* @error Invalid or incorrect Handle.
|
||||||
*/
|
*/
|
||||||
native BfReadString(Handle:bf, String:buffer[], maxlength, bool:line=false);
|
native int BfReadString(Handle bf, char[] buffer, int maxlength, bool line=false);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reads an entity from a readable bitbuffer (bf_read).
|
* Reads an entity from a readable bitbuffer (bf_read).
|
||||||
|
@ -264,7 +413,7 @@ native BfReadString(Handle:bf, String:buffer[], maxlength, bool:line=false);
|
||||||
* @return Entity index read.
|
* @return Entity index read.
|
||||||
* @error Invalid or incorrect Handle.
|
* @error Invalid or incorrect Handle.
|
||||||
*/
|
*/
|
||||||
native BfReadEntity(Handle:bf);
|
native int BfReadEntity(Handle bf);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reads a bit angle from a readable bitbuffer (bf_read).
|
* Reads a bit angle from a readable bitbuffer (bf_read).
|
||||||
|
@ -274,7 +423,7 @@ native BfReadEntity(Handle:bf);
|
||||||
* @return Angle read.
|
* @return Angle read.
|
||||||
* @error Invalid or incorrect Handle.
|
* @error Invalid or incorrect Handle.
|
||||||
*/
|
*/
|
||||||
native Float:BfReadAngle(Handle:bf, numBits=8);
|
native float BfReadAngle(Handle bf, int numBits=8);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reads a coordinate from a readable bitbuffer (bf_read).
|
* Reads a coordinate from a readable bitbuffer (bf_read).
|
||||||
|
@ -283,37 +432,34 @@ native Float:BfReadAngle(Handle:bf, numBits=8);
|
||||||
* @return Coordinate read.
|
* @return Coordinate read.
|
||||||
* @error Invalid or incorrect Handle.
|
* @error Invalid or incorrect Handle.
|
||||||
*/
|
*/
|
||||||
native Float:BfReadCoord(Handle:bf);
|
native float BfReadCoord(Handle bf);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reads a 3D vector of coordinates from a readable bitbuffer (bf_read).
|
* Reads a 3D vector of coordinates from a readable bitbuffer (bf_read).
|
||||||
*
|
*
|
||||||
* @param bf bf_read handle to read from.
|
* @param bf bf_read handle to read from.
|
||||||
* @param coord Destination coordinate array.
|
* @param coord Destination coordinate array.
|
||||||
* @noreturn
|
|
||||||
* @error Invalid or incorrect Handle.
|
* @error Invalid or incorrect Handle.
|
||||||
*/
|
*/
|
||||||
native BfReadVecCoord(Handle:bf, Float:coord[3]);
|
native void BfReadVecCoord(Handle bf, float coord[3]);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reads a 3D normal vector from a readable bitbuffer (bf_read).
|
* Reads a 3D normal vector from a readable bitbuffer (bf_read).
|
||||||
*
|
*
|
||||||
* @param bf bf_read handle to read from.
|
* @param bf bf_read handle to read from.
|
||||||
* @param vec Destination vector array.
|
* @param vec Destination vector array.
|
||||||
* @noreturn
|
|
||||||
* @error Invalid or incorrect Handle.
|
* @error Invalid or incorrect Handle.
|
||||||
*/
|
*/
|
||||||
native BfReadVecNormal(Handle:bf, Float:vec[3]);
|
native void BfReadVecNormal(Handle bf, float vec[3]);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reads a 3D angle vector from a readable bitbuffer (bf_read).
|
* Reads a 3D angle vector from a readable bitbuffer (bf_read).
|
||||||
*
|
*
|
||||||
* @param bf bf_read handle to read from.
|
* @param bf bf_read handle to read from.
|
||||||
* @param angles Destination angle vector.
|
* @param angles Destination angle vector.
|
||||||
* @noreturn
|
|
||||||
* @error Invalid or incorrect Handle.
|
* @error Invalid or incorrect Handle.
|
||||||
*/
|
*/
|
||||||
native BfReadAngles(Handle:bf, Float:angles[3]);
|
native void BfReadAngles(Handle bf, float angles[3]);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the number of bytes left in a readable bitbuffer (bf_read).
|
* Returns the number of bytes left in a readable bitbuffer (bf_read).
|
||||||
|
@ -322,4 +468,4 @@ native BfReadAngles(Handle:bf, Float:angles[3]);
|
||||||
* @return Number of bytes left unread.
|
* @return Number of bytes left unread.
|
||||||
* @error Invalid or incorrect Handle.
|
* @error Invalid or incorrect Handle.
|
||||||
*/
|
*/
|
||||||
native BfGetNumBytesLeft(Handle:bf);
|
native int BfGetNumBytesLeft(Handle bf);
|
||||||
|
|
13
env/include/clientprefs.inc
vendored
13
env/include/clientprefs.inc
vendored
|
@ -165,9 +165,16 @@ forward OnClientCookiesCached(client);
|
||||||
* @param action CookieMenuAction being performed.
|
* @param action CookieMenuAction being performed.
|
||||||
* @param info Info data passed.
|
* @param info Info data passed.
|
||||||
* @param buffer Outbut buffer.
|
* @param buffer Outbut buffer.
|
||||||
* @param maxlen Max length of the output buffer.
|
* @param maxlen Max length of the output buffer.
|
||||||
|
* @noreturn
|
||||||
*/
|
*/
|
||||||
functag public CookieMenuHandler(client, CookieMenuAction:action, any:info, String:buffer[], maxlen);
|
typedef CookieMenuHandler = function void (
|
||||||
|
int client,
|
||||||
|
CookieMenuAction action,
|
||||||
|
any info,
|
||||||
|
char[] buffer,
|
||||||
|
int maxlen
|
||||||
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add a new prefab item to the client cookie settings menu.
|
* Add a new prefab item to the client cookie settings menu.
|
||||||
|
@ -182,7 +189,7 @@ functag public CookieMenuHandler(client, CookieMenuAction:action, any:info, Stri
|
||||||
* @noreturn
|
* @noreturn
|
||||||
* @error Invalid cookie handle.
|
* @error Invalid cookie handle.
|
||||||
*/
|
*/
|
||||||
native SetCookiePrefabMenu(Handle:cookie, CookieMenu:type, const String:display[], CookieMenuHandler:handler=CookieMenuHandler:-1, info=0);
|
native SetCookiePrefabMenu(Handle:cookie, CookieMenu:type, const String:display[], CookieMenuHandler:handler=INVALID_FUNCTION, info=0);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds a new item to the client cookie settings menu.
|
* Adds a new item to the client cookie settings menu.
|
||||||
|
|
55
env/include/clients.inc
vendored
55
env/include/clients.inc
vendored
|
@ -45,6 +45,25 @@ enum NetFlow
|
||||||
NetFlow_Both, /**< Both values added together */
|
NetFlow_Both, /**< Both values added together */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Auth string types.
|
||||||
|
*
|
||||||
|
* Note that for the Steam2 and Steam3 types, the following ids are
|
||||||
|
* also valid values:
|
||||||
|
* "STEAM_ID_PENDING" - Authentication is pending.
|
||||||
|
* "STEAM_ID_LAN" - Authentication is disabled because of being on a LAN server.
|
||||||
|
* "BOT" - The client is a bot.
|
||||||
|
*/
|
||||||
|
enum AuthIdType
|
||||||
|
{
|
||||||
|
AuthId_Engine = 0, /**< The game-specific auth string as returned from the engine */
|
||||||
|
|
||||||
|
// The following are only available on games that support Steam authentication.
|
||||||
|
AuthId_Steam2, /**< Steam2 rendered format, ex "STEAM_1:1:4153990" */
|
||||||
|
AuthId_Steam3, /**< Steam3 rendered format, ex "[U:1:8307981]" */
|
||||||
|
AuthId_SteamID64, /**< A SteamID64 (uint64) as a String, ex "76561197968573709" */
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* MAXPLAYERS is not the same as MaxClients.
|
* MAXPLAYERS is not the same as MaxClients.
|
||||||
* MAXPLAYERS is a hardcoded value as an upper limit. MaxClients changes based on the server.
|
* MAXPLAYERS is a hardcoded value as an upper limit. MaxClients changes based on the server.
|
||||||
|
@ -80,7 +99,7 @@ forward bool:OnClientConnect(client, String:rejectmsg[], maxlen);
|
||||||
* @param client Client index.
|
* @param client Client index.
|
||||||
* @noreturn
|
* @noreturn
|
||||||
*/
|
*/
|
||||||
forward OnClientConnected(client);
|
forward void OnClientConnected(client);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when a client is entering the game.
|
* Called when a client is entering the game.
|
||||||
|
@ -96,7 +115,7 @@ forward OnClientConnected(client);
|
||||||
* @param client Client index.
|
* @param client Client index.
|
||||||
* @noreturn
|
* @noreturn
|
||||||
*/
|
*/
|
||||||
forward OnClientPutInServer(client);
|
forward void OnClientPutInServer(client);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when a client is disconnecting from the server.
|
* Called when a client is disconnecting from the server.
|
||||||
|
@ -104,7 +123,7 @@ forward OnClientPutInServer(client);
|
||||||
* @param client Client index.
|
* @param client Client index.
|
||||||
* @noreturn
|
* @noreturn
|
||||||
*/
|
*/
|
||||||
forward OnClientDisconnect(client);
|
forward void OnClientDisconnect(client);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when a client is disconnected from the server.
|
* Called when a client is disconnected from the server.
|
||||||
|
@ -112,7 +131,7 @@ forward OnClientDisconnect(client);
|
||||||
* @param client Client index.
|
* @param client Client index.
|
||||||
* @noreturn
|
* @noreturn
|
||||||
*/
|
*/
|
||||||
forward OnClientDisconnect_Post(client);
|
forward void OnClientDisconnect_Post(client);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when a client is sending a command.
|
* Called when a client is sending a command.
|
||||||
|
@ -132,20 +151,20 @@ forward Action:OnClientCommand(client, args);
|
||||||
* @param client Client index.
|
* @param client Client index.
|
||||||
* @noreturn
|
* @noreturn
|
||||||
*/
|
*/
|
||||||
forward OnClientSettingsChanged(client);
|
forward void OnClientSettingsChanged(client);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when a client receives a Steam ID. The state of a client's
|
* Called when a client receives an auth ID. The state of a client's
|
||||||
* authorization as an admin is not guaranteed here. Use
|
* authorization as an admin is not guaranteed here. Use
|
||||||
* OnClientPostAdminCheck() if you need a client's admin status.
|
* OnClientPostAdminCheck() if you need a client's admin status.
|
||||||
*
|
*
|
||||||
* This is called by bots, but the ID will be "BOT".
|
* This is called by bots, but the ID will be "BOT".
|
||||||
*
|
*
|
||||||
* @param client Client index.
|
* @param client Client index.
|
||||||
* @param auth Client auth string.
|
* @param auth Client Steam2 id, if available, else engine auth id.
|
||||||
* @noreturn
|
* @noreturn
|
||||||
*/
|
*/
|
||||||
forward OnClientAuthorized(client, const String:auth[]);
|
forward void OnClientAuthorized(client, const String:auth[]);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called once a client is authorized and fully in-game, but
|
* Called once a client is authorized and fully in-game, but
|
||||||
|
@ -180,7 +199,7 @@ forward Action:OnClientPreAdminCheck(client);
|
||||||
* @param client Client index.
|
* @param client Client index.
|
||||||
* @noreturn
|
* @noreturn
|
||||||
*/
|
*/
|
||||||
forward OnClientPostAdminFilter(client);
|
forward void OnClientPostAdminFilter(client);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called once a client is authorized and fully in-game, and
|
* Called once a client is authorized and fully in-game, and
|
||||||
|
@ -192,7 +211,7 @@ forward OnClientPostAdminFilter(client);
|
||||||
* @param client Client index.
|
* @param client Client index.
|
||||||
* @noreturn
|
* @noreturn
|
||||||
*/
|
*/
|
||||||
forward OnClientPostAdminCheck(client);
|
forward void OnClientPostAdminCheck(client);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This function will be deprecated in a future release. Use the MaxClients variable instead.
|
* This function will be deprecated in a future release. Use the MaxClients variable instead.
|
||||||
|
@ -267,8 +286,24 @@ native bool:GetClientIP(client, String:ip[], maxlen, bool:remport=true);
|
||||||
* @return True on success, false otherwise.
|
* @return True on success, false otherwise.
|
||||||
* @error If the client is not connected or the index is invalid.
|
* @error If the client is not connected or the index is invalid.
|
||||||
*/
|
*/
|
||||||
|
#pragma deprecated Use GetClientAuthId
|
||||||
native bool:GetClientAuthString(client, String:auth[], maxlen, bool:validate=true);
|
native bool:GetClientAuthString(client, String:auth[], maxlen, bool:validate=true);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieves a client's authentication string (SteamID).
|
||||||
|
*
|
||||||
|
* @param client Player index.
|
||||||
|
* @param authType Auth id type and format to use.
|
||||||
|
* @param auth Buffer to store the client's auth id.
|
||||||
|
* @param maxlen Maximum length of string buffer (includes NULL terminator).
|
||||||
|
* @param validate Check backend validation status.
|
||||||
|
* DO NOT PASS FALSE UNLESS YOU UNDERSTAND THE CONSEQUENCES,
|
||||||
|
* You WILL KNOW if you need to use this, MOST WILL NOT.
|
||||||
|
* @return True on success, false otherwise.
|
||||||
|
* @error If the client is not connected or the index is invalid.
|
||||||
|
*/
|
||||||
|
native bool:GetClientAuthId(client, AuthIdType:authType, String:auth[], maxlen, bool:validate=true);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the client's Steam account ID.
|
* Returns the client's Steam account ID.
|
||||||
*
|
*
|
||||||
|
|
2
env/include/commandfilters.inc
vendored
2
env/include/commandfilters.inc
vendored
|
@ -140,7 +140,7 @@ stock ReplyToTargetError(client, reason)
|
||||||
* @param clients Array to fill with unique, valid client indexes.
|
* @param clients Array to fill with unique, valid client indexes.
|
||||||
* @return True if pattern was recognized, false otherwise.
|
* @return True if pattern was recognized, false otherwise.
|
||||||
*/
|
*/
|
||||||
functag public bool:MultiTargetFilter(const String:pattern[], Handle:clients);
|
typedef MultiTargetFilter = function bool (const char[] pattern, Handle clients);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds a multi-target filter function for ProcessTargetString().
|
* Adds a multi-target filter function for ProcessTargetString().
|
||||||
|
|
87
env/include/commandline.inc
vendored
Normal file
87
env/include/commandline.inc
vendored
Normal file
|
@ -0,0 +1,87 @@
|
||||||
|
/**
|
||||||
|
* vim: set ts=4 :
|
||||||
|
* =============================================================================
|
||||||
|
* SourceMod (C)2004-2008 AlliedModders LLC. All rights reserved.
|
||||||
|
* =============================================================================
|
||||||
|
*
|
||||||
|
* This file is part of the SourceMod/SourcePawn SDK.
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify it under
|
||||||
|
* the terms of the GNU General Public License, version 3.0, as published by the
|
||||||
|
* Free Software Foundation.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||||
|
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||||
|
* details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along with
|
||||||
|
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
* As a special exception, AlliedModders LLC gives you permission to link the
|
||||||
|
* code of this program (as well as its derivative works) to "Half-Life 2," the
|
||||||
|
* "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
|
||||||
|
* by the Valve Corporation. You must obey the GNU General Public License in
|
||||||
|
* all respects for all other code used. Additionally, AlliedModders LLC grants
|
||||||
|
* this exception to all derivative works. AlliedModders LLC defines further
|
||||||
|
* exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
|
||||||
|
* or <http://www.sourcemod.net/license.php>.
|
||||||
|
*
|
||||||
|
* Version: $Id$
|
||||||
|
*/
|
||||||
|
|
||||||
|
#if defined _commandline_included_
|
||||||
|
#endinput
|
||||||
|
#endif
|
||||||
|
#define _commandline_included_
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the full command line the server was launched with.
|
||||||
|
*
|
||||||
|
* @param commandLine Buffer to store the command line in.
|
||||||
|
* @param maxlen Maximum length of the command line buffer.
|
||||||
|
* @return True if the command line is valid; otherwise, false.
|
||||||
|
* @error No command line available, or no mod support.
|
||||||
|
*/
|
||||||
|
native bool:GetCommandLine(String:commandLine[], maxlen);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the value of a command line parameter the server was launched with.
|
||||||
|
*
|
||||||
|
* @param param The command line parameter to get the value of.
|
||||||
|
* @param value Buffer to store the parameter value in.
|
||||||
|
* @param maxlen Maximum length of the value buffer.
|
||||||
|
* @param defValue The default value to return if the parameter wasn't specified.
|
||||||
|
* @return True if the command line is valid; otherwise, false.
|
||||||
|
* @error No command line available, or no mod support.
|
||||||
|
*/
|
||||||
|
native GetCommandLineParam(const String:param[], String:value[], maxlen, const String:defValue[]="");
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the value of a command line parameter the server was launched with.
|
||||||
|
*
|
||||||
|
* @param param The command line parameter to get the value of.
|
||||||
|
* @param defValue The default value to return if the parameter wasn't specified.
|
||||||
|
* @return The integer value of the command line parameter value.
|
||||||
|
* @error No command line available, or no mod support.
|
||||||
|
*/
|
||||||
|
native GetCommandLineParamInt(const String:param[], defValue=0);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the value of a command line parameter the server was launched with.
|
||||||
|
*
|
||||||
|
* @param param The command line parameter to get the value of.
|
||||||
|
* @param defValue The default value to return if the parameter wasn't specified.
|
||||||
|
* @return The floating point value of the command line parameter value.
|
||||||
|
* @error No command line available, or no mod support.
|
||||||
|
*/
|
||||||
|
native Float:GetCommandLineParamFloat(const String:param[], Float:defValue=0.0);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determines if a specific command line parameter is present.
|
||||||
|
*
|
||||||
|
* @param param The command line parameter to test.
|
||||||
|
* @return True if the command line parameter is specified; otherwise, false.
|
||||||
|
* @error No command line available, or no mod support.
|
||||||
|
*/
|
||||||
|
native bool:FindCommandLineParam(const String:param[]);
|
339
env/include/console.inc
vendored
339
env/include/console.inc
vendored
|
@ -29,7 +29,7 @@
|
||||||
*
|
*
|
||||||
* Version: $Id$
|
* Version: $Id$
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#if defined _console_included
|
#if defined _console_included
|
||||||
#endinput
|
#endinput
|
||||||
#endif
|
#endif
|
||||||
|
@ -37,15 +37,6 @@
|
||||||
|
|
||||||
#define INVALID_FCVAR_FLAGS (-1)
|
#define INVALID_FCVAR_FLAGS (-1)
|
||||||
|
|
||||||
/**
|
|
||||||
* Console variable bound values used with Get/SetConVarBounds()
|
|
||||||
*/
|
|
||||||
enum ConVarBounds
|
|
||||||
{
|
|
||||||
ConVarBound_Upper = 0,
|
|
||||||
ConVarBound_Lower
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Console variable query helper values.
|
* Console variable query helper values.
|
||||||
*/
|
*/
|
||||||
|
@ -63,17 +54,6 @@ enum ReplySource
|
||||||
SM_REPLY_TO_CHAT = 1,
|
SM_REPLY_TO_CHAT = 1,
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* Console variable query result values.
|
|
||||||
*/
|
|
||||||
enum ConVarQueryResult
|
|
||||||
{
|
|
||||||
ConVarQuery_Okay = 0, /**< Retrieval of client convar value was successful. */
|
|
||||||
ConVarQuery_NotFound, /**< Client convar was not found. */
|
|
||||||
ConVarQuery_NotValid, /**< A console command with the same name was found, but there is no convar. */
|
|
||||||
ConVarQuery_Protected /**< Client convar was found, but it is protected. The server cannot retrieve its value. */
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @section Flags for console commands and console variables. The descriptions
|
* @section Flags for console commands and console variables. The descriptions
|
||||||
* for each constant come directly from the Source SDK.
|
* for each constant come directly from the Source SDK.
|
||||||
|
@ -328,7 +308,7 @@ native FormatActivitySource(client, target, const String:namebuf[], maxlength);
|
||||||
* @return An Action value. Not handling the command
|
* @return An Action value. Not handling the command
|
||||||
* means that Source will report it as "not found."
|
* means that Source will report it as "not found."
|
||||||
*/
|
*/
|
||||||
functag public Action:SrvCmd(args);
|
typedef SrvCmd = function Action (int args);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a server-only console command, or hooks an already existing one.
|
* Creates a server-only console command, or hooks an already existing one.
|
||||||
|
@ -352,7 +332,7 @@ native RegServerCmd(const String:cmd[], SrvCmd:callback, const String:descriptio
|
||||||
* @return An Action value. Not handling the command
|
* @return An Action value. Not handling the command
|
||||||
* means that Source will report it as "not found."
|
* means that Source will report it as "not found."
|
||||||
*/
|
*/
|
||||||
functag public Action:ConCmd(client, args);
|
typedef ConCmd = function Action (int client, int args);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a console command, or hooks an already existing one.
|
* Creates a console command, or hooks an already existing one.
|
||||||
|
@ -424,293 +404,6 @@ native GetCmdArg(argnum, String:buffer[], maxlength);
|
||||||
*/
|
*/
|
||||||
native GetCmdArgString(String:buffer[], maxlength);
|
native GetCmdArgString(String:buffer[], maxlength);
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates a new console variable.
|
|
||||||
*
|
|
||||||
* @param name Name of new convar.
|
|
||||||
* @param defaultValue String containing the default value of new convar.
|
|
||||||
* @param description Optional description of the convar.
|
|
||||||
* @param flags Optional bitstring of flags determining how the convar should be handled. See FCVAR_* constants for more details.
|
|
||||||
* @param hasMin Optional boolean that determines if the convar has a minimum value.
|
|
||||||
* @param min Minimum floating point value that the convar can have if hasMin is true.
|
|
||||||
* @param hasMax Optional boolean that determines if the convar has a maximum value.
|
|
||||||
* @param max Maximum floating point value that the convar can have if hasMax is true.
|
|
||||||
* @return A handle to the newly created convar. If the convar already exists, a handle to it will still be returned.
|
|
||||||
* @error Convar name is blank or is the same as an existing console command.
|
|
||||||
*/
|
|
||||||
native Handle:CreateConVar(const String:name[], const String:defaultValue[], const String:description[]="", flags=0, bool:hasMin=false, Float:min=0.0, bool:hasMax=false, Float:max=0.0);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Searches for a console variable.
|
|
||||||
*
|
|
||||||
* @param name Name of convar to find.
|
|
||||||
* @return A handle to the convar if it is found. INVALID_HANDLE otherwise.
|
|
||||||
*/
|
|
||||||
native Handle:FindConVar(const String:name[]);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Called when a console variable's value is changed.
|
|
||||||
*
|
|
||||||
* @param convar Handle to the convar that was changed.
|
|
||||||
* @param oldValue String containing the value of the convar before it was changed.
|
|
||||||
* @param newValue String containing the new value of the convar.
|
|
||||||
* @noreturn
|
|
||||||
*/
|
|
||||||
functag public ConVarChanged(Handle:convar, const String:oldValue[], const String:newValue[]);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates a hook for when a console variable's value is changed.
|
|
||||||
*
|
|
||||||
* @param convar Handle to the convar.
|
|
||||||
* @param callback An OnConVarChanged function pointer.
|
|
||||||
* @noreturn
|
|
||||||
* @error Invalid or corrupt Handle or invalid callback function.
|
|
||||||
*/
|
|
||||||
native HookConVarChange(Handle:convar, ConVarChanged:callback);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Removes a hook for when a console variable's value is changed.
|
|
||||||
*
|
|
||||||
* @param convar Handle to the convar.
|
|
||||||
* @param callback An OnConVarChanged function pointer.
|
|
||||||
* @noreturn
|
|
||||||
* @error Invalid or corrupt Handle, invalid callback function, or no active hook on convar.
|
|
||||||
*/
|
|
||||||
native UnhookConVarChange(Handle:convar, ConVarChanged:callback);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the boolean value of a console variable.
|
|
||||||
*
|
|
||||||
* @param convar Handle to the convar.
|
|
||||||
* @return The boolean value of the convar.
|
|
||||||
* @error Invalid or corrupt Handle.
|
|
||||||
*/
|
|
||||||
native bool:GetConVarBool(Handle:convar);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the boolean value of a console variable.
|
|
||||||
*
|
|
||||||
* Note: The replicate and notify params are only relevant for the original, Dark Messiah, and
|
|
||||||
* Episode 1 engines. Newer engines automatically do these things when the convar value is changed.
|
|
||||||
*
|
|
||||||
* @param convar Handle to the convar.
|
|
||||||
* @param value New boolean value.
|
|
||||||
* @param replicate If set to true, the new convar value will be set on all clients.
|
|
||||||
* This will only work if the convar has the FCVAR_REPLICATED flag
|
|
||||||
* and actually exists on clients.
|
|
||||||
* @param notify If set to true, clients will be notified that the convar has changed.
|
|
||||||
* This will only work if the convar has the FCVAR_NOTIFY flag.
|
|
||||||
* @noreturn
|
|
||||||
* @error Invalid or corrupt Handle.
|
|
||||||
*/
|
|
||||||
native SetConVarBool(Handle:convar, bool:value, bool:replicate=false, bool:notify=false);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the integer value of a console variable.
|
|
||||||
*
|
|
||||||
* @param convar Handle to the convar.
|
|
||||||
* @return The integer value of the convar.
|
|
||||||
* @error Invalid or corrupt Handle.
|
|
||||||
*/
|
|
||||||
native GetConVarInt(Handle:convar);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the integer value of a console variable.
|
|
||||||
*
|
|
||||||
* Note: The replicate and notify params are only relevant for the original, Dark Messiah, and
|
|
||||||
* Episode 1 engines. Newer engines automatically do these things when the convar value is changed.
|
|
||||||
*
|
|
||||||
* @param convar Handle to the convar.
|
|
||||||
* @param value New integer value.
|
|
||||||
* @param replicate If set to true, the new convar value will be set on all clients.
|
|
||||||
* This will only work if the convar has the FCVAR_REPLICATED flag
|
|
||||||
* and actually exists on clients.
|
|
||||||
* @param notify If set to true, clients will be notified that the convar has changed.
|
|
||||||
* This will only work if the convar has the FCVAR_NOTIFY flag.
|
|
||||||
* @noreturn
|
|
||||||
* @error Invalid or corrupt Handle.
|
|
||||||
*/
|
|
||||||
native SetConVarInt(Handle:convar, value, bool:replicate=false, bool:notify=false);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the floating point value of a console variable.
|
|
||||||
*
|
|
||||||
* @param convar Handle to the convar.
|
|
||||||
* @return The floating point value of the convar.
|
|
||||||
* @error Invalid or corrupt Handle.
|
|
||||||
*/
|
|
||||||
native Float:GetConVarFloat(Handle:convar);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the floating point value of a console variable.
|
|
||||||
*
|
|
||||||
* Note: The replicate and notify params are only relevant for the original, Dark Messiah, and
|
|
||||||
* Episode 1 engines. Newer engines automatically do these things when the convar value is changed.
|
|
||||||
*
|
|
||||||
* @param convar Handle to the convar.
|
|
||||||
* @param value New floating point value.
|
|
||||||
* @param replicate If set to true, the new convar value will be set on all clients.
|
|
||||||
* This will only work if the convar has the FCVAR_REPLICATED flag
|
|
||||||
* and actually exists on clients.
|
|
||||||
* @param notify If set to true, clients will be notified that the convar has changed.
|
|
||||||
* This will only work if the convar has the FCVAR_NOTIFY flag.
|
|
||||||
* @noreturn
|
|
||||||
* @error Invalid or corrupt Handle.
|
|
||||||
*/
|
|
||||||
native SetConVarFloat(Handle:convar, Float:value, bool:replicate=false, bool:notify=false);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Retrieves the string value of a console variable.
|
|
||||||
*
|
|
||||||
* @param convar Handle to the convar.
|
|
||||||
* @param value Buffer to store the value of the convar.
|
|
||||||
* @param maxlength Maximum length of string buffer.
|
|
||||||
* @noreturn
|
|
||||||
* @error Invalid or corrupt Handle.
|
|
||||||
*/
|
|
||||||
native GetConVarString(Handle:convar, String:value[], maxlength);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the string value of a console variable.
|
|
||||||
*
|
|
||||||
* Note: The replicate and notify params are only relevant for the original, Dark Messiah, and
|
|
||||||
* Episode 1 engines. Newer engines automatically do these things when the convar value is changed.
|
|
||||||
*
|
|
||||||
* @param convar Handle to the convar.
|
|
||||||
* @param value New string value.
|
|
||||||
* @param replicate If set to true, the new convar value will be set on all clients.
|
|
||||||
* This will only work if the convar has the FCVAR_REPLICATED flag
|
|
||||||
* and actually exists on clients.
|
|
||||||
* @param notify If set to true, clients will be notified that the convar has changed.
|
|
||||||
* This will only work if the convar has the FCVAR_NOTIFY flag.
|
|
||||||
* @noreturn
|
|
||||||
* @error Invalid or corrupt Handle.
|
|
||||||
*/
|
|
||||||
native SetConVarString(Handle:convar, const String:value[], bool:replicate=false, bool:notify=false);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Resets the console variable to its default value.
|
|
||||||
*
|
|
||||||
* Note: The replicate and notify params are only relevant for the original, Dark Messiah, and
|
|
||||||
* Episode 1 engines. Newer engines automatically do these things when the convar value is changed.
|
|
||||||
*
|
|
||||||
* @param convar Handle to the convar.
|
|
||||||
* @param replicate If set to true, the new convar value will be set on all clients.
|
|
||||||
* This will only work if the convar has the FCVAR_REPLICATED flag
|
|
||||||
* and actually exists on clients.
|
|
||||||
* @param notify If set to true, clients will be notified that the convar has changed.
|
|
||||||
* This will only work if the convar has the FCVAR_NOTIFY flag.
|
|
||||||
* @noreturn
|
|
||||||
* @error Invalid or corrupt Handle.
|
|
||||||
*/
|
|
||||||
native ResetConVar(Handle:convar, bool:replicate=false, bool:notify=false);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Retrieves the default string value of a console variable.
|
|
||||||
*
|
|
||||||
* @param convar Handle to the convar.
|
|
||||||
* @param value Buffer to store the default value of the convar.
|
|
||||||
* @param maxlength Maximum length of string buffer.
|
|
||||||
* @return Number of bytes written to the buffer (UTF-8 safe).
|
|
||||||
* @error Invalid or corrupt Handle.
|
|
||||||
*/
|
|
||||||
native GetConVarDefault(Handle:convar, String:value[], maxlength);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the bitstring of flags on a console variable.
|
|
||||||
*
|
|
||||||
* @param convar Handle to the convar.
|
|
||||||
* @return A bitstring containing the FCVAR_* flags that are enabled.
|
|
||||||
* @error Invalid or corrupt Handle.
|
|
||||||
*/
|
|
||||||
native GetConVarFlags(Handle:convar);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the bitstring of flags on a console variable.
|
|
||||||
*
|
|
||||||
* @param convar Handle to the convar.
|
|
||||||
* @param flags A bitstring containing the FCVAR_* flags to enable.
|
|
||||||
* @noreturn
|
|
||||||
* @error Invalid or corrupt Handle.
|
|
||||||
*/
|
|
||||||
native SetConVarFlags(Handle:convar, flags);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Retrieves the specified bound of a console variable.
|
|
||||||
*
|
|
||||||
* @param convar Handle to the convar.
|
|
||||||
* @param type Type of bound to retrieve, ConVarBound_Lower or ConVarBound_Upper.
|
|
||||||
* @param value By-reference cell to store the specified floating point bound value.
|
|
||||||
* @return True if the convar has the specified bound set, false otherwise.
|
|
||||||
* @error Invalid or corrupt Handle.
|
|
||||||
*/
|
|
||||||
native bool:GetConVarBounds(Handle:convar, ConVarBounds:type, &Float:value);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the specified bound of a console variable.
|
|
||||||
*
|
|
||||||
* @param convar Handle to the convar.
|
|
||||||
* @param type Type of bound to set, ConVarBound_Lower or ConVarBound_Upper
|
|
||||||
* @param set If set to true, convar will use specified bound. If false, bound will be removed.
|
|
||||||
* @param value Floating point value to use as the specified bound.
|
|
||||||
* @noreturn
|
|
||||||
* @error Invalid or corrupt Handle.
|
|
||||||
*/
|
|
||||||
native SetConVarBounds(Handle:convar, ConVarBounds:type, bool:set, Float:value=0.0);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Retrieves the name of a console variable.
|
|
||||||
*
|
|
||||||
* @param convar Handle to the convar.
|
|
||||||
* @param name Buffer to store the name of the convar.
|
|
||||||
* @param maxlength Maximum length of string buffer.
|
|
||||||
* @noreturn
|
|
||||||
* @error Invalid or corrupt Handle.
|
|
||||||
*/
|
|
||||||
native GetConVarName(Handle:convar, String:name[], maxlength);
|
|
||||||
|
|
||||||
funcenum ConVarQueryFinished
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Called when a query to retrieve a client's console variable has finished.
|
|
||||||
*
|
|
||||||
* @param cookie Unique identifier of query.
|
|
||||||
* @param client Player index.
|
|
||||||
* @param result Result of query that tells one whether or not query was successful.
|
|
||||||
* See ConVarQueryResult enum for more details.
|
|
||||||
* @param convarName Name of client convar that was queried.
|
|
||||||
* @param convarValue Value of client convar that was queried if successful. This will be "" if it was not.
|
|
||||||
* @param value Value that was passed when query was started.
|
|
||||||
* @noreturn
|
|
||||||
*/
|
|
||||||
public(QueryCookie:cookie, client, ConVarQueryResult:result, const String:cvarName[], const String:cvarValue[], any:value),
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Called when a query to retrieve a client's console variable has finished.
|
|
||||||
*
|
|
||||||
* @param cookie Unique identifier of query.
|
|
||||||
* @param client Player index.
|
|
||||||
* @param result Result of query that tells one whether or not query was successful.
|
|
||||||
* See ConVarQueryResult enum for more details.
|
|
||||||
* @param convarName Name of client convar that was queried.
|
|
||||||
* @param convarValue Value of client convar that was queried if successful. This will be "" if it was not.
|
|
||||||
* @noreturn
|
|
||||||
*/
|
|
||||||
public(QueryCookie:cookie, client, ConVarQueryResult:result, const String:cvarName[], const String:cvarValue[])
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Starts a query to retrieve the value of a client's console variable.
|
|
||||||
*
|
|
||||||
* @param client Player index.
|
|
||||||
* @param cvarName Name of client convar to query.
|
|
||||||
* @param callback A function to use as a callback when the query has finished.
|
|
||||||
* @param value Optional value to pass to the callback function.
|
|
||||||
* @return A cookie that uniquely identifies the query.
|
|
||||||
* Returns QUERYCOOKIE_FAILED on failure, such as when used on a bot.
|
|
||||||
*/
|
|
||||||
native QueryCookie:QueryClientConVar(client, const String:cvarName[], ConVarQueryFinished:callback, any:value=0);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets a command iterator. Must be freed with CloseHandle().
|
* Gets a command iterator. Must be freed with CloseHandle().
|
||||||
*
|
*
|
||||||
|
@ -781,17 +474,6 @@ native bool:CheckAccess(AdminId:id,
|
||||||
flags,
|
flags,
|
||||||
bool:override_only=false);
|
bool:override_only=false);
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns true if the supplied character is valid in a ConVar name.
|
|
||||||
*
|
|
||||||
* @param c Character to validate.
|
|
||||||
* @return True is valid for ConVars, false otherwise
|
|
||||||
*/
|
|
||||||
stock bool:IsValidConVarChar(c)
|
|
||||||
{
|
|
||||||
return (c == '_' || IsCharAlpha(c) || IsCharNumeric(c));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the bitstring of flags of a command.
|
* Returns the bitstring of flags of a command.
|
||||||
*
|
*
|
||||||
|
@ -850,17 +532,6 @@ native Handle:FindFirstConCommand(String:buffer[], max_size, &bool:isCommand, &f
|
||||||
*/
|
*/
|
||||||
native bool:FindNextConCommand(Handle:search, String:buffer[], max_size, &bool:isCommand, &flags=0, String:description[]="", descrmax_size=0);
|
native bool:FindNextConCommand(Handle:search, String:buffer[], max_size, &bool:isCommand, &flags=0, String:description[]="", descrmax_size=0);
|
||||||
|
|
||||||
/**
|
|
||||||
* Replicates a convar value to a specific client. This does not change the actual convar value.
|
|
||||||
*
|
|
||||||
* @param client Client index
|
|
||||||
* @param convar ConVar handle
|
|
||||||
* @param value String value to send
|
|
||||||
* @return True on success, false on failure
|
|
||||||
* @error Invalid client index, client not in game, or client is fake
|
|
||||||
*/
|
|
||||||
native bool:SendConVarValue(client, Handle:convar, const String:value[]);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds an informational string to the server's public "tags".
|
* Adds an informational string to the server's public "tags".
|
||||||
* This string should be a short, unique identifier.
|
* This string should be a short, unique identifier.
|
||||||
|
@ -905,7 +576,7 @@ native RemoveServerTag(const String:tag[]);
|
||||||
* @param argc Argument count.
|
* @param argc Argument count.
|
||||||
* @return Action to take (see extended notes above).
|
* @return Action to take (see extended notes above).
|
||||||
*/
|
*/
|
||||||
functag public Action:CommandListener(client, const String:command[], argc);
|
typedef CommandListener = function Action (int client, const char[] command, int argc);
|
||||||
|
|
||||||
#define FEATURECAP_COMMANDLISTENER "command listener"
|
#define FEATURECAP_COMMANDLISTENER "command listener"
|
||||||
|
|
||||||
|
@ -968,4 +639,4 @@ forward Action:OnClientSayCommand(client, const String:command[], const String:s
|
||||||
* @param sArgs Chat argument string.
|
* @param sArgs Chat argument string.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
forward OnClientSayCommand_Post(client, const String:command[], const String:sArgs[]);
|
forward void OnClientSayCommand_Post(int client, const char[] command, const char[] sArgs);
|
||||||
|
|
493
env/include/convars.inc
vendored
Normal file
493
env/include/convars.inc
vendored
Normal file
|
@ -0,0 +1,493 @@
|
||||||
|
/**
|
||||||
|
* vim: set ts=4 sw=4 tw=99 noet :
|
||||||
|
* =============================================================================
|
||||||
|
* SourceMod (C)2004-2014 AlliedModders LLC. All rights reserved.
|
||||||
|
* =============================================================================
|
||||||
|
*
|
||||||
|
* This file is part of the SourceMod/SourcePawn SDK.
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify it under
|
||||||
|
* the terms of the GNU General Public License, version 3.0, as published by the
|
||||||
|
* Free Software Foundation.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||||
|
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||||
|
* details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along with
|
||||||
|
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
* As a special exception, AlliedModders LLC gives you permission to link the
|
||||||
|
* code of this program (as well as its derivative works) to "Half-Life 2," the
|
||||||
|
* "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
|
||||||
|
* by the Valve Corporation. You must obey the GNU General Public License in
|
||||||
|
* all respects for all other code used. Additionally, AlliedModders LLC grants
|
||||||
|
* this exception to all derivative works. AlliedModders LLC defines further
|
||||||
|
* exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
|
||||||
|
* or <http://www.sourcemod.net/license.php>.
|
||||||
|
*
|
||||||
|
* Version: $Id$
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Console variable bound values used with Get/SetConVarBounds()
|
||||||
|
*/
|
||||||
|
enum ConVarBounds
|
||||||
|
{
|
||||||
|
ConVarBound_Upper = 0,
|
||||||
|
ConVarBound_Lower
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Console variable query result values.
|
||||||
|
*/
|
||||||
|
enum ConVarQueryResult
|
||||||
|
{
|
||||||
|
ConVarQuery_Okay = 0, //< Retrieval of client convar value was successful. */
|
||||||
|
ConVarQuery_NotFound, //< Client convar was not found. */
|
||||||
|
ConVarQuery_NotValid, //< A console command with the same name was found, but there is no convar. */
|
||||||
|
ConVarQuery_Protected //< Client convar was found, but it is protected. The server cannot retrieve its value. */
|
||||||
|
};
|
||||||
|
|
||||||
|
// Called when a console variable's value is changed.
|
||||||
|
//
|
||||||
|
// @param convar Handle to the convar that was changed.
|
||||||
|
// @param oldValue String containing the value of the convar before it was changed.
|
||||||
|
// @param newValue String containing the new value of the convar.
|
||||||
|
typedef ConVarChanged = function void (ConVar convar, const char[] oldValue, const char[] newValue);
|
||||||
|
|
||||||
|
// Creates a new console variable.
|
||||||
|
//
|
||||||
|
// @param name Name of new convar.
|
||||||
|
// @param defaultValue String containing the default value of new convar.
|
||||||
|
// @param description Optional description of the convar.
|
||||||
|
// @param flags Optional bitstring of flags determining how the convar should be handled. See FCVAR_* constants for more details.
|
||||||
|
// @param hasMin Optional boolean that determines if the convar has a minimum value.
|
||||||
|
// @param min Minimum floating point value that the convar can have if hasMin is true.
|
||||||
|
// @param hasMax Optional boolean that determines if the convar has a maximum value.
|
||||||
|
// @param max Maximum floating point value that the convar can have if hasMax is true.
|
||||||
|
// @return A handle to the newly created convar. If the convar already exists, a handle to it will still be returned.
|
||||||
|
// @error Convar name is blank or is the same as an existing console command.
|
||||||
|
native ConVar CreateConVar(
|
||||||
|
const char[] name,
|
||||||
|
const char[] defaultValue,
|
||||||
|
const char[] description="",
|
||||||
|
int flags=0,
|
||||||
|
bool hasMin=false, float min=0.0,
|
||||||
|
bool hasMax=false, float max=0.0);
|
||||||
|
|
||||||
|
// Searches for a console variable.
|
||||||
|
//
|
||||||
|
// @param name Name of convar to find.
|
||||||
|
// @return A ConVar object if found; null otherwise.
|
||||||
|
native ConVar FindConVar(const char[] name);
|
||||||
|
|
||||||
|
// A ConVar is a configurable, named setting in the srcds console.
|
||||||
|
methodmap ConVar < Handle
|
||||||
|
{
|
||||||
|
// Retrieves or sets a boolean value for the convar.
|
||||||
|
property bool BoolValue {
|
||||||
|
public native get();
|
||||||
|
public native set(bool b);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Retrieves or sets an integer value for the convar.
|
||||||
|
property int IntValue {
|
||||||
|
public native get();
|
||||||
|
public native set(int value);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Retrieves or sets a float value for the convar.
|
||||||
|
property float FloatValue {
|
||||||
|
public native get();
|
||||||
|
public native set(float value);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Gets or sets the flag bits (FCVAR_*) on the convar.
|
||||||
|
property int Flags {
|
||||||
|
public native get();
|
||||||
|
public native set(int flags);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Sets the boolean value of a console variable.
|
||||||
|
//
|
||||||
|
// Note: The replicate and notify params are only relevant for the
|
||||||
|
// original, Dark Messiah, and Episode 1 engines. Newer engines
|
||||||
|
// automatically do these things when the convar value is changed.
|
||||||
|
//
|
||||||
|
// @param value New boolean value.
|
||||||
|
// @param replicate If set to true, the new convar value will be set on all clients.
|
||||||
|
// This will only work if the convar has the FCVAR_REPLICATED flag
|
||||||
|
// and actually exists on clients.
|
||||||
|
// @param notify If set to true, clients will be notified that the convar has changed.
|
||||||
|
// This will only work if the convar has the FCVAR_NOTIFY flag.
|
||||||
|
public native void SetBool(bool value, bool replicate=false, bool notify=false);
|
||||||
|
|
||||||
|
// Sets the integer value of a console variable.
|
||||||
|
//
|
||||||
|
// Note: The replicate and notify params are only relevant for the
|
||||||
|
// original, Dark Messiah, and Episode 1 engines. Newer engines
|
||||||
|
// automatically do these things when the convar value is changed.
|
||||||
|
//
|
||||||
|
// @param value New integer value.
|
||||||
|
// @param replicate If set to true, the new convar value will be set on all clients.
|
||||||
|
// This will only work if the convar has the FCVAR_REPLICATED flag
|
||||||
|
// and actually exists on clients.
|
||||||
|
// @param notify If set to true, clients will be notified that the convar has changed.
|
||||||
|
// This will only work if the convar has the FCVAR_NOTIFY flag.
|
||||||
|
public native void SetInt(int value, bool replicate=false, bool notify=false);
|
||||||
|
|
||||||
|
// Sets the floating point value of a console variable.
|
||||||
|
//
|
||||||
|
// Note: The replicate and notify params are only relevant for the
|
||||||
|
// original, Dark Messiah, and Episode 1 engines. Newer engines
|
||||||
|
// automatically do these things when the convar value is changed.
|
||||||
|
//
|
||||||
|
// @param value New floating point value.
|
||||||
|
// @param replicate If set to true, the new convar value will be set on all clients.
|
||||||
|
// This will only work if the convar has the FCVAR_REPLICATED flag
|
||||||
|
// and actually exists on clients.
|
||||||
|
// @param notify If set to true, clients will be notified that the convar has changed.
|
||||||
|
// This will only work if the convar has the FCVAR_NOTIFY flag.
|
||||||
|
public native void SetFloat(float value, bool replicate=false, bool notify=false);
|
||||||
|
|
||||||
|
// Retrieves the string value of a console variable.
|
||||||
|
//
|
||||||
|
// @param convar Handle to the convar.
|
||||||
|
// @param value Buffer to store the value of the convar.
|
||||||
|
// @param maxlength Maximum length of string buffer.
|
||||||
|
public native void GetString(char[] value, int maxlength);
|
||||||
|
|
||||||
|
// Sets the string value of a console variable.
|
||||||
|
//
|
||||||
|
// Note: The replicate and notify params are only relevant for the
|
||||||
|
// original, Dark Messiah, and Episode 1 engines. Newer engines
|
||||||
|
// automatically do these things when the convar value is changed.
|
||||||
|
//
|
||||||
|
// @param value New string value.
|
||||||
|
// @param replicate If set to true, the new convar value will be set on all clients.
|
||||||
|
// This will only work if the convar has the FCVAR_REPLICATED flag
|
||||||
|
// and actually exists on clients.
|
||||||
|
// @param notify If set to true, clients will be notified that the convar has changed.
|
||||||
|
// This will only work if the convar has the FCVAR_NOTIFY flag.
|
||||||
|
public native void SetString(const char[] value, bool replicate=false, bool notify=false);
|
||||||
|
|
||||||
|
// Resets the console variable to its default value.
|
||||||
|
//
|
||||||
|
// Note: The replicate and notify params are only relevant for the
|
||||||
|
// original, Dark Messiah, and Episode 1 engines. Newer engines
|
||||||
|
// automatically do these things when the convar value is changed.
|
||||||
|
//
|
||||||
|
// @param replicate If set to true, the new convar value will be set on all clients.
|
||||||
|
// This will only work if the convar has the FCVAR_REPLICATED flag
|
||||||
|
// and actually exists on clients.
|
||||||
|
// @param notify If set to true, clients will be notified that the convar has changed.
|
||||||
|
// This will only work if the convar has the FCVAR_NOTIFY flag.
|
||||||
|
public native void RestoreDefault(bool replicate=false, bool notify=false);
|
||||||
|
|
||||||
|
// Retrieves the default string value of a console variable.
|
||||||
|
//
|
||||||
|
// @param value Buffer to store the default value of the convar.
|
||||||
|
// @param maxlength Maximum length of string buffer.
|
||||||
|
// @return Number of bytes written to the buffer (UTF-8 safe).
|
||||||
|
public native int GetDefault(char[] value, int maxlength);
|
||||||
|
|
||||||
|
// Retrieves the specified bound of a console variable.
|
||||||
|
//
|
||||||
|
// @param type Type of bound to retrieve, ConVarBound_Lower or ConVarBound_Upper.
|
||||||
|
// @param value By-reference cell to store the specified floating point bound value.
|
||||||
|
// @return True if the convar has the specified bound set, false otherwise.
|
||||||
|
public native bool GetBounds(ConVarBounds type, float &value);
|
||||||
|
|
||||||
|
// Sets the specified bound of a console variable.
|
||||||
|
//
|
||||||
|
// @param type Type of bound to set, ConVarBound_Lower or ConVarBound_Upper
|
||||||
|
// @param set If set to true, convar will use specified bound. If false, bound will be removed.
|
||||||
|
// @param value Floating point value to use as the specified bound.
|
||||||
|
public native void SetBounds(ConVarBounds type, bool set, float value=0.0);
|
||||||
|
|
||||||
|
// Retrieves the name of a console variable.
|
||||||
|
//
|
||||||
|
// @param name Buffer to store the name of the convar.
|
||||||
|
// @param maxlength Maximum length of string buffer.
|
||||||
|
public native void GetName(char[] name, maxlength);
|
||||||
|
|
||||||
|
// Replicates a convar value to a specific client. This does not change the actual convar value.
|
||||||
|
//
|
||||||
|
// @param client Client index
|
||||||
|
// @param value String value to send
|
||||||
|
// @return True on success, false on failure
|
||||||
|
// @error Invalid client index, client not in game, or client is fake
|
||||||
|
public native bool ReplicateToClient(int client, const char[] value);
|
||||||
|
|
||||||
|
// Creates a hook for when a console variable's value is changed.
|
||||||
|
//
|
||||||
|
// @param callback An OnConVarChanged function pointer.
|
||||||
|
public native void AddChangeHook(ConVarChanged callback);
|
||||||
|
|
||||||
|
// Removes a hook for when a console variable's value is changed.
|
||||||
|
//
|
||||||
|
// @param convar Handle to the convar.
|
||||||
|
// @param callback An OnConVarChanged function pointer.
|
||||||
|
// @error No active hook on convar.
|
||||||
|
public native void RemoveChangeHook(ConVarChanged callback);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a hook for when a console variable's value is changed.
|
||||||
|
*
|
||||||
|
* @param convar Handle to the convar.
|
||||||
|
* @param callback An OnConVarChanged function pointer.
|
||||||
|
* @error Invalid or corrupt Handle or invalid callback function.
|
||||||
|
*/
|
||||||
|
native void HookConVarChange(Handle convar, ConVarChanged callback);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Removes a hook for when a console variable's value is changed.
|
||||||
|
*
|
||||||
|
* @param convar Handle to the convar.
|
||||||
|
* @param callback An OnConVarChanged function pointer.
|
||||||
|
* @error Invalid or corrupt Handle, invalid callback function, or no active hook on convar.
|
||||||
|
*/
|
||||||
|
native void UnhookConVarChange(Handle convar, ConVarChanged callback);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the boolean value of a console variable.
|
||||||
|
*
|
||||||
|
* @param convar Handle to the convar.
|
||||||
|
* @return The boolean value of the convar.
|
||||||
|
* @error Invalid or corrupt Handle.
|
||||||
|
*/
|
||||||
|
native bool GetConVarBool(Handle convar);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the boolean value of a console variable.
|
||||||
|
*
|
||||||
|
* Note: The replicate and notify params are only relevant for the original, Dark Messiah, and
|
||||||
|
* Episode 1 engines. Newer engines automatically do these things when the convar value is changed.
|
||||||
|
*
|
||||||
|
* @param convar Handle to the convar.
|
||||||
|
* @param value New boolean value.
|
||||||
|
* @param replicate If set to true, the new convar value will be set on all clients.
|
||||||
|
* This will only work if the convar has the FCVAR_REPLICATED flag
|
||||||
|
* and actually exists on clients.
|
||||||
|
* @param notify If set to true, clients will be notified that the convar has changed.
|
||||||
|
* This will only work if the convar has the FCVAR_NOTIFY flag.
|
||||||
|
* @error Invalid or corrupt Handle.
|
||||||
|
*/
|
||||||
|
native void SetConVarBool(Handle convar, bool value, bool replicate=false, bool notify=false);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the integer value of a console variable.
|
||||||
|
*
|
||||||
|
* @param convar Handle to the convar.
|
||||||
|
* @return The integer value of the convar.
|
||||||
|
* @error Invalid or corrupt Handle.
|
||||||
|
*/
|
||||||
|
native int GetConVarInt(Handle convar);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the integer value of a console variable.
|
||||||
|
*
|
||||||
|
* Note: The replicate and notify params are only relevant for the original, Dark Messiah, and
|
||||||
|
* Episode 1 engines. Newer engines automatically do these things when the convar value is changed.
|
||||||
|
*
|
||||||
|
* @param convar Handle to the convar.
|
||||||
|
* @param value New integer value.
|
||||||
|
* @param replicate If set to true, the new convar value will be set on all clients.
|
||||||
|
* This will only work if the convar has the FCVAR_REPLICATED flag
|
||||||
|
* and actually exists on clients.
|
||||||
|
* @param notify If set to true, clients will be notified that the convar has changed.
|
||||||
|
* This will only work if the convar has the FCVAR_NOTIFY flag.
|
||||||
|
* @error Invalid or corrupt Handle.
|
||||||
|
*/
|
||||||
|
native void SetConVarInt(Handle convar, int value, bool replicate=false, bool notify=false);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the floating point value of a console variable.
|
||||||
|
*
|
||||||
|
* @param convar Handle to the convar.
|
||||||
|
* @return The floating point value of the convar.
|
||||||
|
* @error Invalid or corrupt Handle.
|
||||||
|
*/
|
||||||
|
native float GetConVarFloat(Handle convar);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the floating point value of a console variable.
|
||||||
|
*
|
||||||
|
* Note: The replicate and notify params are only relevant for the original, Dark Messiah, and
|
||||||
|
* Episode 1 engines. Newer engines automatically do these things when the convar value is changed.
|
||||||
|
*
|
||||||
|
* @param convar Handle to the convar.
|
||||||
|
* @param value New floating point value.
|
||||||
|
* @param replicate If set to true, the new convar value will be set on all clients.
|
||||||
|
* This will only work if the convar has the FCVAR_REPLICATED flag
|
||||||
|
* and actually exists on clients.
|
||||||
|
* @param notify If set to true, clients will be notified that the convar has changed.
|
||||||
|
* This will only work if the convar has the FCVAR_NOTIFY flag.
|
||||||
|
* @error Invalid or corrupt Handle.
|
||||||
|
*/
|
||||||
|
native void SetConVarFloat(Handle convar, float value, bool replicate=false, bool notify=false);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieves the string value of a console variable.
|
||||||
|
*
|
||||||
|
* @param convar Handle to the convar.
|
||||||
|
* @param value Buffer to store the value of the convar.
|
||||||
|
* @param maxlength Maximum length of string buffer.
|
||||||
|
* @error Invalid or corrupt Handle.
|
||||||
|
*/
|
||||||
|
native void GetConVarString(Handle convar, char[] value, int maxlength);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the string value of a console variable.
|
||||||
|
*
|
||||||
|
* Note: The replicate and notify params are only relevant for the original, Dark Messiah, and
|
||||||
|
* Episode 1 engines. Newer engines automatically do these things when the convar value is changed.
|
||||||
|
*
|
||||||
|
* @param convar Handle to the convar.
|
||||||
|
* @param value New string value.
|
||||||
|
* @param replicate If set to true, the new convar value will be set on all clients.
|
||||||
|
* This will only work if the convar has the FCVAR_REPLICATED flag
|
||||||
|
* and actually exists on clients.
|
||||||
|
* @param notify If set to true, clients will be notified that the convar has changed.
|
||||||
|
* This will only work if the convar has the FCVAR_NOTIFY flag.
|
||||||
|
* @error Invalid or corrupt Handle.
|
||||||
|
*/
|
||||||
|
native void SetConVarString(Handle convar, const char[] value, bool replicate=false, bool notify=false);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Resets the console variable to its default value.
|
||||||
|
*
|
||||||
|
* Note: The replicate and notify params are only relevant for the original, Dark Messiah, and
|
||||||
|
* Episode 1 engines. Newer engines automatically do these things when the convar value is changed.
|
||||||
|
*
|
||||||
|
* @param convar Handle to the convar.
|
||||||
|
* @param replicate If set to true, the new convar value will be set on all clients.
|
||||||
|
* This will only work if the convar has the FCVAR_REPLICATED flag
|
||||||
|
* and actually exists on clients.
|
||||||
|
* @param notify If set to true, clients will be notified that the convar has changed.
|
||||||
|
* This will only work if the convar has the FCVAR_NOTIFY flag.
|
||||||
|
* @error Invalid or corrupt Handle.
|
||||||
|
*/
|
||||||
|
native void ResetConVar(Handle convar, bool replicate=false, bool notify=false);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieves the default string value of a console variable.
|
||||||
|
*
|
||||||
|
* @param convar Handle to the convar.
|
||||||
|
* @param value Buffer to store the default value of the convar.
|
||||||
|
* @param maxlength Maximum length of string buffer.
|
||||||
|
* @return Number of bytes written to the buffer (UTF-8 safe).
|
||||||
|
* @error Invalid or corrupt Handle.
|
||||||
|
*/
|
||||||
|
native int GetConVarDefault(Handle convar, char[] value, int maxlength);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the bitstring of flags on a console variable.
|
||||||
|
*
|
||||||
|
* @param convar Handle to the convar.
|
||||||
|
* @return A bitstring containing the FCVAR_* flags that are enabled.
|
||||||
|
* @error Invalid or corrupt Handle.
|
||||||
|
*/
|
||||||
|
native int GetConVarFlags(Handle convar);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the bitstring of flags on a console variable.
|
||||||
|
*
|
||||||
|
* @param convar Handle to the convar.
|
||||||
|
* @param flags A bitstring containing the FCVAR_* flags to enable.
|
||||||
|
* @error Invalid or corrupt Handle.
|
||||||
|
*/
|
||||||
|
native void SetConVarFlags(Handle convar, flags);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieves the specified bound of a console variable.
|
||||||
|
*
|
||||||
|
* @param convar Handle to the convar.
|
||||||
|
* @param type Type of bound to retrieve, ConVarBound_Lower or ConVarBound_Upper.
|
||||||
|
* @param value By-reference cell to store the specified floating point bound value.
|
||||||
|
* @return True if the convar has the specified bound set, false otherwise.
|
||||||
|
* @error Invalid or corrupt Handle.
|
||||||
|
*/
|
||||||
|
native bool GetConVarBounds(Handle convar, ConVarBounds type, float &value);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the specified bound of a console variable.
|
||||||
|
*
|
||||||
|
* @param convar Handle to the convar.
|
||||||
|
* @param type Type of bound to set, ConVarBound_Lower or ConVarBound_Upper
|
||||||
|
* @param set If set to true, convar will use specified bound. If false, bound will be removed.
|
||||||
|
* @param value Floating point value to use as the specified bound.
|
||||||
|
* @error Invalid or corrupt Handle.
|
||||||
|
*/
|
||||||
|
native void SetConVarBounds(Handle convar, ConVarBounds type, bool set, float value=0.0);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieves the name of a console variable.
|
||||||
|
*
|
||||||
|
* @param convar Handle to the convar.
|
||||||
|
* @param name Buffer to store the name of the convar.
|
||||||
|
* @param maxlength Maximum length of string buffer.
|
||||||
|
* @error Invalid or corrupt Handle.
|
||||||
|
*/
|
||||||
|
native void GetConVarName(Handle convar, char[] name, maxlength);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Replicates a convar value to a specific client. This does not change the actual convar value.
|
||||||
|
*
|
||||||
|
* @param client Client index
|
||||||
|
* @param convar ConVar handle
|
||||||
|
* @param value String value to send
|
||||||
|
* @return True on success, false on failure
|
||||||
|
* @error Invalid client index, client not in game, or client is fake
|
||||||
|
*/
|
||||||
|
native bool SendConVarValue(int client, Handle convar, const char[] value);
|
||||||
|
|
||||||
|
typeset ConVarQueryFinished
|
||||||
|
{
|
||||||
|
// Called when a query to retrieve a client's console variable has finished.
|
||||||
|
//
|
||||||
|
// @param cookie Unique identifier of query.
|
||||||
|
// @param client Player index.
|
||||||
|
// @param result Result of query that tells one whether or not query was successful.
|
||||||
|
// See ConVarQueryResult enum for more details.
|
||||||
|
// @param convarName Name of client convar that was queried.
|
||||||
|
// @param convarValue Value of client convar that was queried if successful. This will be "" if it was not.
|
||||||
|
// @param value Value that was passed when query was started.
|
||||||
|
function void (QueryCookie cookie, int client, ConVarQueryResult result, const char[] cvarName, const char[] cvarValue, any value);
|
||||||
|
|
||||||
|
// Called when a query to retrieve a client's console variable has finished.
|
||||||
|
//
|
||||||
|
// @param cookie Unique identifier of query.
|
||||||
|
// @param client Player index.
|
||||||
|
// @param result Result of query that tells one whether or not query was successful.
|
||||||
|
// See ConVarQueryResult enum for more details.
|
||||||
|
// @param convarName Name of client convar that was queried.
|
||||||
|
// @param convarValue Value of client convar that was queried if successful. This will be "" if it was not.
|
||||||
|
function void (QueryCookie cookie, int client, ConVarQueryResult result, const char[] cvarName, const char[] cvarValue);
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Starts a query to retrieve the value of a client's console variable.
|
||||||
|
*
|
||||||
|
* @param client Player index.
|
||||||
|
* @param cvarName Name of client convar to query.
|
||||||
|
* @param callback A function to use as a callback when the query has finished.
|
||||||
|
* @param value Optional value to pass to the callback function.
|
||||||
|
* @return A cookie that uniquely identifies the query.
|
||||||
|
* Returns QUERYCOOKIE_FAILED on failure, such as when used on a bot.
|
||||||
|
*/
|
||||||
|
native QueryCookie QueryClientConVar(int client, const char[] cvarName, ConVarQueryFinished callback, any value=0);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns true if the supplied character is valid in a ConVar name.
|
||||||
|
*
|
||||||
|
* @param c Character to validate.
|
||||||
|
* @return True is valid for ConVars, false otherwise
|
||||||
|
*/
|
||||||
|
stock bool IsValidConVarChar(int c)
|
||||||
|
{
|
||||||
|
return (c == '_' || IsCharAlpha(c) || IsCharNumeric(c));
|
||||||
|
}
|
104
env/include/core.inc
vendored
104
env/include/core.inc
vendored
|
@ -42,18 +42,10 @@
|
||||||
|
|
||||||
struct PlVers
|
struct PlVers
|
||||||
{
|
{
|
||||||
version,
|
public int version;
|
||||||
String:filevers[],
|
public const char[] filevers;
|
||||||
String:date[],
|
public const char[] date;
|
||||||
String:time[]
|
public const char[] time;
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Function helper values.
|
|
||||||
*/
|
|
||||||
enum Function
|
|
||||||
{
|
|
||||||
INVALID_FUNCTION = -1,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -103,7 +95,19 @@ enum PluginStatus
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Plugin information properties.
|
* Plugin information properties. Plugins can declare a global variable with
|
||||||
|
* their info. Example,
|
||||||
|
*
|
||||||
|
* public Plugin:myinfo = {
|
||||||
|
* name = "Admin Help",
|
||||||
|
* author = "AlliedModders LLC",
|
||||||
|
* description = "Display command information",
|
||||||
|
* version = "1.0",
|
||||||
|
* url = "http://www.sourcemod.net/"
|
||||||
|
* };
|
||||||
|
*
|
||||||
|
* SourceMod will display this information when a user inspects plugins in the
|
||||||
|
* console.
|
||||||
*/
|
*/
|
||||||
enum PluginInfo
|
enum PluginInfo
|
||||||
{
|
{
|
||||||
|
@ -119,10 +123,10 @@ enum PluginInfo
|
||||||
*/
|
*/
|
||||||
struct Extension
|
struct Extension
|
||||||
{
|
{
|
||||||
const String:name[], /**< Short name */
|
public const char[] name; /**< Short name */
|
||||||
const String:file[], /**< Default file name */
|
public const char[] file; /**< Default file name */
|
||||||
bool:autoload, /**< Whether or not to auto-load */
|
public bool autoload; /**< Whether or not to auto-load */
|
||||||
bool:required, /**< Whether or not to require */
|
public bool required; /**< Whether or not to require */
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -130,9 +134,9 @@ struct Extension
|
||||||
*/
|
*/
|
||||||
struct SharedPlugin
|
struct SharedPlugin
|
||||||
{
|
{
|
||||||
const String:name[], /**< Short name */
|
public const char[] name; /**< Short name */
|
||||||
const String:file[], /**< File name */
|
public const char[] file; /**< File name */
|
||||||
bool:required, /**< Whether or not to require */
|
public bool required; /**< Whether or not to require */
|
||||||
};
|
};
|
||||||
|
|
||||||
public Float:NULL_VECTOR[3]; /**< Pass this into certain functions to act as a C++ NULL */
|
public Float:NULL_VECTOR[3]; /**< Pass this into certain functions to act as a C++ NULL */
|
||||||
|
@ -197,6 +201,36 @@ public __ext_core_SetNTVOptional()
|
||||||
MarkNativeAsOptional("BfReadVecNormal");
|
MarkNativeAsOptional("BfReadVecNormal");
|
||||||
MarkNativeAsOptional("BfReadAngles");
|
MarkNativeAsOptional("BfReadAngles");
|
||||||
MarkNativeAsOptional("BfGetNumBytesLeft");
|
MarkNativeAsOptional("BfGetNumBytesLeft");
|
||||||
|
|
||||||
|
MarkNativeAsOptional("BfWrite.WriteBool");
|
||||||
|
MarkNativeAsOptional("BfWrite.WriteByte");
|
||||||
|
MarkNativeAsOptional("BfWrite.WriteChar");
|
||||||
|
MarkNativeAsOptional("BfWrite.WriteShort");
|
||||||
|
MarkNativeAsOptional("BfWrite.WriteWord");
|
||||||
|
MarkNativeAsOptional("BfWrite.WriteNum");
|
||||||
|
MarkNativeAsOptional("BfWrite.WriteFloat");
|
||||||
|
MarkNativeAsOptional("BfWrite.WriteString");
|
||||||
|
MarkNativeAsOptional("BfWrite.WriteEntity");
|
||||||
|
MarkNativeAsOptional("BfWrite.WriteAngle");
|
||||||
|
MarkNativeAsOptional("BfWrite.WriteCoord");
|
||||||
|
MarkNativeAsOptional("BfWrite.WriteVecCoord");
|
||||||
|
MarkNativeAsOptional("BfWrite.WriteVecNormal");
|
||||||
|
MarkNativeAsOptional("BfWrite.WriteAngles");
|
||||||
|
MarkNativeAsOptional("BfRead.ReadBool");
|
||||||
|
MarkNativeAsOptional("BfRead.ReadByte");
|
||||||
|
MarkNativeAsOptional("BfRead.ReadChar");
|
||||||
|
MarkNativeAsOptional("BfRead.ReadShort");
|
||||||
|
MarkNativeAsOptional("BfRead.ReadWord");
|
||||||
|
MarkNativeAsOptional("BfRead.ReadNum");
|
||||||
|
MarkNativeAsOptional("BfRead.ReadFloat");
|
||||||
|
MarkNativeAsOptional("BfRead.ReadString");
|
||||||
|
MarkNativeAsOptional("BfRead.ReadEntity");
|
||||||
|
MarkNativeAsOptional("BfRead.ReadAngle");
|
||||||
|
MarkNativeAsOptional("BfRead.ReadCoord");
|
||||||
|
MarkNativeAsOptional("BfRead.ReadVecCoord");
|
||||||
|
MarkNativeAsOptional("BfRead.ReadVecNormal");
|
||||||
|
MarkNativeAsOptional("BfRead.ReadAngles");
|
||||||
|
MarkNativeAsOptional("BfRead.GetNumBytesLeft");
|
||||||
|
|
||||||
MarkNativeAsOptional("PbReadInt");
|
MarkNativeAsOptional("PbReadInt");
|
||||||
MarkNativeAsOptional("PbReadFloat");
|
MarkNativeAsOptional("PbReadFloat");
|
||||||
|
@ -227,6 +261,36 @@ public __ext_core_SetNTVOptional()
|
||||||
MarkNativeAsOptional("PbReadMessage");
|
MarkNativeAsOptional("PbReadMessage");
|
||||||
MarkNativeAsOptional("PbReadRepeatedMessage");
|
MarkNativeAsOptional("PbReadRepeatedMessage");
|
||||||
MarkNativeAsOptional("PbAddMessage");
|
MarkNativeAsOptional("PbAddMessage");
|
||||||
|
|
||||||
|
MarkNativeAsOptional("Protobuf.ReadInt");
|
||||||
|
MarkNativeAsOptional("Protobuf.ReadFloat");
|
||||||
|
MarkNativeAsOptional("Protobuf.ReadBool");
|
||||||
|
MarkNativeAsOptional("Protobuf.ReadString");
|
||||||
|
MarkNativeAsOptional("Protobuf.ReadColor");
|
||||||
|
MarkNativeAsOptional("Protobuf.ReadAngle");
|
||||||
|
MarkNativeAsOptional("Protobuf.ReadVector");
|
||||||
|
MarkNativeAsOptional("Protobuf.ReadVector2D");
|
||||||
|
MarkNativeAsOptional("Protobuf.GetRepeatedFieldCount");
|
||||||
|
MarkNativeAsOptional("Protobuf.SetInt");
|
||||||
|
MarkNativeAsOptional("Protobuf.SetFloat");
|
||||||
|
MarkNativeAsOptional("Protobuf.SetBool");
|
||||||
|
MarkNativeAsOptional("Protobuf.SetString");
|
||||||
|
MarkNativeAsOptional("Protobuf.SetColor");
|
||||||
|
MarkNativeAsOptional("Protobuf.SetAngle");
|
||||||
|
MarkNativeAsOptional("Protobuf.SetVector");
|
||||||
|
MarkNativeAsOptional("Protobuf.SetVector2D");
|
||||||
|
MarkNativeAsOptional("Protobuf.AddInt");
|
||||||
|
MarkNativeAsOptional("Protobuf.AddFloat");
|
||||||
|
MarkNativeAsOptional("Protobuf.AddBool");
|
||||||
|
MarkNativeAsOptional("Protobuf.AddString");
|
||||||
|
MarkNativeAsOptional("Protobuf.AddColor");
|
||||||
|
MarkNativeAsOptional("Protobuf.AddAngle");
|
||||||
|
MarkNativeAsOptional("Protobuf.AddVector");
|
||||||
|
MarkNativeAsOptional("Protobuf.AddVector2D");
|
||||||
|
MarkNativeAsOptional("Protobuf.RemoveRepeatedFieldValue");
|
||||||
|
MarkNativeAsOptional("Protobuf.ReadMessage");
|
||||||
|
MarkNativeAsOptional("Protobuf.ReadRepeatedMessage");
|
||||||
|
MarkNativeAsOptional("Protobuf.AddMessage");
|
||||||
|
|
||||||
VerifyCoreVersion();
|
VerifyCoreVersion();
|
||||||
}
|
}
|
||||||
|
|
62
env/include/datapack.inc
vendored
62
env/include/datapack.inc
vendored
|
@ -40,7 +40,7 @@
|
||||||
*
|
*
|
||||||
* @return A Handle to the data pack. Must be closed with CloseHandle().
|
* @return A Handle to the data pack. Must be closed with CloseHandle().
|
||||||
*/
|
*/
|
||||||
native Handle:CreateDataPack();
|
native DataPack CreateDataPack();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Packs a normal cell into a data pack.
|
* Packs a normal cell into a data pack.
|
||||||
|
@ -50,7 +50,7 @@ native Handle:CreateDataPack();
|
||||||
* @noreturn
|
* @noreturn
|
||||||
* @error Invalid handle.
|
* @error Invalid handle.
|
||||||
*/
|
*/
|
||||||
native WritePackCell(Handle:pack, any:cell);
|
native void WritePackCell(Handle pack, any cell);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Packs a float into a data pack.
|
* Packs a float into a data pack.
|
||||||
|
@ -60,7 +60,7 @@ native WritePackCell(Handle:pack, any:cell);
|
||||||
* @noreturn
|
* @noreturn
|
||||||
* @error Invalid handle.
|
* @error Invalid handle.
|
||||||
*/
|
*/
|
||||||
native WritePackFloat(Handle:pack, Float:val);
|
native void WritePackFloat(Handle pack, float val);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Packs a string into a data pack.
|
* Packs a string into a data pack.
|
||||||
|
@ -70,7 +70,17 @@ native WritePackFloat(Handle:pack, Float:val);
|
||||||
* @noreturn
|
* @noreturn
|
||||||
* @error Invalid handle.
|
* @error Invalid handle.
|
||||||
*/
|
*/
|
||||||
native WritePackString(Handle:pack, const String:str[]);
|
native void WritePackString(Handle pack, const char[] str);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Packs a function pointer into a data pack.
|
||||||
|
*
|
||||||
|
* @param pack Handle to the data pack.
|
||||||
|
* @param fktptr Function pointer to add.
|
||||||
|
* @noreturn
|
||||||
|
* @error Invalid handle.
|
||||||
|
*/
|
||||||
|
native void WritePackFunction(Handle pack, Function fktptr);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reads a cell from a data pack.
|
* Reads a cell from a data pack.
|
||||||
|
@ -79,7 +89,7 @@ native WritePackString(Handle:pack, const String:str[]);
|
||||||
* @return Cell value.
|
* @return Cell value.
|
||||||
* @error Invalid handle, or bounds error.
|
* @error Invalid handle, or bounds error.
|
||||||
*/
|
*/
|
||||||
native any:ReadPackCell(Handle:pack);
|
native any ReadPackCell(Handle pack);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reads a float from a data pack.
|
* Reads a float from a data pack.
|
||||||
|
@ -88,7 +98,7 @@ native any:ReadPackCell(Handle:pack);
|
||||||
* @return Float value.
|
* @return Float value.
|
||||||
* @error Invalid handle, or bounds error.
|
* @error Invalid handle, or bounds error.
|
||||||
*/
|
*/
|
||||||
native Float:ReadPackFloat(Handle:pack);
|
native float ReadPackFloat(Handle pack);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reads a string from a data pack.
|
* Reads a string from a data pack.
|
||||||
|
@ -99,7 +109,16 @@ native Float:ReadPackFloat(Handle:pack);
|
||||||
* @noreturn
|
* @noreturn
|
||||||
* @error Invalid handle, or bounds error.
|
* @error Invalid handle, or bounds error.
|
||||||
*/
|
*/
|
||||||
native ReadPackString(Handle:pack, String:buffer[], maxlen);
|
native void ReadPackString(Handle pack, char[] buffer, maxlen);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reads a function pointer from a data pack.
|
||||||
|
*
|
||||||
|
* @param pack Handle to the data pack.
|
||||||
|
* @return Function pointer.
|
||||||
|
* @error Invalid handle, or bounds error.
|
||||||
|
*/
|
||||||
|
native Function ReadPackFunction(Handle pack);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Resets the position in a data pack.
|
* Resets the position in a data pack.
|
||||||
|
@ -109,7 +128,7 @@ native ReadPackString(Handle:pack, String:buffer[], maxlen);
|
||||||
* @noreturn
|
* @noreturn
|
||||||
* @error Invalid handle.
|
* @error Invalid handle.
|
||||||
*/
|
*/
|
||||||
native ResetPack(Handle:pack, bool:clear=false);
|
native void ResetPack(Handle pack, bool clear=false);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the read or write position in a data pack.
|
* Returns the read or write position in a data pack.
|
||||||
|
@ -118,7 +137,7 @@ native ResetPack(Handle:pack, bool:clear=false);
|
||||||
* @return Numerical position in the data pack.
|
* @return Numerical position in the data pack.
|
||||||
* @error Invalid handle.
|
* @error Invalid handle.
|
||||||
*/
|
*/
|
||||||
native GetPackPosition(Handle:pack);
|
native int GetPackPosition(Handle pack);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the read/write position in a data pack.
|
* Sets the read/write position in a data pack.
|
||||||
|
@ -128,7 +147,7 @@ native GetPackPosition(Handle:pack);
|
||||||
* @noreturn
|
* @noreturn
|
||||||
* @error Invalid handle, or position is beyond the pack bounds.
|
* @error Invalid handle, or position is beyond the pack bounds.
|
||||||
*/
|
*/
|
||||||
native SetPackPosition(Handle:pack, position);
|
native void SetPackPosition(Handle pack, int position);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns whether or not a specified number of bytes from the data pack
|
* Returns whether or not a specified number of bytes from the data pack
|
||||||
|
@ -139,4 +158,25 @@ native SetPackPosition(Handle:pack, position);
|
||||||
* @return True if can be read, false otherwise.
|
* @return True if can be read, false otherwise.
|
||||||
* @error Invalid handle.
|
* @error Invalid handle.
|
||||||
*/
|
*/
|
||||||
native bool:IsPackReadable(Handle:pack, bytes);
|
native bool IsPackReadable(Handle pack, int bytes);
|
||||||
|
|
||||||
|
methodmap DataPack < Handle
|
||||||
|
{
|
||||||
|
public DataPack() = CreateDataPack;
|
||||||
|
public WriteCell() = WritePackCell;
|
||||||
|
public WriteFloat() = WritePackFloat;
|
||||||
|
public WriteString() = WritePackString;
|
||||||
|
public WriteFunction() = WritePackFunction;
|
||||||
|
public ReadCell() = ReadPackCell;
|
||||||
|
public ReadFloat() = ReadPackFloat;
|
||||||
|
public ReadString() = ReadPackString;
|
||||||
|
public ReadFunction() = ReadPackFunction;
|
||||||
|
public Reset() = ResetPack;
|
||||||
|
public IsReadable() = IsPackReadable;
|
||||||
|
|
||||||
|
property int Position {
|
||||||
|
public get() = GetPackPosition;
|
||||||
|
public set() = SetPackPosition;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
552
env/include/dbi.inc
vendored
552
env/include/dbi.inc
vendored
|
@ -1,7 +1,7 @@
|
||||||
/**
|
/**
|
||||||
* vim: set ts=4 :
|
* vim: set ts=4 sw=4 tw=99 noet :
|
||||||
* =============================================================================
|
* =============================================================================
|
||||||
* SourceMod (C)2004-2008 AlliedModders LLC. All rights reserved.
|
* SourceMod (C)2004-2014 AlliedModders LLC. All rights reserved.
|
||||||
* =============================================================================
|
* =============================================================================
|
||||||
*
|
*
|
||||||
* This file is part of the SourceMod/SourcePawn SDK.
|
* This file is part of the SourceMod/SourcePawn SDK.
|
||||||
|
@ -35,35 +35,6 @@
|
||||||
#endif
|
#endif
|
||||||
#define _dbi_included
|
#define _dbi_included
|
||||||
|
|
||||||
/**
|
|
||||||
* @handle Driver
|
|
||||||
*
|
|
||||||
* Contains information about an SQL driver.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @handle Database
|
|
||||||
*
|
|
||||||
* Contains information about a database connection.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @handle Query
|
|
||||||
*
|
|
||||||
* Contains information about an active query and its
|
|
||||||
* result sets.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @handle Statement : Query
|
|
||||||
*
|
|
||||||
* Extends a Query Handle and can be used as a Query Handle.
|
|
||||||
* Statement Handles are for prepared queries and contain
|
|
||||||
* their own function for binding parameters. Statement
|
|
||||||
* Handles can be used instead of database Handles in a few
|
|
||||||
* select functions.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Describes a database field fetch status.
|
* Describes a database field fetch status.
|
||||||
*/
|
*/
|
||||||
|
@ -95,6 +66,345 @@ enum DBPriority
|
||||||
DBPrio_Low = 2, /**< Low priority. */
|
DBPrio_Low = 2, /**< Low priority. */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// A Driver represents a database backend, currently MySQL or SQLite.
|
||||||
|
//
|
||||||
|
// Driver handles cannot be closed.
|
||||||
|
methodmap DBDriver < Handle
|
||||||
|
{
|
||||||
|
// Finds the driver associated with a name.
|
||||||
|
//
|
||||||
|
// Supported driver strings:
|
||||||
|
// mysql
|
||||||
|
// sqlite
|
||||||
|
//
|
||||||
|
// @param name Driver identification string, or an empty string
|
||||||
|
// to return the default driver.
|
||||||
|
// @return Driver handle, or null on failure.
|
||||||
|
public static native DBDriver Find(const char[] name = "");
|
||||||
|
|
||||||
|
// Retrieves a driver's identification string.
|
||||||
|
//
|
||||||
|
// Example: "mysql", "sqlite"
|
||||||
|
//
|
||||||
|
// @param ident Identification string buffer.
|
||||||
|
// @param maxlength Maximum length of the buffer.
|
||||||
|
public native void GetIdentifier(char[] ident, int maxlength);
|
||||||
|
|
||||||
|
// Retrieves a driver's product string.
|
||||||
|
//
|
||||||
|
// Example: "MySQL", "SQLite"
|
||||||
|
//
|
||||||
|
// @param product Product string buffer.
|
||||||
|
// @param maxlength Maximum length of the buffer.
|
||||||
|
public native void GetProduct(char[] product, int maxlength);
|
||||||
|
};
|
||||||
|
|
||||||
|
// Represents a set of results returned from executing a query.
|
||||||
|
methodmap DBResultSet < Handle
|
||||||
|
{
|
||||||
|
// Advances to the next set of results.
|
||||||
|
//
|
||||||
|
// In some SQL implementations, multiple result sets can exist on one query.
|
||||||
|
// This is possible in MySQL with simple queries when executing a CALL
|
||||||
|
// query. If this is the case, all result sets must be processed before
|
||||||
|
// another query is made.
|
||||||
|
//
|
||||||
|
// @return True if there was another result set, false otherwise.
|
||||||
|
public native bool FetchMoreResults();
|
||||||
|
|
||||||
|
// Returns whether or not a result set exists. This will
|
||||||
|
// return true even if 0 results were returned, but false
|
||||||
|
// on queries like UPDATE, INSERT, or DELETE.
|
||||||
|
property bool HasResults {
|
||||||
|
public native get();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Retrieves the number of rows in the last result set.
|
||||||
|
//
|
||||||
|
// @param query A query (or statement) Handle.
|
||||||
|
// @return Number of rows in the current result set.
|
||||||
|
property int RowCount {
|
||||||
|
public native get();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Retrieves the number of fields in the last result set.
|
||||||
|
property int FieldCount {
|
||||||
|
public native get();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Returns the number of affected rows from the query that generated this
|
||||||
|
// result set.
|
||||||
|
property int AffectedRows {
|
||||||
|
public native get();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Returns the insert id from the query that generated this result set.
|
||||||
|
property int InsertId {
|
||||||
|
public native get();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Retrieves the name of a field by index.
|
||||||
|
//
|
||||||
|
// @param field Field number (starting from 0).
|
||||||
|
// @param name Name buffer.
|
||||||
|
// @param maxlength Maximum length of the name buffer.
|
||||||
|
// @error Invalid field index, or no current result set.
|
||||||
|
public native void FieldNumToName(int field, char[] name, int maxlength);
|
||||||
|
|
||||||
|
// Retrieves a field index by name.
|
||||||
|
//
|
||||||
|
// @param name Name of the field (case sensitive).
|
||||||
|
// @param field Variable to store field index in.
|
||||||
|
// @return True if found, false if not found.
|
||||||
|
// @error No current result set.
|
||||||
|
public native bool FieldNameToNum(const char[] name, int &field);
|
||||||
|
|
||||||
|
// Fetches a row from the current result set. This must be
|
||||||
|
// successfully called before any results are fetched.
|
||||||
|
//
|
||||||
|
// If this function fails, _MoreResults can be used to
|
||||||
|
// tell if there was an error or the result set is finished.
|
||||||
|
//
|
||||||
|
// @return True if a row was fetched, false otherwise.
|
||||||
|
public native bool FetchRow();
|
||||||
|
|
||||||
|
// Returns if there are more rows.
|
||||||
|
//
|
||||||
|
// @return True if there are more rows, false otherwise.
|
||||||
|
property bool MoreRows {
|
||||||
|
public native get();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Rewinds a result set back to the first result.
|
||||||
|
//
|
||||||
|
// @return True on success, false otherwise.
|
||||||
|
// @error No current result set.
|
||||||
|
public native bool Rewind();
|
||||||
|
|
||||||
|
// Fetches a string from a field in the current row of a result set.
|
||||||
|
// If the result is NULL, an empty string will be returned. A NULL
|
||||||
|
// check can be done with the result parameter, or SQL_IsFieldNull().
|
||||||
|
//
|
||||||
|
// @param field The field index (starting from 0).
|
||||||
|
// @param buffer String buffer.
|
||||||
|
// @param maxlength Maximum size of the string buffer.
|
||||||
|
// @param result Optional variable to store the status of the return value.
|
||||||
|
// @return Number of bytes written.
|
||||||
|
// @error Invalid field index, invalid type conversion requested
|
||||||
|
// from the database, or no current result set.
|
||||||
|
public native int FetchString(int field, char[] buffer, int maxlength,
|
||||||
|
DBResult &result=DBVal_Error);
|
||||||
|
|
||||||
|
// Fetches a float from a field in the current row of a result set.
|
||||||
|
// If the result is NULL, a value of 0.0 will be returned. A NULL
|
||||||
|
// check can be done with the result parameter, or SQL_IsFieldNull().
|
||||||
|
//
|
||||||
|
// @param field The field index (starting from 0).
|
||||||
|
// @param result Optional variable to store the status of the return value.
|
||||||
|
// @return A float value.
|
||||||
|
// @error Invalid field index, invalid type conversion requested
|
||||||
|
// from the database, or no current result set.
|
||||||
|
public native float FetchFloat(int field, DBResult &result=DBVal_Error);
|
||||||
|
|
||||||
|
// Fetches an integer from a field in the current row of a result set.
|
||||||
|
// If the result is NULL, a value of 0 will be returned. A NULL
|
||||||
|
// check can be done with the result parameter, or SQL_IsFieldNull().
|
||||||
|
//
|
||||||
|
// @param field The field index (starting from 0).
|
||||||
|
// @param result Optional variable to store the status of the return value.
|
||||||
|
// @return An integer value.
|
||||||
|
// @error Invalid field index, invalid type conversion requested
|
||||||
|
// from the database, or no current result set.
|
||||||
|
public native int FetchInt(int field, DBResult &result=DBVal_Error);
|
||||||
|
|
||||||
|
// Returns whether a field's data in the current row of a result set is
|
||||||
|
// NULL or not. NULL is an SQL type which means "no data."
|
||||||
|
//
|
||||||
|
// @param field The field index (starting from 0).
|
||||||
|
// @return True if data is NULL, false otherwise.
|
||||||
|
// @error Invalid field index, or no current result set.
|
||||||
|
public native bool IsFieldNull(Handle query, int field);
|
||||||
|
|
||||||
|
// Returns the length of a field's data in the current row of a result
|
||||||
|
// set. This only needs to be called for strings to determine how many
|
||||||
|
// bytes to use. Note that the return value does not include the null
|
||||||
|
// terminator.
|
||||||
|
//
|
||||||
|
// @param field The field index (starting from 0).
|
||||||
|
// @return Number of bytes for the field's data size.
|
||||||
|
// @error Invalid field index or no current result set.
|
||||||
|
public native int FetchSize(int field);
|
||||||
|
};
|
||||||
|
|
||||||
|
// Callback for a successful transaction.
|
||||||
|
//
|
||||||
|
// @param db Database handle.
|
||||||
|
// @param data Data value passed to SQL_ExecuteTransaction().
|
||||||
|
// @param numQueries Number of queries executed in the transaction.
|
||||||
|
// @param results An array of Query handle results, one for each of numQueries. They are closed automatically.
|
||||||
|
// @param queryData An array of each data value passed to SQL_AddQuery().
|
||||||
|
typedef SQLTxnSuccess = function void (Database db, any data, int numQueries, Handle[] results, any[] queryData);
|
||||||
|
|
||||||
|
// Callback for a failed transaction.
|
||||||
|
//
|
||||||
|
// @param db Database handle.
|
||||||
|
// @param data Data value passed to SQL_ExecuteTransaction().
|
||||||
|
// @param numQueries Number of queries executed in the transaction.
|
||||||
|
// @param error Error message.
|
||||||
|
// @param failIndex Index of the query that failed, or -1 if something else.
|
||||||
|
// @param queryData An array of each data value passed to SQL_AddQuery().
|
||||||
|
typedef SQLTxnFailure = function void (Database db, any data, int numQueries, const char[] error, int failIndex, any[] queryData);
|
||||||
|
|
||||||
|
// A Transaction is a collection of SQL statements that must all execute
|
||||||
|
// successfully or not at all.
|
||||||
|
methodmap Transaction < Handle
|
||||||
|
{
|
||||||
|
// Create a new transaction.
|
||||||
|
public native Transaction();
|
||||||
|
|
||||||
|
// Adds a query to the transaction.
|
||||||
|
//
|
||||||
|
// @param query Query string.
|
||||||
|
// @param data Extra data value to pass to the final callback.
|
||||||
|
// @return The index of the query in the transaction's query list.
|
||||||
|
public native int AddQuery(const char[] query, any data=0);
|
||||||
|
};
|
||||||
|
|
||||||
|
// A DBStatement is a pre-compiled SQL query that may be executed multiple
|
||||||
|
// times with different parameters. A DBStatement holds a reference to the
|
||||||
|
// Database that prepared it.
|
||||||
|
methodmap DBStatement < Handle
|
||||||
|
{
|
||||||
|
// Binds a parameter in a prepared statement to a given integer value.
|
||||||
|
//
|
||||||
|
// @param param The parameter index (starting from 0).
|
||||||
|
// @param number The number to bind.
|
||||||
|
// @param signed True to bind the number as signed, false to
|
||||||
|
// bind it as unsigned.
|
||||||
|
// @error Invalid parameter index, or SQL error.
|
||||||
|
public native void BindInt(int param, int number, bool signed=true);
|
||||||
|
|
||||||
|
// Binds a parameter in a prepared statement to a given float value.
|
||||||
|
//
|
||||||
|
// @param param The parameter index (starting from 0).
|
||||||
|
// @param value The float number to bind.
|
||||||
|
// @error Invalid parameter index, or SQL error.
|
||||||
|
public native void BindFloat(int param, float value);
|
||||||
|
|
||||||
|
// Binds a parameter in a prepared statement to a given string value.
|
||||||
|
//
|
||||||
|
// @param param The parameter index (starting from 0).
|
||||||
|
// @param value The string to bind.
|
||||||
|
// @param copy Whether or not SourceMod should copy the value
|
||||||
|
// locally if necessary. If the string contents
|
||||||
|
// won't change before calling SQL_Execute(), this
|
||||||
|
// can be set to false for optimization.
|
||||||
|
// @error Invalid parameter index, or SQL error.
|
||||||
|
public native void BindString(int param, const char[] value, bool copy);
|
||||||
|
};
|
||||||
|
|
||||||
|
// Callback for receiving asynchronous database connections.
|
||||||
|
//
|
||||||
|
// @param db Handle to the database connection.
|
||||||
|
// @param error Error string if there was an error. The error could be
|
||||||
|
// empty even if an error condition exists, so it is important
|
||||||
|
// to check the actual Handle value instead.
|
||||||
|
// @param data Data passed in via the original threaded invocation.
|
||||||
|
typedef SQLConnectCallback = function void (Database db, const char[] error, any data);
|
||||||
|
|
||||||
|
// Callback for receiving asynchronous database query results.
|
||||||
|
//
|
||||||
|
// @param db Cloned handle to the database connection.
|
||||||
|
// @param results Result object, or null on failure.
|
||||||
|
// @param error Error string if there was an error. The error could be
|
||||||
|
// empty even if an error condition exists, so it is important
|
||||||
|
// to check the actual results value instead.
|
||||||
|
// @param data Data passed in via the original threaded invocation.
|
||||||
|
typedef SQLQueryCallback = function void (Database db, DBResultSet results, const char[] error, any data);
|
||||||
|
|
||||||
|
// A Database represents a live connection to a database, either over the
|
||||||
|
// wire, through a unix domain socket, or over an open file.
|
||||||
|
methodmap Database < Handle
|
||||||
|
{
|
||||||
|
// Connects to a database asynchronously, so the game thread is not blocked.
|
||||||
|
//
|
||||||
|
// @param callback Callback. If no driver was found, the owner is null.
|
||||||
|
// @param name Database configuration name.
|
||||||
|
// @param data Extra data value to pass to the callback.
|
||||||
|
public static native void Connect(SQLConnectCallback callback, const char[] name="default", any data=0);
|
||||||
|
|
||||||
|
// Returns the driver for this database connection.
|
||||||
|
property DBDriver Driver {
|
||||||
|
public native get();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Sets the character set of the connection.
|
||||||
|
// Like SET NAMES .. in mysql, but stays after connection problems.
|
||||||
|
//
|
||||||
|
// Example: "utf8", "latin1"
|
||||||
|
//
|
||||||
|
// @param characterset The character set string to change to.
|
||||||
|
// @return True, if character set was changed, false otherwise.
|
||||||
|
public native bool SetCharset(const char[] charset);
|
||||||
|
|
||||||
|
// Escapes a database string for literal insertion. This is not needed
|
||||||
|
// for binding strings in prepared statements.
|
||||||
|
//
|
||||||
|
// Generally, database strings are inserted into queries enclosed in
|
||||||
|
// single quotes ('). If user input has a single quote in it, the
|
||||||
|
// quote needs to be escaped. This function ensures that any unsafe
|
||||||
|
// characters are safely escaped according to the database engine and
|
||||||
|
// the database's character set.
|
||||||
|
//
|
||||||
|
// NOTE: SourceMod only guarantees properly escaped strings when the query
|
||||||
|
// encloses the string in ''. While drivers tend to allow " instead, the string
|
||||||
|
// may be not be escaped (for example, on SQLite)!
|
||||||
|
//
|
||||||
|
// @param string String to quote.
|
||||||
|
// @param buffer Buffer to store quoted string in.
|
||||||
|
// @param maxlength Maximum length of the buffer.
|
||||||
|
// @param written Optionally returns the number of bytes written.
|
||||||
|
// @return True on success, false if buffer is not big enough.
|
||||||
|
// The buffer must be at least 2*strlen(string)+1.
|
||||||
|
public native bool Escape(const char[] string, char[] buffer, int maxlength, int &written=0);
|
||||||
|
|
||||||
|
// Returns whether a database is the same connection as another database.
|
||||||
|
public native bool IsSameConnection(Database other);
|
||||||
|
|
||||||
|
// Executes a query via a thread. The result handle is passed through the
|
||||||
|
// callback.
|
||||||
|
//
|
||||||
|
// The database handle returned through the callback is always a new Handle,
|
||||||
|
// and if necessary, IsSameConnection() should be used to test against other
|
||||||
|
// conenctions.
|
||||||
|
//
|
||||||
|
// The result handle returned through the callback is temporary and destroyed
|
||||||
|
// at the end of the callback.
|
||||||
|
//
|
||||||
|
// @param callback Callback.
|
||||||
|
// @param query Query string.
|
||||||
|
// @param data Extra data value to pass to the callback.
|
||||||
|
// @param prio Priority queue to use.
|
||||||
|
public native void Query(SQLQueryCallback callback, const char[] query,
|
||||||
|
any data = 0,
|
||||||
|
DBPriority prio = DBPrio_Normal);
|
||||||
|
|
||||||
|
// Sends a transaction to the database thread. The transaction handle is
|
||||||
|
// automatically closed. When the transaction completes, the optional
|
||||||
|
// callback is invoked.
|
||||||
|
//
|
||||||
|
// @param txn A transaction handle.
|
||||||
|
// @param onSuccess An optional callback to receive a successful transaction.
|
||||||
|
// @param onError An optional callback to receive an error message.
|
||||||
|
// @param data An optional value to pass to callbacks.
|
||||||
|
// @param prio Priority queue to use.
|
||||||
|
public native void Execute(Transaction txn,
|
||||||
|
SQLTxnSuccess:onSuccess = INVALID_FUNCTION,
|
||||||
|
SQLTxnFailure:onError = INVALID_FUNCTION,
|
||||||
|
any data = 0,
|
||||||
|
DBPriority priority = DBPrio_Normal);
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates an SQL connection from a named configuration.
|
* Creates an SQL connection from a named configuration.
|
||||||
*
|
*
|
||||||
|
@ -105,7 +415,7 @@ enum DBPriority
|
||||||
* @param maxlength Maximum length of the error buffer.
|
* @param maxlength Maximum length of the error buffer.
|
||||||
* @return A database connection Handle, or INVALID_HANDLE on failure.
|
* @return A database connection Handle, or INVALID_HANDLE on failure.
|
||||||
*/
|
*/
|
||||||
native Handle:SQL_Connect(const String:confname[], bool:persistent, String:error[], maxlength);
|
native Database SQL_Connect(const char[] confname, bool persistent, char[] error, int maxlength);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a default SQL connection.
|
* Creates a default SQL connection.
|
||||||
|
@ -117,7 +427,7 @@ native Handle:SQL_Connect(const String:confname[], bool:persistent, String:error
|
||||||
* @return A database connection Handle, or INVALID_HANDLE on failure.
|
* @return A database connection Handle, or INVALID_HANDLE on failure.
|
||||||
* On failure the error buffer will be filled with a message.
|
* On failure the error buffer will be filled with a message.
|
||||||
*/
|
*/
|
||||||
stock Handle:SQL_DefConnect(String:error[], maxlength, bool:persistent=true)
|
stock Database SQL_DefConnect(char[] error, int maxlength, bool persistent=true)
|
||||||
{
|
{
|
||||||
return SQL_Connect("default", persistent, error, maxlength);
|
return SQL_Connect("default", persistent, error, maxlength);
|
||||||
}
|
}
|
||||||
|
@ -143,10 +453,10 @@ stock Handle:SQL_DefConnect(String:error[], maxlength, bool:persistent=true)
|
||||||
* On failure the error buffer will be filled with a message.
|
* On failure the error buffer will be filled with a message.
|
||||||
* @error Invalid KeyValues handle.
|
* @error Invalid KeyValues handle.
|
||||||
*/
|
*/
|
||||||
native Handle:SQL_ConnectCustom(Handle:keyvalues,
|
native Database SQL_ConnectCustom(Handle keyvalues,
|
||||||
String:error[],
|
char[] error,
|
||||||
maxlength,
|
maxlength,
|
||||||
bool:persistent);
|
bool persistent);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Grabs a handle to an SQLite database, creating one if it does not exist.
|
* Grabs a handle to an SQLite database, creating one if it does not exist.
|
||||||
|
@ -163,11 +473,11 @@ native Handle:SQL_ConnectCustom(Handle:keyvalues,
|
||||||
* @return A database connection Handle, or INVALID_HANDLE on failure.
|
* @return A database connection Handle, or INVALID_HANDLE on failure.
|
||||||
* On failure the error buffer will be filled with a message.
|
* On failure the error buffer will be filled with a message.
|
||||||
*/
|
*/
|
||||||
stock Handle:SQLite_UseDatabase(const String:database[],
|
stock Database SQLite_UseDatabase(const char[] database,
|
||||||
String:error[],
|
char[] error,
|
||||||
maxlength)
|
maxlength)
|
||||||
{
|
{
|
||||||
new Handle:kv, Handle:db;
|
Handle kv, db;
|
||||||
|
|
||||||
kv = CreateKeyValues("");
|
kv = CreateKeyValues("");
|
||||||
KvSetString(kv, "driver", "sqlite");
|
KvSetString(kv, "driver", "sqlite");
|
||||||
|
@ -184,14 +494,14 @@ stock Handle:SQLite_UseDatabase(const String:database[],
|
||||||
* This function is deprecated. Use SQL_ConnectCustom or SQLite_UseDatabase instead.
|
* This function is deprecated. Use SQL_ConnectCustom or SQLite_UseDatabase instead.
|
||||||
*/
|
*/
|
||||||
#pragma deprecated Use SQL_ConnectCustom instead.
|
#pragma deprecated Use SQL_ConnectCustom instead.
|
||||||
native Handle:SQL_ConnectEx(Handle:driver,
|
native Handle SQL_ConnectEx(Handle driver,
|
||||||
const String:host[],
|
const String:host[],
|
||||||
const String:user[],
|
const String:user[],
|
||||||
const String:pass[],
|
const String:pass[],
|
||||||
const String:database[],
|
const String:database[],
|
||||||
String:error[],
|
char[] error,
|
||||||
maxlength,
|
maxlength,
|
||||||
bool:persistent=true,
|
bool persistent=true,
|
||||||
port=0,
|
port=0,
|
||||||
maxTimeout=0);
|
maxTimeout=0);
|
||||||
|
|
||||||
|
@ -201,7 +511,7 @@ native Handle:SQL_ConnectEx(Handle:driver,
|
||||||
* @param name Configuration name.
|
* @param name Configuration name.
|
||||||
* @return True if it exists, false otherwise.
|
* @return True if it exists, false otherwise.
|
||||||
*/
|
*/
|
||||||
native bool:SQL_CheckConfig(const String:name[]);
|
native bool SQL_CheckConfig(const char[] name);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a driver Handle from a name string.
|
* Returns a driver Handle from a name string.
|
||||||
|
@ -213,7 +523,7 @@ native bool:SQL_CheckConfig(const String:name[]);
|
||||||
* string to return the default driver.
|
* string to return the default driver.
|
||||||
* @return Driver Handle, or INVALID_HANDLE on failure.
|
* @return Driver Handle, or INVALID_HANDLE on failure.
|
||||||
*/
|
*/
|
||||||
native Handle:SQL_GetDriver(const String:name[]="");
|
native Handle SQL_GetDriver(const char[] name="");
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reads the driver of an opened database.
|
* Reads the driver of an opened database.
|
||||||
|
@ -223,7 +533,7 @@ native Handle:SQL_GetDriver(const String:name[]="");
|
||||||
* @param ident_length Maximum length of the buffer.
|
* @param ident_length Maximum length of the buffer.
|
||||||
* @return Driver Handle.
|
* @return Driver Handle.
|
||||||
*/
|
*/
|
||||||
native Handle:SQL_ReadDriver(Handle:database, String:ident[]="", ident_length=0);
|
native Handle SQL_ReadDriver(Handle database, char[] ident="", ident_length=0);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieves a driver's identification string.
|
* Retrieves a driver's identification string.
|
||||||
|
@ -236,7 +546,7 @@ native Handle:SQL_ReadDriver(Handle:database, String:ident[]="", ident_length=0)
|
||||||
* @noreturn
|
* @noreturn
|
||||||
* @error Invalid Handle other than INVALID_HANDLE.
|
* @error Invalid Handle other than INVALID_HANDLE.
|
||||||
*/
|
*/
|
||||||
native SQL_GetDriverIdent(Handle:driver, String:ident[], maxlength);
|
native void SQL_GetDriverIdent(Handle driver, char[] ident, int maxlength);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieves a driver's product string.
|
* Retrieves a driver's product string.
|
||||||
|
@ -249,7 +559,7 @@ native SQL_GetDriverIdent(Handle:driver, String:ident[], maxlength);
|
||||||
* @noreturn
|
* @noreturn
|
||||||
* @error Invalid Handle other than INVALID_HANDLE.
|
* @error Invalid Handle other than INVALID_HANDLE.
|
||||||
*/
|
*/
|
||||||
native SQL_GetDriverProduct(Handle:driver, String:product[], maxlength);
|
native void SQL_GetDriverProduct(Handle driver, char[] product, int maxlength);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the character set of the current connection.
|
* Sets the character set of the current connection.
|
||||||
|
@ -261,7 +571,7 @@ native SQL_GetDriverProduct(Handle:driver, String:product[], maxlength);
|
||||||
* @param characterset The character set string to change to.
|
* @param characterset The character set string to change to.
|
||||||
* @return True, if character set was changed, false otherwise.
|
* @return True, if character set was changed, false otherwise.
|
||||||
*/
|
*/
|
||||||
native bool:SQL_SetCharset(Handle:database, const String:charset[]);
|
native bool SQL_SetCharset(Handle database, const char[] charset);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the number of affected rows from the last query.
|
* Returns the number of affected rows from the last query.
|
||||||
|
@ -270,7 +580,7 @@ native bool:SQL_SetCharset(Handle:database, const String:charset[]);
|
||||||
* @return Number of rows affected by the last query.
|
* @return Number of rows affected by the last query.
|
||||||
* @error Invalid database or statement Handle.
|
* @error Invalid database or statement Handle.
|
||||||
*/
|
*/
|
||||||
native SQL_GetAffectedRows(Handle:hndl);
|
native int SQL_GetAffectedRows(Handle hndl);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the last query's insertion id.
|
* Returns the last query's insertion id.
|
||||||
|
@ -279,7 +589,7 @@ native SQL_GetAffectedRows(Handle:hndl);
|
||||||
* @return Last query's insertion id.
|
* @return Last query's insertion id.
|
||||||
* @error Invalid database, query, or statement Handle.
|
* @error Invalid database, query, or statement Handle.
|
||||||
*/
|
*/
|
||||||
native SQL_GetInsertId(Handle:hndl);
|
native int SQL_GetInsertId(Handle hndl);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the error reported by the last query.
|
* Returns the error reported by the last query.
|
||||||
|
@ -290,7 +600,7 @@ native SQL_GetInsertId(Handle:hndl);
|
||||||
* @return True if there was an error, false otherwise.
|
* @return True if there was an error, false otherwise.
|
||||||
* @error Invalid database, query, or statement Handle.
|
* @error Invalid database, query, or statement Handle.
|
||||||
*/
|
*/
|
||||||
native bool:SQL_GetError(Handle:hndl, String:error[], maxlength);
|
native bool SQL_GetError(Handle hndl, char[] error, int maxlength);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Escapes a database string for literal insertion. This is not needed
|
* Escapes a database string for literal insertion. This is not needed
|
||||||
|
@ -315,19 +625,19 @@ native bool:SQL_GetError(Handle:hndl, String:error[], maxlength);
|
||||||
* The buffer must be at least 2*strlen(string)+1.
|
* The buffer must be at least 2*strlen(string)+1.
|
||||||
* @error Invalid database or statement Handle.
|
* @error Invalid database or statement Handle.
|
||||||
*/
|
*/
|
||||||
native bool:SQL_EscapeString(Handle:database,
|
native bool SQL_EscapeString(Handle database,
|
||||||
const String:string[],
|
const char[] string,
|
||||||
String:buffer[],
|
char[] buffer,
|
||||||
maxlength,
|
int maxlength,
|
||||||
&written=0);
|
int &written=0);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is a backwards compatibility stock. You should use SQL_EscapeString()
|
* This is a backwards compatibility stock. You should use SQL_EscapeString()
|
||||||
* instead, as this function will probably be deprecated in SourceMod 1.1.
|
* instead, as this function will probably be deprecated in SourceMod 1.1.
|
||||||
*/
|
*/
|
||||||
stock bool:SQL_QuoteString(Handle:database,
|
stock bool SQL_QuoteString(Handle database,
|
||||||
const String:string[],
|
const char[] string,
|
||||||
String:buffer[],
|
char[] buffer,
|
||||||
maxlength,
|
maxlength,
|
||||||
&written=0)
|
&written=0)
|
||||||
{
|
{
|
||||||
|
@ -346,7 +656,7 @@ stock bool:SQL_QuoteString(Handle:database,
|
||||||
* SQL_GetError to find the last error.
|
* SQL_GetError to find the last error.
|
||||||
* @error Invalid database Handle.
|
* @error Invalid database Handle.
|
||||||
*/
|
*/
|
||||||
native bool:SQL_FastQuery(Handle:database, const String:query[], len=-1);
|
native bool SQL_FastQuery(Handle database, const char[] query, int len=-1);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Executes a simple query and returns a new query Handle for
|
* Executes a simple query and returns a new query Handle for
|
||||||
|
@ -361,7 +671,7 @@ native bool:SQL_FastQuery(Handle:database, const String:query[], len=-1);
|
||||||
* otherwise. The Handle must be freed with CloseHandle().
|
* otherwise. The Handle must be freed with CloseHandle().
|
||||||
* @error Invalid database Handle.
|
* @error Invalid database Handle.
|
||||||
*/
|
*/
|
||||||
native Handle:SQL_Query(Handle:database, const String:query[], len=-1);
|
native DBResultSet SQL_Query(Handle database, const char[] query, int len=-1);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new prepared statement query. Prepared statements can
|
* Creates a new prepared statement query. Prepared statements can
|
||||||
|
@ -379,7 +689,7 @@ native Handle:SQL_Query(Handle:database, const String:query[], len=-1);
|
||||||
* otherwise. The Handle must be freed with CloseHandle().
|
* otherwise. The Handle must be freed with CloseHandle().
|
||||||
* @error Invalid database Handle.
|
* @error Invalid database Handle.
|
||||||
*/
|
*/
|
||||||
native Handle:SQL_PrepareQuery(Handle:database, const String:query[], String:error[], maxlength);
|
native DBStatement SQL_PrepareQuery(Handle database, const char[] query, char[] error, int maxlength);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Advances to the next set of results.
|
* Advances to the next set of results.
|
||||||
|
@ -393,7 +703,7 @@ native Handle:SQL_PrepareQuery(Handle:database, const String:query[], String:err
|
||||||
* @return True if there was another result set, false otherwise.
|
* @return True if there was another result set, false otherwise.
|
||||||
* @error Invalid query Handle.
|
* @error Invalid query Handle.
|
||||||
*/
|
*/
|
||||||
native bool:SQL_FetchMoreResults(Handle:query);
|
native bool SQL_FetchMoreResults(Handle query);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns whether or not a result set exists. This will
|
* Returns whether or not a result set exists. This will
|
||||||
|
@ -404,7 +714,7 @@ native bool:SQL_FetchMoreResults(Handle:query);
|
||||||
* @return True if there is a result set, false otherwise.
|
* @return True if there is a result set, false otherwise.
|
||||||
* @error Invalid query Handle.
|
* @error Invalid query Handle.
|
||||||
*/
|
*/
|
||||||
native bool:SQL_HasResultSet(Handle:query);
|
native bool SQL_HasResultSet(Handle query);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieves the number of rows in the last result set.
|
* Retrieves the number of rows in the last result set.
|
||||||
|
@ -413,7 +723,7 @@ native bool:SQL_HasResultSet(Handle:query);
|
||||||
* @return Number of rows in the current result set.
|
* @return Number of rows in the current result set.
|
||||||
* @error Invalid query Handle.
|
* @error Invalid query Handle.
|
||||||
*/
|
*/
|
||||||
native SQL_GetRowCount(Handle:query);
|
native int SQL_GetRowCount(Handle query);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieves the number of fields in the last result set.
|
* Retrieves the number of fields in the last result set.
|
||||||
|
@ -422,7 +732,7 @@ native SQL_GetRowCount(Handle:query);
|
||||||
* @return Number of fields in the current result set.
|
* @return Number of fields in the current result set.
|
||||||
* @error Invalid query Handle.
|
* @error Invalid query Handle.
|
||||||
*/
|
*/
|
||||||
native SQL_GetFieldCount(Handle:query);
|
native int SQL_GetFieldCount(Handle query);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieves the name of a field by index.
|
* Retrieves the name of a field by index.
|
||||||
|
@ -431,11 +741,10 @@ native SQL_GetFieldCount(Handle:query);
|
||||||
* @param field Field number (starting from 0).
|
* @param field Field number (starting from 0).
|
||||||
* @param name Name buffer.
|
* @param name Name buffer.
|
||||||
* @param maxlength Maximum length of the name buffer.
|
* @param maxlength Maximum length of the name buffer.
|
||||||
* @noreturn
|
|
||||||
* @error Invalid query Handle, invalid field index, or
|
* @error Invalid query Handle, invalid field index, or
|
||||||
* no current result set.
|
* no current result set.
|
||||||
*/
|
*/
|
||||||
native SQL_FieldNumToName(Handle:query, field, String:name[], maxlength);
|
native void SQL_FieldNumToName(Handle query, int field, String:name[], int maxlength);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieves a field index by name.
|
* Retrieves a field index by name.
|
||||||
|
@ -446,7 +755,7 @@ native SQL_FieldNumToName(Handle:query, field, String:name[], maxlength);
|
||||||
* @return True if found, false if not found.
|
* @return True if found, false if not found.
|
||||||
* @error Invalid query Handle or no current result set.
|
* @error Invalid query Handle or no current result set.
|
||||||
*/
|
*/
|
||||||
native bool:SQL_FieldNameToNum(Handle:query, const String:name[], &field);
|
native bool SQL_FieldNameToNum(Handle query, const char[] name, &field);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fetches a row from the current result set. This must be
|
* Fetches a row from the current result set. This must be
|
||||||
|
@ -459,7 +768,7 @@ native bool:SQL_FieldNameToNum(Handle:query, const String:name[], &field);
|
||||||
* @return True if a row was fetched, false otherwise.
|
* @return True if a row was fetched, false otherwise.
|
||||||
* @error Invalid query Handle.
|
* @error Invalid query Handle.
|
||||||
*/
|
*/
|
||||||
native bool:SQL_FetchRow(Handle:query);
|
native bool SQL_FetchRow(Handle query);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns if there are more rows.
|
* Returns if there are more rows.
|
||||||
|
@ -468,7 +777,7 @@ native bool:SQL_FetchRow(Handle:query);
|
||||||
* @return True if there are more rows, false otherwise.
|
* @return True if there are more rows, false otherwise.
|
||||||
* @error Invalid query Handle.
|
* @error Invalid query Handle.
|
||||||
*/
|
*/
|
||||||
native bool:SQL_MoreRows(Handle:query);
|
native bool SQL_MoreRows(Handle query);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Rewinds a result set back to the first result.
|
* Rewinds a result set back to the first result.
|
||||||
|
@ -477,7 +786,7 @@ native bool:SQL_MoreRows(Handle:query);
|
||||||
* @return True on success, false otherwise.
|
* @return True on success, false otherwise.
|
||||||
* @error Invalid query Handle or no current result set.
|
* @error Invalid query Handle or no current result set.
|
||||||
*/
|
*/
|
||||||
native bool:SQL_Rewind(Handle:query);
|
native bool SQL_Rewind(Handle query);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fetches a string from a field in the current row of a result set.
|
* Fetches a string from a field in the current row of a result set.
|
||||||
|
@ -494,7 +803,7 @@ native bool:SQL_Rewind(Handle:query);
|
||||||
* type conversion requested from the database,
|
* type conversion requested from the database,
|
||||||
* or no current result set.
|
* or no current result set.
|
||||||
*/
|
*/
|
||||||
native SQL_FetchString(Handle:query, field, String:buffer[], maxlength, &DBResult:result=DBVal_Error);
|
native int SQL_FetchString(Handle query, int field, char[] buffer, int maxlength, DBResult &result=DBVal_Error);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fetches a float from a field in the current row of a result set.
|
* Fetches a float from a field in the current row of a result set.
|
||||||
|
@ -509,7 +818,7 @@ native SQL_FetchString(Handle:query, field, String:buffer[], maxlength, &DBResul
|
||||||
* type conversion requested from the database,
|
* type conversion requested from the database,
|
||||||
* or no current result set.
|
* or no current result set.
|
||||||
*/
|
*/
|
||||||
native Float:SQL_FetchFloat(Handle:query, field, &DBResult:result=DBVal_Error);
|
native float SQL_FetchFloat(Handle query, int field, DBResult &result=DBVal_Error);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fetches an integer from a field in the current row of a result set.
|
* Fetches an integer from a field in the current row of a result set.
|
||||||
|
@ -524,7 +833,7 @@ native Float:SQL_FetchFloat(Handle:query, field, &DBResult:result=DBVal_Error);
|
||||||
* type conversion requested from the database,
|
* type conversion requested from the database,
|
||||||
* or no current result set.
|
* or no current result set.
|
||||||
*/
|
*/
|
||||||
native SQL_FetchInt(Handle:query, field, &DBResult:result=DBVal_Error);
|
native int SQL_FetchInt(Handle query, int field, DBResult &result=DBVal_Error);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns whether a field's data in the current row of a result set is
|
* Returns whether a field's data in the current row of a result set is
|
||||||
|
@ -536,7 +845,7 @@ native SQL_FetchInt(Handle:query, field, &DBResult:result=DBVal_Error);
|
||||||
* @error Invalid query Handle or field index, or no
|
* @error Invalid query Handle or field index, or no
|
||||||
* current result set.
|
* current result set.
|
||||||
*/
|
*/
|
||||||
native bool:SQL_IsFieldNull(Handle:query, field);
|
native bool SQL_IsFieldNull(Handle query, int field);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the length of a field's data in the current row of a result
|
* Returns the length of a field's data in the current row of a result
|
||||||
|
@ -550,7 +859,7 @@ native bool:SQL_IsFieldNull(Handle:query, field);
|
||||||
* @error Invalid query Handle or field index or no
|
* @error Invalid query Handle or field index or no
|
||||||
* current result set.
|
* current result set.
|
||||||
*/
|
*/
|
||||||
native SQL_FetchSize(Handle:query, field);
|
native int SQL_FetchSize(Handle query, int field);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Binds a parameter in a prepared statement to a given integer value.
|
* Binds a parameter in a prepared statement to a given integer value.
|
||||||
|
@ -560,11 +869,10 @@ native SQL_FetchSize(Handle:query, field);
|
||||||
* @param number The number to bind.
|
* @param number The number to bind.
|
||||||
* @param signed True to bind the number as signed, false to
|
* @param signed True to bind the number as signed, false to
|
||||||
* bind it as unsigned.
|
* bind it as unsigned.
|
||||||
* @noreturn
|
|
||||||
* @error Invalid statement Handle or parameter index, or
|
* @error Invalid statement Handle or parameter index, or
|
||||||
* SQL error.
|
* SQL error.
|
||||||
*/
|
*/
|
||||||
native SQL_BindParamInt(Handle:statement, param, number, bool:signed=true);
|
native void SQL_BindParamInt(Handle statement, int param, int number, bool signed=true);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Binds a parameter in a prepared statement to a given float value.
|
* Binds a parameter in a prepared statement to a given float value.
|
||||||
|
@ -572,11 +880,10 @@ native SQL_BindParamInt(Handle:statement, param, number, bool:signed=true);
|
||||||
* @param statement A statement (prepared query) Handle.
|
* @param statement A statement (prepared query) Handle.
|
||||||
* @param param The parameter index (starting from 0).
|
* @param param The parameter index (starting from 0).
|
||||||
* @param value The float number to bind.
|
* @param value The float number to bind.
|
||||||
* @noreturn
|
|
||||||
* @error Invalid statement Handle or parameter index, or
|
* @error Invalid statement Handle or parameter index, or
|
||||||
* SQL error.
|
* SQL error.
|
||||||
*/
|
*/
|
||||||
native SQL_BindParamFloat(Handle:statement, param, Float:value);
|
native void SQL_BindParamFloat(Handle statement, int param, float value);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Binds a parameter in a prepared statement to a given string value.
|
* Binds a parameter in a prepared statement to a given string value.
|
||||||
|
@ -588,11 +895,10 @@ native SQL_BindParamFloat(Handle:statement, param, Float:value);
|
||||||
* locally if necessary. If the string contents
|
* locally if necessary. If the string contents
|
||||||
* won't change before calling SQL_Execute(), this
|
* won't change before calling SQL_Execute(), this
|
||||||
* can be set to false for optimization.
|
* can be set to false for optimization.
|
||||||
* @noreturn
|
|
||||||
* @error Invalid statement Handle or parameter index, or
|
* @error Invalid statement Handle or parameter index, or
|
||||||
* SQL error.
|
* SQL error.
|
||||||
*/
|
*/
|
||||||
native SQL_BindParamString(Handle:statement, param, const String:value[], bool:copy);
|
native void SQL_BindParamString(Handle statement, int param, const char[] value, bool copy);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Executes a prepared statement. All parameters must be bound beforehand.
|
* Executes a prepared statement. All parameters must be bound beforehand.
|
||||||
|
@ -601,7 +907,7 @@ native SQL_BindParamString(Handle:statement, param, const String:value[], bool:c
|
||||||
* @return True on success, false on failure.
|
* @return True on success, false on failure.
|
||||||
* @error Invalid statement Handle.
|
* @error Invalid statement Handle.
|
||||||
*/
|
*/
|
||||||
native bool:SQL_Execute(Handle:statement);
|
native bool SQL_Execute(Handle statement);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Locks a database so threading operations will not interrupt.
|
* Locks a database so threading operations will not interrupt.
|
||||||
|
@ -618,32 +924,27 @@ native bool:SQL_Execute(Handle:statement);
|
||||||
* threaded operation has concluded.
|
* threaded operation has concluded.
|
||||||
*
|
*
|
||||||
* @param database A database Handle.
|
* @param database A database Handle.
|
||||||
* @noreturn
|
|
||||||
* @error Invalid database Handle.
|
* @error Invalid database Handle.
|
||||||
*/
|
*/
|
||||||
native SQL_LockDatabase(Handle:database);
|
native void SQL_LockDatabase(Handle database);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Unlocks a database so threading operations may continue.
|
* Unlocks a database so threading operations may continue.
|
||||||
*
|
*
|
||||||
* @param database A database Handle.
|
* @param database A database Handle.
|
||||||
* @noreturn
|
|
||||||
* @error Invalid database Handle.
|
* @error Invalid database Handle.
|
||||||
*/
|
*/
|
||||||
native SQL_UnlockDatabase(Handle:database);
|
native void SQL_UnlockDatabase(Handle database);
|
||||||
|
|
||||||
/**
|
// General callback for threaded SQL stuff.
|
||||||
* General callback for threaded SQL stuff.
|
//
|
||||||
*
|
// @param owner Parent object of the Handle (or INVALID_HANDLE if none).
|
||||||
* @param owner Parent object of the Handle (or INVALID_HANDLE if none).
|
// @param hndl Handle to the child object (or INVALID_HANDLE if none).
|
||||||
* @param hndl Handle to the child object (or INVALID_HANDLE if none).
|
// @param error Error string if there was an error. The error could be
|
||||||
* @param error Error string if there was an error. The error could be
|
// empty even if an error condition exists, so it is important
|
||||||
* empty even if an error condition exists, so it is important
|
// to check the actual Handle value instead.
|
||||||
* to check the actual Handle value instead.
|
// @param data Data passed in via the original threaded invocation.
|
||||||
* @param data Data passed in via the original threaded invocation.
|
typedef SQLTCallback = function void (Handle owner, Handle hndl, const char[] error, any data);
|
||||||
* @param
|
|
||||||
*/
|
|
||||||
functag public SQLTCallback(Handle:owner, Handle:hndl, const String:error[], any:data);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tells whether two database handles both point to the same database
|
* Tells whether two database handles both point to the same database
|
||||||
|
@ -655,7 +956,7 @@ functag public SQLTCallback(Handle:owner, Handle:hndl, const String:error[], any
|
||||||
* connection, false otherwise.
|
* connection, false otherwise.
|
||||||
* @error Invalid Handle.
|
* @error Invalid Handle.
|
||||||
*/
|
*/
|
||||||
native bool:SQL_IsSameConnection(Handle:hndl1, Handle:hndl2);
|
native bool SQL_IsSameConnection(Handle hndl1, Handle hndl2);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Connects to a database via a thread. This can be used instead of
|
* Connects to a database via a thread. This can be used instead of
|
||||||
|
@ -669,9 +970,8 @@ native bool:SQL_IsSameConnection(Handle:hndl1, Handle:hndl2);
|
||||||
* If no driver was found, the owner is INVALID_HANDLE.
|
* If no driver was found, the owner is INVALID_HANDLE.
|
||||||
* @param name Database name.
|
* @param name Database name.
|
||||||
* @param data Extra data value to pass to the callback.
|
* @param data Extra data value to pass to the callback.
|
||||||
* @noreturn
|
|
||||||
*/
|
*/
|
||||||
native SQL_TConnect(SQLTCallback:callback, const String:name[]="default", any:data=0);
|
native void SQL_TConnect(SQLTCallback callback, const char[] name="default", any data=0);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Executes a simple query via a thread. The query Handle is passed through
|
* Executes a simple query via a thread. The query Handle is passed through
|
||||||
|
@ -690,10 +990,9 @@ native SQL_TConnect(SQLTCallback:callback, const String:name[]="default", any:da
|
||||||
* @param query Query string.
|
* @param query Query string.
|
||||||
* @param data Extra data value to pass to the callback.
|
* @param data Extra data value to pass to the callback.
|
||||||
* @param prio Priority queue to use.
|
* @param prio Priority queue to use.
|
||||||
* @noreturn
|
|
||||||
* @error Invalid database Handle.
|
* @error Invalid database Handle.
|
||||||
*/
|
*/
|
||||||
native SQL_TQuery(Handle:database, SQLTCallback:callback, const String:query[], any:data=0, DBPriority:prio=DBPrio_Normal);
|
native void SQL_TQuery(Handle database, SQLTCallback callback, const char[] query, any data=0, DBPriority prio=DBPrio_Normal);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new transaction object. A transaction object is a list of queries
|
* Creates a new transaction object. A transaction object is a list of queries
|
||||||
|
@ -701,7 +1000,7 @@ native SQL_TQuery(Handle:database, SQLTCallback:callback, const String:query[],
|
||||||
*
|
*
|
||||||
* @return A transaction handle.
|
* @return A transaction handle.
|
||||||
*/
|
*/
|
||||||
native Handle:SQL_CreateTransaction();
|
native Transaction SQL_CreateTransaction();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds a query to a transaction object.
|
* Adds a query to a transaction object.
|
||||||
|
@ -712,32 +1011,7 @@ native Handle:SQL_CreateTransaction();
|
||||||
* @return The index of the query in the transaction's query list.
|
* @return The index of the query in the transaction's query list.
|
||||||
* @error Invalid transaction handle.
|
* @error Invalid transaction handle.
|
||||||
*/
|
*/
|
||||||
native SQL_AddQuery(Handle:txn, const String:query[], any:data=0);
|
native int SQL_AddQuery(Transaction txn, const char[] query, any data=0);
|
||||||
|
|
||||||
/**
|
|
||||||
* Callback for a successful transaction.
|
|
||||||
*
|
|
||||||
* @param db Database handle.
|
|
||||||
* @param data Data value passed to SQL_ExecuteTransaction().
|
|
||||||
* @param numQueries Number of queries executed in the transaction.
|
|
||||||
* @param results An array of Query handle results, one for each of numQueries. They are closed automatically.
|
|
||||||
* @param queryData An array of each data value passed to SQL_AddQuery().
|
|
||||||
* @noreturn
|
|
||||||
*/
|
|
||||||
functag public SQLTxnSuccess(Handle:db, any:data, numQueries, Handle:results[], any:queryData[]);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Callback for a failed transaction.
|
|
||||||
*
|
|
||||||
* @param db Database handle.
|
|
||||||
* @param data Data value passed to SQL_ExecuteTransaction().
|
|
||||||
* @param numQueries Number of queries executed in the transaction.
|
|
||||||
* @param error Error message.
|
|
||||||
* @param failIndex Index of the query that failed, or -1 if something else.
|
|
||||||
* @param queryData An array of each data value passed to SQL_AddQuery().
|
|
||||||
* @noreturn
|
|
||||||
*/
|
|
||||||
functag public SQLTxnFailure(Handle:db, any:data, numQueries, const String:error[], failIndex, any:queryData[]);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sends a transaction to the database thread. The transaction handle is
|
* Sends a transaction to the database thread. The transaction handle is
|
||||||
|
@ -754,9 +1028,9 @@ functag public SQLTxnFailure(Handle:db, any:data, numQueries, const String:error
|
||||||
* @error An invalid handle.
|
* @error An invalid handle.
|
||||||
*/
|
*/
|
||||||
native SQL_ExecuteTransaction(
|
native SQL_ExecuteTransaction(
|
||||||
Handle:db,
|
Handle db,
|
||||||
Handle:txn,
|
Transaction:txn,
|
||||||
SQLTxnSuccess:onSuccess=SQLTxnSuccess:-1,
|
SQLTxnSuccess:onSuccess = INVALID_FUNCTION,
|
||||||
SQLTxnFailure:onError=SQLTxnFailure:-1,
|
SQLTxnFailure:onError = INVALID_FUNCTION,
|
||||||
any:data=0,
|
any data=0,
|
||||||
DBPriority:priority=DBPrio_Normal);
|
DBPriority:priority=DBPrio_Normal);
|
||||||
|
|
9
env/include/entity.inc
vendored
9
env/include/entity.inc
vendored
|
@ -682,15 +682,12 @@ native GetEntPropArraySize(entity, PropType:type, const String:prop[]);
|
||||||
* @param array Array to read into.
|
* @param array Array to read into.
|
||||||
* @param arraySize Number of values to read.
|
* @param arraySize Number of values to read.
|
||||||
* @param dataSize Size of each value in bytes (1, 2, or 4).
|
* @param dataSize Size of each value in bytes (1, 2, or 4).
|
||||||
* @noreturn
|
|
||||||
* @error Invalid entity or offset out of reasonable bounds.
|
* @error Invalid entity or offset out of reasonable bounds.
|
||||||
*/
|
*/
|
||||||
stock GetEntDataArray(entity, offset, array[], arraySize, dataSize=4)
|
stock void GetEntDataArray(int entity, int offset, int[] array, int arraySize, int dataSize=4)
|
||||||
{
|
{
|
||||||
for (new i=0; i<arraySize; i++)
|
for (int i=0; i<arraySize; i++)
|
||||||
{
|
array[i] = GetEntData(entity, offset + i*dataSize, dataSize);
|
||||||
array[i] = GetEntData(entity, offset + i*dataSize, dataSize)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
176
env/include/events.inc
vendored
176
env/include/events.inc
vendored
|
@ -1,7 +1,7 @@
|
||||||
/**
|
/**
|
||||||
* vim: set ts=4 :
|
* vim: set ts=4 sw=4 tw=99 noet :
|
||||||
* =============================================================================
|
* =============================================================================
|
||||||
* SourceMod (C)2004-2008 AlliedModders LLC. All rights reserved.
|
* SourceMod (C)2004-2014 AlliedModders LLC. All rights reserved.
|
||||||
* =============================================================================
|
* =============================================================================
|
||||||
*
|
*
|
||||||
* This file is part of the SourceMod/SourcePawn SDK.
|
* This file is part of the SourceMod/SourcePawn SDK.
|
||||||
|
@ -40,38 +40,123 @@
|
||||||
*/
|
*/
|
||||||
enum EventHookMode
|
enum EventHookMode
|
||||||
{
|
{
|
||||||
EventHookMode_Pre, /**< Hook callback fired before event is fired */
|
EventHookMode_Pre, //< Hook callback fired before event is fired */
|
||||||
EventHookMode_Post, /**< Hook callback fired after event is fired */
|
EventHookMode_Post, //< Hook callback fired after event is fired */
|
||||||
EventHookMode_PostNoCopy /**< Hook callback fired after event is fired, but event data won't be copied */
|
EventHookMode_PostNoCopy //< Hook callback fired after event is fired, but event data won't be copied */
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Hook function types for events.
|
* Hook function types for events.
|
||||||
*/
|
*/
|
||||||
funcenum EventHook
|
typeset EventHook
|
||||||
{
|
{
|
||||||
/**
|
// Called when a game event is fired.
|
||||||
* Called when a game event is fired.
|
//
|
||||||
*
|
// @param event Handle to event. This could be INVALID_HANDLE if every plugin hooking
|
||||||
* @param event Handle to event. This could be INVALID_HANDLE if every plugin hooking
|
// this event has set the hook mode EventHookMode_PostNoCopy.
|
||||||
* this event has set the hook mode EventHookMode_PostNoCopy.
|
// @param name String containing the name of the event.
|
||||||
* @param name String containing the name of the event.
|
// @param dontBroadcast True if event was not broadcast to clients, false otherwise.
|
||||||
* @param dontBroadcast True if event was not broadcast to clients, false otherwise.
|
// @return Ignored for post hooks. Plugin_Handled will block event if hooked as pre.
|
||||||
* @return Ignored for post hooks. Plugin_Handled will block event if hooked as pre.
|
///
|
||||||
*/
|
function Action (Event event, const char[] name, bool dontBroadcast);
|
||||||
Action:public(Handle:event, const String:name[], bool:dontBroadcast),
|
//
|
||||||
/**
|
// Called when a game event is fired.
|
||||||
* Called when a game event is fired.
|
//
|
||||||
*
|
// @param event Handle to event. This could be INVALID_HANDLE if every plugin hooking
|
||||||
* @param event Handle to event. This could be INVALID_HANDLE if every plugin hooking
|
// this event has set the hook mode EventHookMode_PostNoCopy.
|
||||||
* this event has set the hook mode EventHookMode_PostNoCopy.
|
// @param name String containing the name of the event.
|
||||||
* @param name String containing the name of the event.
|
// @param dontBroadcast True if event was not broadcast to clients, false otherwise.
|
||||||
* @param dontBroadcast True if event was not broadcast to clients, false otherwise.
|
// @noreturn
|
||||||
* @noreturn
|
///
|
||||||
*/
|
function void (Event event, const char[] name, bool dontBroadcast);
|
||||||
public(Handle:event, const String:name[], bool:dontBroadcast),
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
methodmap Event < Handle
|
||||||
|
{
|
||||||
|
// Fires a game event.
|
||||||
|
//
|
||||||
|
// This function closes the event Handle after completing.
|
||||||
|
//
|
||||||
|
// @param dontBroadcast Optional boolean that determines if event should be broadcast to clients.
|
||||||
|
public native void Fire(bool dontBroadcast=false);
|
||||||
|
|
||||||
|
// Cancels a previously created game event that has not been fired. This
|
||||||
|
// is necessary to avoid leaking memory when an event isn't fired.
|
||||||
|
public native void Cancel();
|
||||||
|
|
||||||
|
// Returns the boolean value of a game event's key.
|
||||||
|
//
|
||||||
|
// @param key Name of event key.
|
||||||
|
// @param defValue Optional default value to use if the key is not found.
|
||||||
|
// @return The boolean value of the specfied event key.
|
||||||
|
public native bool GetBool(const char[] key, bool defValue=false);
|
||||||
|
|
||||||
|
// Sets the boolean value of a game event's key.
|
||||||
|
//
|
||||||
|
// @param key Name of event key.
|
||||||
|
// @param value New boolean value.
|
||||||
|
public native void SetBool(const char[] key, bool value);
|
||||||
|
|
||||||
|
// Returns the integer value of a game event's key.
|
||||||
|
//
|
||||||
|
// @param key Name of event key.
|
||||||
|
// @param defValue Optional default value to use if the key is not found.
|
||||||
|
// @return The integer value of the specfied event key.
|
||||||
|
public native int GetInt(const char[] key, int defValue=0);
|
||||||
|
|
||||||
|
// Sets the integer value of a game event's key.
|
||||||
|
//
|
||||||
|
// Integer value refers to anything that can be reduced to an integer.
|
||||||
|
// The various size specifiers, such as "byte" and "short" are still
|
||||||
|
// integers, and only refer to how much data will actually be sent
|
||||||
|
// over the network (if applicable).
|
||||||
|
//
|
||||||
|
// @param key Name of event key.
|
||||||
|
// @param value New integer value.
|
||||||
|
public native void SetInt(const char[] key, int value);
|
||||||
|
|
||||||
|
// Returns the floating point value of a game event's key.
|
||||||
|
//
|
||||||
|
// @param key Name of event key.
|
||||||
|
// @param defValue Optional default value to use if the key is not found.
|
||||||
|
// @return The floating point value of the specfied event key.
|
||||||
|
public native float GetFloat(const char[] key, float defValue=0.0);
|
||||||
|
|
||||||
|
// Sets the floating point value of a game event's key.
|
||||||
|
//
|
||||||
|
// @param key Name of event key.
|
||||||
|
// @param value New floating point value.
|
||||||
|
public native void SetFloat(const char[] key, float value);
|
||||||
|
|
||||||
|
// Retrieves the string value of a game event's key.
|
||||||
|
//
|
||||||
|
// @param key Name of event key.
|
||||||
|
// @param value Buffer to store the value of the specified event key.
|
||||||
|
// @param maxlength Maximum length of string buffer.
|
||||||
|
// @param defValue Optional default value to use if the key is not found.
|
||||||
|
public native void GetString(const char[] key, char[] value, int maxlength, const char[] defvalue="");
|
||||||
|
|
||||||
|
// Sets the string value of a game event's key.
|
||||||
|
//
|
||||||
|
// @param key Name of event key.
|
||||||
|
// @param value New string value.
|
||||||
|
public native void SetString(const char[] key, const char[] value);
|
||||||
|
|
||||||
|
// Retrieves the name of a game event.
|
||||||
|
//
|
||||||
|
// @param name Buffer to store the name of the event.
|
||||||
|
// @param maxlength Maximum length of string buffer.
|
||||||
|
public native void GetName(char[] name, int maxlength);
|
||||||
|
|
||||||
|
// Sets whether an event's broadcasting will be disabled or not.
|
||||||
|
//
|
||||||
|
// This has no effect on events Handles that are not from HookEvent
|
||||||
|
// or HookEventEx callbacks.
|
||||||
|
property bool BroadcastDisabled {
|
||||||
|
public native set(bool dontBroadcast);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a hook for when a game event is fired.
|
* Creates a hook for when a game event is fired.
|
||||||
*
|
*
|
||||||
|
@ -81,7 +166,7 @@ funcenum EventHook
|
||||||
* @noreturn
|
* @noreturn
|
||||||
* @error Invalid event name or invalid callback function.
|
* @error Invalid event name or invalid callback function.
|
||||||
*/
|
*/
|
||||||
native HookEvent(const String:name[], EventHook:callback, EventHookMode:mode=EventHookMode_Post);
|
native void HookEvent(const char[] name, EventHook callback, EventHookMode mode=EventHookMode_Post);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a hook for when a game event is fired.
|
* Creates a hook for when a game event is fired.
|
||||||
|
@ -92,7 +177,7 @@ native HookEvent(const String:name[], EventHook:callback, EventHookMode:mode=Eve
|
||||||
* @return True if event exists and was hooked successfully, false otherwise.
|
* @return True if event exists and was hooked successfully, false otherwise.
|
||||||
* @error Invalid callback function.
|
* @error Invalid callback function.
|
||||||
*/
|
*/
|
||||||
native bool:HookEventEx(const String:name[], EventHook:callback, EventHookMode:mode=EventHookMode_Post);
|
native bool HookEventEx(const char[] name, EventHook callback, EventHookMode mode=EventHookMode_Post);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Removes a hook for when a game event is fired.
|
* Removes a hook for when a game event is fired.
|
||||||
|
@ -103,13 +188,13 @@ native bool:HookEventEx(const String:name[], EventHook:callback, EventHookMode:m
|
||||||
* @noreturn
|
* @noreturn
|
||||||
* @error Invalid callback function or no active hook for specified event.
|
* @error Invalid callback function or no active hook for specified event.
|
||||||
*/
|
*/
|
||||||
native UnhookEvent(const String:name[], EventHook:callback, EventHookMode:mode=EventHookMode_Post);
|
native void UnhookEvent(const char[] name, EventHook callback, EventHookMode mode=EventHookMode_Post);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a game event to be fired later.
|
* Creates a game event to be fired later.
|
||||||
*
|
*
|
||||||
* The Handle should not be closed via CloseHandle(). It must be closed via
|
* The Handle should not be closed via CloseHandle(). It must be closed via
|
||||||
* FireEvent() or CancelCreatedEvent().
|
* event.Fire() or event.Cancel().
|
||||||
*
|
*
|
||||||
* @param name Name of event.
|
* @param name Name of event.
|
||||||
* @param force If set to true, this forces the event to be created even if it's not being hooked.
|
* @param force If set to true, this forces the event to be created even if it's not being hooked.
|
||||||
|
@ -117,7 +202,7 @@ native UnhookEvent(const String:name[], EventHook:callback, EventHookMode:mode=E
|
||||||
* @return Handle to event. INVALID_HANDLE is returned if the event doesn't exist or isn't
|
* @return Handle to event. INVALID_HANDLE is returned if the event doesn't exist or isn't
|
||||||
being hooked (unless force is true).
|
being hooked (unless force is true).
|
||||||
*/
|
*/
|
||||||
native Handle:CreateEvent(const String:name[], bool:force=false);
|
native Event CreateEvent(const char[] name, bool force=false);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fires a game event.
|
* Fires a game event.
|
||||||
|
@ -129,7 +214,7 @@ native Handle:CreateEvent(const String:name[], bool:force=false);
|
||||||
* @noreturn
|
* @noreturn
|
||||||
* @error Invalid or corrupt Handle.
|
* @error Invalid or corrupt Handle.
|
||||||
*/
|
*/
|
||||||
native FireEvent(Handle:event, bool:dontBroadcast=false);
|
native void FireEvent(Handle event, bool dontBroadcast=false);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Cancels a previously created game event that has not been fired.
|
* Cancels a previously created game event that has not been fired.
|
||||||
|
@ -138,17 +223,18 @@ native FireEvent(Handle:event, bool:dontBroadcast=false);
|
||||||
* @noreturn
|
* @noreturn
|
||||||
* @error Invalid or corrupt Handle.
|
* @error Invalid or corrupt Handle.
|
||||||
*/
|
*/
|
||||||
native CancelCreatedEvent(Handle:event);
|
native void CancelCreatedEvent(Handle event);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the boolean value of a game event's key.
|
* Returns the boolean value of a game event's key.
|
||||||
*
|
*
|
||||||
* @param event Handle to the event.
|
* @param event Handle to the event.
|
||||||
* @param key Name of event key.
|
* @param key Name of event key.
|
||||||
|
* @param defValue Optional default value to use if the key is not found.
|
||||||
* @return The boolean value of the specfied event key.
|
* @return The boolean value of the specfied event key.
|
||||||
* @error Invalid or corrupt Handle.
|
* @error Invalid or corrupt Handle.
|
||||||
*/
|
*/
|
||||||
native bool:GetEventBool(Handle:event, const String:key[]);
|
native bool GetEventBool(Handle event, const char[] key, bool defValue=false);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the boolean value of a game event's key.
|
* Sets the boolean value of a game event's key.
|
||||||
|
@ -159,17 +245,18 @@ native bool:GetEventBool(Handle:event, const String:key[]);
|
||||||
* @noreturn
|
* @noreturn
|
||||||
* @error Invalid or corrupt Handle.
|
* @error Invalid or corrupt Handle.
|
||||||
*/
|
*/
|
||||||
native SetEventBool(Handle:event, const String:key[], bool:value);
|
native void SetEventBool(Handle event, const char[] key, bool value);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the integer value of a game event's key.
|
* Returns the integer value of a game event's key.
|
||||||
*
|
*
|
||||||
* @param event Handle to the event.
|
* @param event Handle to the event.
|
||||||
* @param key Name of event key.
|
* @param key Name of event key.
|
||||||
|
* @param defValue Optional default value to use if the key is not found.
|
||||||
* @return The integer value of the specfied event key.
|
* @return The integer value of the specfied event key.
|
||||||
* @error Invalid or corrupt Handle.
|
* @error Invalid or corrupt Handle.
|
||||||
*/
|
*/
|
||||||
native GetEventInt(Handle:event, const String:key[]);
|
native int GetEventInt(Handle event, const char[] key, int defValue=0);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the integer value of a game event's key.
|
* Sets the integer value of a game event's key.
|
||||||
|
@ -185,17 +272,18 @@ native GetEventInt(Handle:event, const String:key[]);
|
||||||
* @noreturn
|
* @noreturn
|
||||||
* @error Invalid or corrupt Handle.
|
* @error Invalid or corrupt Handle.
|
||||||
*/
|
*/
|
||||||
native SetEventInt(Handle:event, const String:key[], value);
|
native void SetEventInt(Handle event, const char[] key, int value);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the floating point value of a game event's key.
|
* Returns the floating point value of a game event's key.
|
||||||
*
|
*
|
||||||
* @param event Handle to the event.
|
* @param event Handle to the event.
|
||||||
* @param key Name of event key.
|
* @param key Name of event key.
|
||||||
|
* @param defValue Optional default value to use if the key is not found.
|
||||||
* @return The floating point value of the specfied event key.
|
* @return The floating point value of the specfied event key.
|
||||||
* @error Invalid or corrupt Handle.
|
* @error Invalid or corrupt Handle.
|
||||||
*/
|
*/
|
||||||
native Float:GetEventFloat(Handle:event, const String:key[]);
|
native float GetEventFloat(Handle event, const char[] key, float defValue=0.0);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the floating point value of a game event's key.
|
* Sets the floating point value of a game event's key.
|
||||||
|
@ -206,7 +294,7 @@ native Float:GetEventFloat(Handle:event, const String:key[]);
|
||||||
* @noreturn
|
* @noreturn
|
||||||
* @error Invalid or corrupt Handle.
|
* @error Invalid or corrupt Handle.
|
||||||
*/
|
*/
|
||||||
native SetEventFloat(Handle:event, const String:key[], Float:value);
|
native void SetEventFloat(Handle event, const char[] key, float value);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieves the string value of a game event's key.
|
* Retrieves the string value of a game event's key.
|
||||||
|
@ -215,10 +303,11 @@ native SetEventFloat(Handle:event, const String:key[], Float:value);
|
||||||
* @param key Name of event key.
|
* @param key Name of event key.
|
||||||
* @param value Buffer to store the value of the specified event key.
|
* @param value Buffer to store the value of the specified event key.
|
||||||
* @param maxlength Maximum length of string buffer.
|
* @param maxlength Maximum length of string buffer.
|
||||||
|
* @param defValue Optional default value to use if the key is not found.
|
||||||
* @noreturn
|
* @noreturn
|
||||||
* @error Invalid or corrupt Handle.
|
* @error Invalid or corrupt Handle.
|
||||||
*/
|
*/
|
||||||
native GetEventString(Handle:event, const String:key[], String:value[], maxlength);
|
native void GetEventString(Handle event, const char[] key, char[] value, int maxlength, const char[] defvalue="");
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the string value of a game event's key.
|
* Sets the string value of a game event's key.
|
||||||
|
@ -229,7 +318,7 @@ native GetEventString(Handle:event, const String:key[], String:value[], maxlengt
|
||||||
* @noreturn
|
* @noreturn
|
||||||
* @error Invalid or corrupt Handle.
|
* @error Invalid or corrupt Handle.
|
||||||
*/
|
*/
|
||||||
native SetEventString(Handle:event, const String:key[], const String:value[]);
|
native void SetEventString(Handle event, const char[] key, const char[] value);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieves the name of a game event.
|
* Retrieves the name of a game event.
|
||||||
|
@ -240,7 +329,7 @@ native SetEventString(Handle:event, const String:key[], const String:value[]);
|
||||||
* @noreturn
|
* @noreturn
|
||||||
* @error Invalid or corrupt Handle.
|
* @error Invalid or corrupt Handle.
|
||||||
*/
|
*/
|
||||||
native GetEventName(Handle:event, String:name[], maxlength);
|
native void GetEventName(Handle event, char[] name, int maxlength);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets whether an event's broadcasting will be disabled or not.
|
* Sets whether an event's broadcasting will be disabled or not.
|
||||||
|
@ -253,5 +342,4 @@ native GetEventName(Handle:event, String:name[], maxlength);
|
||||||
* @noreturn
|
* @noreturn
|
||||||
* @error Invalid Handle.
|
* @error Invalid Handle.
|
||||||
*/
|
*/
|
||||||
native SetEventBroadcast(Handle:event, bool:dontBroadcast);
|
native void SetEventBroadcast(Handle event, bool dontBroadcast);
|
||||||
|
|
||||||
|
|
310
env/include/files.inc
vendored
310
env/include/files.inc
vendored
|
@ -1,7 +1,7 @@
|
||||||
/**
|
/**
|
||||||
* vim: set ts=4 :
|
* vim: set ts=4 sw=4 tw=99 noet :
|
||||||
* =============================================================================
|
* =============================================================================
|
||||||
* SourceMod (C)2004-2008 AlliedModders LLC. All rights reserved.
|
* SourceMod (C)2004-2014 AlliedModders LLC. All rights reserved.
|
||||||
* =============================================================================
|
* =============================================================================
|
||||||
*
|
*
|
||||||
* This file is part of the SourceMod/SourcePawn SDK.
|
* This file is part of the SourceMod/SourcePawn SDK.
|
||||||
|
@ -36,7 +36,7 @@
|
||||||
#define _files_included
|
#define _files_included
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @global All paths in SourceMod natives are relative to the mod folder
|
* @global All paths in SourceMod natives are relative to the mod folder
|
||||||
* unless otherwise noted.
|
* unless otherwise noted.
|
||||||
*
|
*
|
||||||
* Most functions in SourceMod (at least, ones that deal with direct
|
* Most functions in SourceMod (at least, ones that deal with direct
|
||||||
|
@ -55,7 +55,7 @@
|
||||||
/**
|
/**
|
||||||
* File inode types.
|
* File inode types.
|
||||||
*/
|
*/
|
||||||
enum FileType
|
enum FileType:
|
||||||
{
|
{
|
||||||
FileType_Unknown = 0, /* Unknown file type (device/socket) */
|
FileType_Unknown = 0, /* Unknown file type (device/socket) */
|
||||||
FileType_Directory = 1, /* File is a directory */
|
FileType_Directory = 1, /* File is a directory */
|
||||||
|
@ -65,7 +65,7 @@ enum FileType
|
||||||
/**
|
/**
|
||||||
* File time modes.
|
* File time modes.
|
||||||
*/
|
*/
|
||||||
enum FileTimeMode
|
enum FileTimeMode:
|
||||||
{
|
{
|
||||||
FileTime_LastAccess = 0, /* Last access (does not work on FAT) */
|
FileTime_LastAccess = 0, /* Last access (does not work on FAT) */
|
||||||
FileTime_Created = 1, /* Creation (does not work on FAT) */
|
FileTime_Created = 1, /* Creation (does not work on FAT) */
|
||||||
|
@ -81,11 +81,164 @@ enum FileTimeMode
|
||||||
/**
|
/**
|
||||||
* Path types.
|
* Path types.
|
||||||
*/
|
*/
|
||||||
enum PathType
|
enum PathType:
|
||||||
{
|
{
|
||||||
Path_SM, /**< SourceMod root folder */
|
Path_SM, /**< SourceMod root folder */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// A DirectoryListing iterates over the contents of a directory. To obtain a
|
||||||
|
// DirectoryListing handle, call OpenDirectory().
|
||||||
|
methodmap DirectoryListing < Handle
|
||||||
|
{
|
||||||
|
// Reads the current directory entry as a local filename, then moves to the
|
||||||
|
// next file.
|
||||||
|
//
|
||||||
|
// Note: Both the '.' and '..' automatic directory entries will be retrieved.
|
||||||
|
//
|
||||||
|
// @param buffer String buffer to hold directory name.
|
||||||
|
// @param maxlength Maximum size of string buffer.
|
||||||
|
// @param type Optional variable to store the file type.
|
||||||
|
// @return True on success, false if there are no more files to read.
|
||||||
|
public native bool GetNext(char[] buffer, int maxlength, FileType &type=FileType_Unknown);
|
||||||
|
};
|
||||||
|
|
||||||
|
// A File object can be obtained by calling OpenFile(). File objects should be
|
||||||
|
// closed with delete or Close(). Note that, "delete file" does not
|
||||||
|
// actually a file, it just closes it.
|
||||||
|
methodmap File < Handle
|
||||||
|
{
|
||||||
|
// Close the file handle. This is the same as using CloseHandle) or delete.
|
||||||
|
public void Close() {
|
||||||
|
CloseHandle(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Reads a line of text from a file.
|
||||||
|
//
|
||||||
|
// @param buffer String buffer to hold the line.
|
||||||
|
// @param maxlength Maximum size of string buffer.
|
||||||
|
// @return True on success, false otherwise.
|
||||||
|
public native bool ReadLine(char[] buffer, int maxlength);
|
||||||
|
|
||||||
|
// Reads binary data from a file.
|
||||||
|
//
|
||||||
|
// @param items Array to store each item read.
|
||||||
|
// @param num_items Number of items to read into the array.
|
||||||
|
// @param size Size of each element, in bytes, to be read.
|
||||||
|
// Valid sizes are 1, 2, or 4.
|
||||||
|
// @return Number of elements read, or -1 on error.
|
||||||
|
public native int Read(int[] items, int num_items, int size);
|
||||||
|
|
||||||
|
// Reads a UTF8 or ANSI string from a file.
|
||||||
|
//
|
||||||
|
// @param buffer Buffer to store the string.
|
||||||
|
// @param max_size Maximum size of the string buffer.
|
||||||
|
// @param read_count If -1, reads until a null terminator is encountered in
|
||||||
|
// the file. Otherwise, read_count bytes are read
|
||||||
|
// into the buffer provided. In this case the buffer
|
||||||
|
// is not explicitly null terminated, and the buffer
|
||||||
|
// will contain any null terminators read from the file.
|
||||||
|
// @return Number of characters written to the buffer, or -1
|
||||||
|
// if an error was encountered.
|
||||||
|
// @error read_count > max_size.
|
||||||
|
public native int ReadString(char[] buffer, int max_size, int read_count=-1);
|
||||||
|
|
||||||
|
// Writes binary data to a file.
|
||||||
|
//
|
||||||
|
// @param items Array of items to write. The data is read directly.
|
||||||
|
// That is, in 1 or 2-byte mode, the lower byte(s) in
|
||||||
|
// each cell are used directly, rather than performing
|
||||||
|
// any casts from a 4-byte number to a smaller number.
|
||||||
|
// @param num_items Number of items in the array.
|
||||||
|
// @param size Size of each item in the array in bytes.
|
||||||
|
// Valid sizes are 1, 2, or 4.
|
||||||
|
// @return True on success, false on error.
|
||||||
|
public native bool Write(const int[] items, int num_items, int size);
|
||||||
|
|
||||||
|
// Writes a binary string to a file.
|
||||||
|
//
|
||||||
|
// @param buffer String to write.
|
||||||
|
// @param term True to append NUL terminator, false otherwise.
|
||||||
|
// @return True on success, false on error.
|
||||||
|
public native bool WriteString(const char[] buffer, bool term);
|
||||||
|
|
||||||
|
// Writes a line of text to a text file. A newline is automatically appended.
|
||||||
|
//
|
||||||
|
// @param hndl Handle to the file.
|
||||||
|
// @param format Formatting rules.
|
||||||
|
// @param ... Variable number of format parameters.
|
||||||
|
// @return True on success, false otherwise.
|
||||||
|
public native bool WriteLine(const char[] format, any:...);
|
||||||
|
|
||||||
|
// Reads a single int8 (byte) from a file. The returned value is sign-
|
||||||
|
// extended to an int32.
|
||||||
|
//
|
||||||
|
// @param data Variable to store the data read.
|
||||||
|
// @return True on success, false on failure.
|
||||||
|
public native bool ReadInt8(int &data);
|
||||||
|
|
||||||
|
// Reads a single uint8 (unsigned byte) from a file. The returned value is
|
||||||
|
// zero-extended to an int32.
|
||||||
|
//
|
||||||
|
// @param data Variable to store the data read.
|
||||||
|
// @return True on success, false on failure.
|
||||||
|
public native bool ReadUint8(int &data);
|
||||||
|
|
||||||
|
// Reads a single int16 (short) from a file. The value is sign-extended to
|
||||||
|
// an int32.
|
||||||
|
//
|
||||||
|
// @param data Variable to store the data read.
|
||||||
|
// @return True on success, false on failure.
|
||||||
|
public native bool ReadInt16(int &data);
|
||||||
|
|
||||||
|
// Reads a single unt16 (unsigned short) from a file. The value is zero-
|
||||||
|
// extended to an int32.
|
||||||
|
//
|
||||||
|
// @param data Variable to store the data read.
|
||||||
|
// @return True on success, false on failure.
|
||||||
|
public native bool ReadUint16(int &data);
|
||||||
|
|
||||||
|
// Reads a single int32 (int/cell) from a file.
|
||||||
|
//
|
||||||
|
// @param data Variable to store the data read.
|
||||||
|
// @return True on success, false on failure.
|
||||||
|
public native bool ReadInt32(int &data);
|
||||||
|
|
||||||
|
// Writes a single int8 (byte) to a file.
|
||||||
|
//
|
||||||
|
// @param data Data to write (truncated to an int8).
|
||||||
|
// @return True on success, false on failure.
|
||||||
|
public native bool WriteInt8(int data);
|
||||||
|
|
||||||
|
// Writes a single int16 (short) to a file.
|
||||||
|
//
|
||||||
|
// @param data Data to write (truncated to an int16).
|
||||||
|
// @return True on success, false on failure.
|
||||||
|
public native bool WriteInt16(int data);
|
||||||
|
|
||||||
|
// Writes a single int32 (int/cell) to a file.
|
||||||
|
//
|
||||||
|
// @param data Data to write.
|
||||||
|
// @return True on success, false on failure.
|
||||||
|
public native bool WriteInt32(int data);
|
||||||
|
|
||||||
|
// Tests if the end of file has been reached.
|
||||||
|
//
|
||||||
|
// @return True if end of file has been reached, false otherwise.
|
||||||
|
public native bool EndOfFile();
|
||||||
|
|
||||||
|
// Sets the file position indicator.
|
||||||
|
//
|
||||||
|
// @param position Position relative to what is specified in whence.
|
||||||
|
// @param where SEEK_ constant value of where to see from.
|
||||||
|
// @return True on success, false otherwise.
|
||||||
|
public native bool Seek(int position, int where);
|
||||||
|
|
||||||
|
// Get the current position in the file; returns -1 on failure.
|
||||||
|
property int Position {
|
||||||
|
public native get();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Builds a path relative to the SourceMod folder. This should be used instead of
|
* Builds a path relative to the SourceMod folder. This should be used instead of
|
||||||
* directly referencing addons/sourcemod, in case users change the name of their
|
* directly referencing addons/sourcemod, in case users change the name of their
|
||||||
|
@ -98,19 +251,24 @@ enum PathType
|
||||||
* @param ... Format arguments.
|
* @param ... Format arguments.
|
||||||
* @return Number of bytes written to buffer (not including null terminator).
|
* @return Number of bytes written to buffer (not including null terminator).
|
||||||
*/
|
*/
|
||||||
native BuildPath(PathType:type, String:buffer[], maxlength, const String:fmt[], any:...);
|
native int BuildPath(PathType type, char[] buffer, int maxlength, const char[] fmt, any:...);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Opens a directory/folder for contents enumeration.
|
* Opens a directory/folder for contents enumeration.
|
||||||
*
|
*
|
||||||
* @note Directories are closed with CloseHandle().
|
* @note Directories are closed with CloseHandle() or delete.
|
||||||
* @note Directories Handles can be cloned.
|
* @note Directories Handles can be cloned.
|
||||||
* @note OpenDirectory() supports the "file://" notation.
|
* @note OpenDirectory() supports the "file://" notation.
|
||||||
*
|
*
|
||||||
* @param path Path to open.
|
* @param path Path to open.
|
||||||
* @return A Handle to the directory, INVALID_HANDLE on open error.
|
* @param use_valve_fs If true, the Valve file system will be used instead.
|
||||||
|
* This can be used to find files existing in any of
|
||||||
|
* the Valve search paths, rather than solely files
|
||||||
|
* existing directly in the gamedir.
|
||||||
|
* @param valve_path_id If use_valve_fs, a search path from gameinfo or NULL_STRING for all search paths.
|
||||||
|
* @return A Handle to the directory, null on error.
|
||||||
*/
|
*/
|
||||||
native Handle:OpenDirectory(const String:path[]);
|
native DirectoryListing OpenDirectory(const char[] path, bool use_valve_fs=false, const char[] valve_path_id="GAME");
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reads the current directory entry as a local filename, then moves to the next file.
|
* Reads the current directory entry as a local filename, then moves to the next file.
|
||||||
|
@ -125,28 +283,56 @@ native Handle:OpenDirectory(const String:path[]);
|
||||||
* @return True on success, false if there are no more files to read.
|
* @return True on success, false if there are no more files to read.
|
||||||
* @error Invalid or corrupt Handle.
|
* @error Invalid or corrupt Handle.
|
||||||
*/
|
*/
|
||||||
native bool:ReadDirEntry(Handle:dir, String:buffer[], maxlength, &FileType:type=FileType_Unknown);
|
native bool ReadDirEntry(Handle dir, char[] buffer, int maxlength, FileType &type=FileType_Unknown);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Opens a file.
|
* Opens or creates a file, returning a File handle on success. File handles
|
||||||
|
* should be closed with delete or CloseHandle().
|
||||||
*
|
*
|
||||||
* @note Files are closed with CloseHandle().
|
* The open mode may be one of the following strings:
|
||||||
* @note File Handles can be cloned.
|
* "r": Open an existing file for reading.
|
||||||
* @note OpenFile() supports the "file://" notation.
|
* "w": Create a file for writing, or truncate (delete the contents of) an
|
||||||
|
* existing file and then open it for writing.
|
||||||
|
* "a": Create a file for writing, or open an existing file such that writes
|
||||||
|
* will be appended to the end.
|
||||||
|
* "r+": Open an existing file for both reading and writing.
|
||||||
|
* "w+": Create a file for reading and writing, or truncate an existing file
|
||||||
|
* and then open it for reading and writing.
|
||||||
|
* "a+": Create a file for both reading and writing, or open an existing file
|
||||||
|
* such that writes will be appended to the end.
|
||||||
|
*
|
||||||
|
* The open mode may also contain an additional character after "r", "w", or "a",
|
||||||
|
* but before any "+" sign. This character may be "b" (indicating binary mode) or
|
||||||
|
* "t" (indicating text mode). By default, "text" mode is implied. On Linux and
|
||||||
|
* Mac, this has no distinction from binary mode. On Windows, it causes the '\n'
|
||||||
|
* character (0xA) to be written as "\r\n" (0xD, 0xA).
|
||||||
|
*
|
||||||
|
* Example: "rb" opens a binary file for writing; "at" opens a text file for
|
||||||
|
* appending.
|
||||||
*
|
*
|
||||||
* @param file File to open.
|
* @param file File to open.
|
||||||
* @param mode Open mode.
|
* @param mode Open mode.
|
||||||
* @return A Handle to the file, INVALID_HANDLE on open error.
|
* @param use_valve_fs If true, the Valve file system will be used instead.
|
||||||
|
* This can be used to find files existing in valve
|
||||||
|
* search paths, rather than solely files existing directly
|
||||||
|
* in the gamedir.
|
||||||
|
* @param valve_path_id If use_valve_fs, a search path from gameinfo or NULL_STRING for all search paths.
|
||||||
|
* @return A File handle, or null if the file could not be opened.
|
||||||
*/
|
*/
|
||||||
native Handle:OpenFile(const String:file[], const String:mode[]);
|
native File OpenFile(const char[] file, const char[] mode, bool use_valve_fs=false, const char[] valve_path_id="GAME");
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Deletes a file.
|
* Deletes a file.
|
||||||
*
|
*
|
||||||
* @param path Path of the file to delete.
|
* @param path Path of the file to delete.
|
||||||
* @return True on success, false otherwise.
|
* @param use_valve_fs If true, the Valve file system will be used instead.
|
||||||
|
* This can be used to delete files existing in the Valve
|
||||||
|
* search path, rather than solely files existing directly
|
||||||
|
* in the gamedir.
|
||||||
|
* @param valve_path_id If use_valve_fs, a search path from gameinfo or NULL_STRING for all search paths.
|
||||||
|
* @return True on success, false on failure or if file not immediately removed.
|
||||||
*/
|
*/
|
||||||
native bool:DeleteFile(const String:path[]);
|
native bool DeleteFile(const char[] path, bool use_valve_fs=false, const char[] valve_path_id="DEFAULT_WRITE_PATH");
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reads a line from a text file.
|
* Reads a line from a text file.
|
||||||
|
@ -156,7 +342,7 @@ native bool:DeleteFile(const String:path[]);
|
||||||
* @param maxlength Maximum size of string buffer.
|
* @param maxlength Maximum size of string buffer.
|
||||||
* @return True on success, false otherwise.
|
* @return True on success, false otherwise.
|
||||||
*/
|
*/
|
||||||
native bool:ReadFileLine(Handle:hndl, String:buffer[], maxlength);
|
native bool ReadFileLine(Handle hndl, char[] buffer, int maxlength);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reads binary data from a file.
|
* Reads binary data from a file.
|
||||||
|
@ -168,7 +354,7 @@ native bool:ReadFileLine(Handle:hndl, String:buffer[], maxlength);
|
||||||
* Valid sizes are 1, 2, or 4.
|
* Valid sizes are 1, 2, or 4.
|
||||||
* @return Number of elements read, or -1 on error.
|
* @return Number of elements read, or -1 on error.
|
||||||
*/
|
*/
|
||||||
native ReadFile(Handle:hndl, items[], num_items, size);
|
native int ReadFile(Handle hndl, int[] items, int num_items, int size);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reads a UTF8 or ANSI string from a file.
|
* Reads a UTF8 or ANSI string from a file.
|
||||||
|
@ -185,7 +371,7 @@ native ReadFile(Handle:hndl, items[], num_items, size);
|
||||||
* if an error was encountered.
|
* if an error was encountered.
|
||||||
* @error Invalid Handle, or read_count > max_size.
|
* @error Invalid Handle, or read_count > max_size.
|
||||||
*/
|
*/
|
||||||
native ReadFileString(Handle:hndl, String:buffer[], max_size, read_count=-1);
|
native int ReadFileString(Handle hndl, char[] buffer, int max_size, int read_count=-1);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Writes binary data to a file.
|
* Writes binary data to a file.
|
||||||
|
@ -201,7 +387,7 @@ native ReadFileString(Handle:hndl, String:buffer[], max_size, read_count=-1);
|
||||||
* @return True on success, false on error.
|
* @return True on success, false on error.
|
||||||
* @error Invalid Handle.
|
* @error Invalid Handle.
|
||||||
*/
|
*/
|
||||||
native bool:WriteFile(Handle:hndl, const items[], num_items, size);
|
native bool WriteFile(Handle hndl, const int[] items, int num_items, int size);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Writes a binary string to a file.
|
* Writes a binary string to a file.
|
||||||
|
@ -212,7 +398,7 @@ native bool:WriteFile(Handle:hndl, const items[], num_items, size);
|
||||||
* @return True on success, false on error.
|
* @return True on success, false on error.
|
||||||
* @error Invalid Handle.
|
* @error Invalid Handle.
|
||||||
*/
|
*/
|
||||||
native bool:WriteFileString(Handle:hndl, const String:buffer[], bool:term);
|
native bool WriteFileString(Handle hndl, const char[] buffer, bool term);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Writes a line of text to a text file. A newline is automatically appended.
|
* Writes a line of text to a text file. A newline is automatically appended.
|
||||||
|
@ -223,7 +409,7 @@ native bool:WriteFileString(Handle:hndl, const String:buffer[], bool:term);
|
||||||
* @return True on success, false otherwise.
|
* @return True on success, false otherwise.
|
||||||
* @error Invalid Handle.
|
* @error Invalid Handle.
|
||||||
*/
|
*/
|
||||||
native bool:WriteFileLine(Handle:hndl, const String:format[], any:...);
|
native bool WriteFileLine(Handle hndl, const char[] format, any:...);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reads a single binary cell from a file.
|
* Reads a single binary cell from a file.
|
||||||
|
@ -235,14 +421,13 @@ native bool:WriteFileLine(Handle:hndl, const String:format[], any:...);
|
||||||
* @return Number of elements read (max 1), or -1 on error.
|
* @return Number of elements read (max 1), or -1 on error.
|
||||||
* @error Invalid Handle.
|
* @error Invalid Handle.
|
||||||
*/
|
*/
|
||||||
stock ReadFileCell(Handle:hndl, &data, size)
|
stock int ReadFileCell(Handle hndl, int &data, int size)
|
||||||
{
|
{
|
||||||
new array[1], ret;
|
int ret;
|
||||||
|
int array[1];
|
||||||
|
|
||||||
if ((ret = ReadFile(hndl, array, 1, size)) == 1)
|
if ((ret = ReadFile(hndl, array, 1, size)) == 1)
|
||||||
{
|
|
||||||
data = array[0];
|
data = array[0];
|
||||||
}
|
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -260,12 +445,11 @@ stock ReadFileCell(Handle:hndl, &data, size)
|
||||||
* @return True on success, false on error.
|
* @return True on success, false on error.
|
||||||
* @error Invalid Handle.
|
* @error Invalid Handle.
|
||||||
*/
|
*/
|
||||||
stock bool:WriteFileCell(Handle:hndl, data, size)
|
stock bool WriteFileCell(Handle hndl, int data, int size)
|
||||||
{
|
{
|
||||||
new array[1];
|
int array[1];
|
||||||
|
|
||||||
array[0] = data;
|
array[0] = data;
|
||||||
|
|
||||||
return WriteFile(hndl, array, 1, size);
|
return WriteFile(hndl, array, 1, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -276,7 +460,7 @@ stock bool:WriteFileCell(Handle:hndl, data, size)
|
||||||
* @return True if end of file has been reached, false otherwise.
|
* @return True if end of file has been reached, false otherwise.
|
||||||
* @error Invalid Handle.
|
* @error Invalid Handle.
|
||||||
*/
|
*/
|
||||||
native bool:IsEndOfFile(Handle:file);
|
native bool IsEndOfFile(Handle file);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the file position indicator.
|
* Sets the file position indicator.
|
||||||
|
@ -287,7 +471,7 @@ native bool:IsEndOfFile(Handle:file);
|
||||||
* @return True on success, false otherwise.
|
* @return True on success, false otherwise.
|
||||||
* @error Invalid Handle.
|
* @error Invalid Handle.
|
||||||
*/
|
*/
|
||||||
native bool:FileSeek(Handle:file, position, where);
|
native bool FileSeek(Handle file, int position, int where);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get current position in the file.
|
* Get current position in the file.
|
||||||
|
@ -296,7 +480,7 @@ native bool:FileSeek(Handle:file, position, where);
|
||||||
* @return Value for the file position indicator.
|
* @return Value for the file position indicator.
|
||||||
* @error Invalid Handle.
|
* @error Invalid Handle.
|
||||||
*/
|
*/
|
||||||
native FilePosition(Handle:file);
|
native int FilePosition(Handle file);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if a file exists.
|
* Checks if a file exists.
|
||||||
|
@ -304,28 +488,38 @@ native FilePosition(Handle:file);
|
||||||
* @param path Path to the file.
|
* @param path Path to the file.
|
||||||
* @param use_valve_fs If true, the Valve file system will be used instead.
|
* @param use_valve_fs If true, the Valve file system will be used instead.
|
||||||
* This can be used to find files existing in any of
|
* This can be used to find files existing in any of
|
||||||
* the GAME search paths, rather than solely files
|
* the Valve search paths, rather than solely files
|
||||||
* existing directly in the gamedir.
|
* existing directly in the gamedir.
|
||||||
|
* @param valve_path_id If use_valve_fs, a search path from gameinfo or NULL_STRING for all search paths.
|
||||||
* @return True if the file exists, false otherwise.
|
* @return True if the file exists, false otherwise.
|
||||||
*/
|
*/
|
||||||
native bool:FileExists(const String:path[], bool:use_valve_fs=false);
|
native bool FileExists(const char[] path, bool use_valve_fs=false, const char[] valve_path_id="GAME");
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Renames a file.
|
* Renames a file.
|
||||||
*
|
*
|
||||||
* @param newpath New path to the file.
|
* @param newpath New path to the file.
|
||||||
* @param oldpath Path to the existing file.
|
* @param oldpath Path to the existing file.
|
||||||
* @return True on success, false otherwise.
|
* @param use_valve_fs If true, the Valve file system will be used instead.
|
||||||
|
* This can be used to rename files in the game's
|
||||||
|
* Valve search paths, rather than directly in the gamedir.
|
||||||
|
* @param valve_path_id If use_valve_fs, a search path from gameinfo or NULL_STRING for all search paths.
|
||||||
|
* @return True on success or use_valve_fs specified, false otherwise.
|
||||||
*/
|
*/
|
||||||
native bool:RenameFile(const String:newpath[], const String:oldpath[]);
|
native bool RenameFile(const char[] newpath, const char[] oldpath, bool use_valve_fs=false, const char[] valve_path_id="DEFAULT_WRITE_PATH");
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if a directory exists.
|
* Checks if a directory exists.
|
||||||
*
|
*
|
||||||
* @param path Path to the directory.
|
* @param path Path to the directory.
|
||||||
|
* @param use_valve_fs If true, the Valve file system will be used instead.
|
||||||
|
* This can be used to find files existing in any of
|
||||||
|
* the Valve search paths, rather than solely files
|
||||||
|
* existing directly in the gamedir.
|
||||||
|
* @param valve_path_id If use_valve_fs, a search path from gameinfo or NULL_STRING for all search paths.
|
||||||
* @return True if the directory exists, false otherwise.
|
* @return True if the directory exists, false otherwise.
|
||||||
*/
|
*/
|
||||||
native bool:DirExists(const String:path[]);
|
native bool DirExists(const char[] path, bool use_valve_fs=false, const char[] valve_path_id="GAME");
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the file size in bytes.
|
* Get the file size in bytes.
|
||||||
|
@ -333,20 +527,22 @@ native bool:DirExists(const String:path[]);
|
||||||
* @param path Path to the file.
|
* @param path Path to the file.
|
||||||
* @param use_valve_fs If true, the Valve file system will be used instead.
|
* @param use_valve_fs If true, the Valve file system will be used instead.
|
||||||
* This can be used to find files existing in any of
|
* This can be used to find files existing in any of
|
||||||
* the GAME search paths, rather than solely files
|
* the Valve search paths, rather than solely files
|
||||||
* existing directly in the gamedir.
|
* existing directly in the gamedir.
|
||||||
|
* @param valve_path_id If use_valve_fs, a search path from gameinfo or NULL_STRING for all search paths.
|
||||||
* @return File size in bytes, -1 if file not found.
|
* @return File size in bytes, -1 if file not found.
|
||||||
*/
|
*/
|
||||||
native FileSize(const String:path[], bool:use_valve_fs=false);
|
native int FileSize(const char[] path, bool use_valve_fs=false, const char[] valve_path_id="GAME");
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Flushes a file's buffered output; any buffered output
|
* Flushes a file's buffered output; any buffered output
|
||||||
* is immediately written to the file.
|
* is immediately written to the file.
|
||||||
*
|
*
|
||||||
* @param file Handle to the file.
|
* @param file Handle to the file.
|
||||||
* @return True on success, false on failure.
|
* @return True on success or use_valve_fs specified with OpenFile,
|
||||||
|
* otherwise false on failure.
|
||||||
*/
|
*/
|
||||||
native FlushFile(Handle:file);
|
native bool FlushFile(Handle file);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Removes a directory.
|
* Removes a directory.
|
||||||
|
@ -355,7 +551,7 @@ native FlushFile(Handle:file);
|
||||||
* @param path Path to the directory.
|
* @param path Path to the directory.
|
||||||
* @return True on success, false otherwise.
|
* @return True on success, false otherwise.
|
||||||
*/
|
*/
|
||||||
native bool:RemoveDir(const String:path[]);
|
native bool RemoveDir(const char[] path);
|
||||||
|
|
||||||
#define FPERM_U_READ 0x0100 /* User can read. */
|
#define FPERM_U_READ 0x0100 /* User can read. */
|
||||||
#define FPERM_U_WRITE 0x0080 /* User can write. */
|
#define FPERM_U_WRITE 0x0080 /* User can write. */
|
||||||
|
@ -373,8 +569,22 @@ native bool:RemoveDir(const String:path[]);
|
||||||
* @param path Path to create.
|
* @param path Path to create.
|
||||||
* @param mode Permissions (default is o=rx,g=rx,u=rwx). Note that folders must have
|
* @param mode Permissions (default is o=rx,g=rx,u=rwx). Note that folders must have
|
||||||
* the execute bit set on Linux. On Windows, the mode is ignored.
|
* the execute bit set on Linux. On Windows, the mode is ignored.
|
||||||
|
* @param use_valve_fs If true, the Valve file system will be used instead.
|
||||||
|
* This can be used to create folders in the game's
|
||||||
|
* Valve search paths, rather than directly in the gamedir.
|
||||||
|
* @param valve_path_id If use_valve_fs, a search path from gameinfo or NULL_STRING for default.
|
||||||
|
* In this case, mode is ignored.
|
||||||
*/
|
*/
|
||||||
native bool:CreateDirectory(const String:path[], mode);
|
native bool CreateDirectory(const char[] path, int mode, bool use_valve_fs=false, const char[] valve_path_id="DEFAULT_WRITE_PATH");
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Changes a file or directories permissions.
|
||||||
|
*
|
||||||
|
* @param path Path to the file.
|
||||||
|
* @param mode Permissions to set.
|
||||||
|
* @return True on success, false otherwise.
|
||||||
|
*/
|
||||||
|
native bool SetFilePermissions(const String:path[], int mode);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a file timestamp as a unix timestamp.
|
* Returns a file timestamp as a unix timestamp.
|
||||||
|
@ -383,7 +593,7 @@ native bool:CreateDirectory(const String:path[], mode);
|
||||||
* @param tmode Time mode.
|
* @param tmode Time mode.
|
||||||
* @return Time value, or -1 on failure.
|
* @return Time value, or -1 on failure.
|
||||||
*/
|
*/
|
||||||
native GetFileTime(const String:file[], FileTimeMode:tmode);
|
native GetFileTime(const char[] file, FileTimeMode tmode);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Same as LogToFile(), except uses an open file Handle. The file must
|
* Same as LogToFile(), except uses an open file Handle. The file must
|
||||||
|
@ -392,10 +602,9 @@ native GetFileTime(const String:file[], FileTimeMode:tmode);
|
||||||
* @param hndl Handle to the file.
|
* @param hndl Handle to the file.
|
||||||
* @param message Message format.
|
* @param message Message format.
|
||||||
* @param ... Message format parameters.
|
* @param ... Message format parameters.
|
||||||
* @noreturn
|
|
||||||
* @error Invalid Handle.
|
* @error Invalid Handle.
|
||||||
*/
|
*/
|
||||||
native LogToOpenFile(Handle:hndl, const String:message[], any:...);
|
native void LogToOpenFile(Handle hndl, const char[] message, any:...);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Same as LogToFileEx(), except uses an open file Handle. The file must
|
* Same as LogToFileEx(), except uses an open file Handle. The file must
|
||||||
|
@ -404,8 +613,7 @@ native LogToOpenFile(Handle:hndl, const String:message[], any:...);
|
||||||
* @param hndl Handle to the file.
|
* @param hndl Handle to the file.
|
||||||
* @param message Message format.
|
* @param message Message format.
|
||||||
* @param ... Message format parameters.
|
* @param ... Message format parameters.
|
||||||
* @noreturn
|
|
||||||
* @error Invalid Handle.
|
* @error Invalid Handle.
|
||||||
*/
|
*/
|
||||||
native LogToOpenFileEx(Handle:hndl, const String:message[], any:...);
|
native void LogToOpenFileEx(Handle hndl, const char[] message, any:...);
|
||||||
|
|
||||||
|
|
4
env/include/float.inc
vendored
4
env/include/float.inc
vendored
|
@ -35,6 +35,7 @@
|
||||||
#endif
|
#endif
|
||||||
#define _float_included
|
#define _float_included
|
||||||
|
|
||||||
|
#if !defined __sourcepawn2__
|
||||||
/**
|
/**
|
||||||
* Converts an integer into a floating point value.
|
* Converts an integer into a floating point value.
|
||||||
*
|
*
|
||||||
|
@ -42,6 +43,7 @@
|
||||||
* @return Floating point value.
|
* @return Floating point value.
|
||||||
*/
|
*/
|
||||||
native Float:float(value);
|
native Float:float(value);
|
||||||
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Multiplies two floats together.
|
* Multiplies two floats together.
|
||||||
|
@ -244,6 +246,7 @@ stock RoundFloat(Float:value)
|
||||||
* User defined operators.
|
* User defined operators.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
#if !defined __sourcepawn2__
|
||||||
#pragma rational Float
|
#pragma rational Float
|
||||||
|
|
||||||
native bool:__FLOAT_GT__(Float:a, Float:b);
|
native bool:__FLOAT_GT__(Float:a, Float:b);
|
||||||
|
@ -368,6 +371,7 @@ stock bool:operator<=(oper1, Float:oper2)
|
||||||
forward operator%(Float:oper1, Float:oper2);
|
forward operator%(Float:oper1, Float:oper2);
|
||||||
forward operator%(Float:oper1, oper2);
|
forward operator%(Float:oper1, oper2);
|
||||||
forward operator%(oper1, Float:oper2);
|
forward operator%(oper1, Float:oper2);
|
||||||
|
#endif // __sourcepawn2__
|
||||||
|
|
||||||
#define FLOAT_PI 3.1415926535897932384626433832795
|
#define FLOAT_PI 3.1415926535897932384626433832795
|
||||||
|
|
||||||
|
|
13
env/include/functions.inc
vendored
13
env/include/functions.inc
vendored
|
@ -357,7 +357,7 @@ native Call_Cancel();
|
||||||
* @param numParams Number of parameters passed to the native.
|
* @param numParams Number of parameters passed to the native.
|
||||||
* @return Value for the native call to return.
|
* @return Value for the native call to return.
|
||||||
*/
|
*/
|
||||||
functag public NativeCall(Handle:plugin, numParams);
|
typedef NativeCall = function int (Handle plugin, int numParams);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a dynamic native. This should only be called in AskPluginLoad(), or
|
* Creates a dynamic native. This should only be called in AskPluginLoad(), or
|
||||||
|
@ -428,6 +428,15 @@ native SetNativeString(param, const String:source[], maxlength, bool:utf8=true,
|
||||||
*/
|
*/
|
||||||
native any:GetNativeCell(param);
|
native any:GetNativeCell(param);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets a function pointer from a native parameter.
|
||||||
|
*
|
||||||
|
* @param param Parameter number, starting from 1.
|
||||||
|
* @return Function pointer at the given parameter number.
|
||||||
|
* @error Invalid parameter number, or calling from a non-native function.
|
||||||
|
*/
|
||||||
|
native Function GetNativeFunction(param);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets a cell from a native parameter, by reference.
|
* Gets a cell from a native parameter, by reference.
|
||||||
*
|
*
|
||||||
|
@ -499,7 +508,7 @@ native FormatNativeString(out_param,
|
||||||
* @param data Data passed to the RequestFrame native.
|
* @param data Data passed to the RequestFrame native.
|
||||||
* @noreturn
|
* @noreturn
|
||||||
*/
|
*/
|
||||||
functag public RequestFrameCallback(any:data);
|
typedef RequestFrameCallback = function void (any data);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a single use Next Frame hook.
|
* Creates a single use Next Frame hook.
|
||||||
|
|
45
env/include/halflife.inc
vendored
45
env/include/halflife.inc
vendored
|
@ -568,15 +568,15 @@ native ShowHudText(client, channel, const String:message[], any:...);
|
||||||
*/
|
*/
|
||||||
stock ShowMOTDPanel(client, const String:title[], const String:msg[], type=MOTDPANEL_TYPE_INDEX)
|
stock ShowMOTDPanel(client, const String:title[], const String:msg[], type=MOTDPANEL_TYPE_INDEX)
|
||||||
{
|
{
|
||||||
decl String:num[3];
|
char num[3];
|
||||||
new Handle:Kv = CreateKeyValues("data");
|
|
||||||
IntToString(type, num, sizeof(num));
|
IntToString(type, num, sizeof(num));
|
||||||
|
|
||||||
KvSetString(Kv, "title", title);
|
KeyValues kv = new KeyValues("data");
|
||||||
KvSetString(Kv, "type", num);
|
kv.SetString("title", title);
|
||||||
KvSetString(Kv, "msg", msg);
|
kv.SetString("type", num);
|
||||||
ShowVGUIPanel(client, "info", Kv);
|
kv.SetString("msg", msg);
|
||||||
CloseHandle(Kv);
|
ShowVGUIPanel(client, "info", kv);
|
||||||
|
delete kv;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -590,13 +590,14 @@ stock ShowMOTDPanel(client, const String:title[], const String:msg[], type=MOTDP
|
||||||
*/
|
*/
|
||||||
stock DisplayAskConnectBox(client, Float:time, const String:ip[], const String:password[] = "")
|
stock DisplayAskConnectBox(client, Float:time, const String:ip[], const String:password[] = "")
|
||||||
{
|
{
|
||||||
decl String:destination[288];
|
char destination[288];
|
||||||
FormatEx(destination, sizeof(destination), "%s/%s", ip, password);
|
FormatEx(destination, sizeof(destination), "%s/%s", ip, password);
|
||||||
new Handle:Kv = CreateKeyValues("data");
|
|
||||||
KvSetFloat(Kv, "time", time);
|
KeyValues kv = new KeyValues("data");
|
||||||
KvSetString(Kv, "title", destination);
|
kv.SetFloat("time", time);
|
||||||
CreateDialog(client, Kv, DialogType_AskConnect);
|
kv.SetString("title", destination);
|
||||||
CloseHandle(Kv);
|
CreateDialog(client, kv, DialogType_AskConnect);
|
||||||
|
delete kv;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -623,3 +624,21 @@ native EntRefToEntIndex(ref);
|
||||||
*/
|
*/
|
||||||
native MakeCompatEntRef(ref);
|
native MakeCompatEntRef(ref);
|
||||||
|
|
||||||
|
|
||||||
|
enum ClientRangeType
|
||||||
|
{
|
||||||
|
RangeType_Visibility = 0,
|
||||||
|
RangeType_Audibility,
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Find clients that are potentially in range of a position.
|
||||||
|
*
|
||||||
|
* @param origin Coordinates from which to test range.
|
||||||
|
* @param rangeType Range type to use for filtering clients.
|
||||||
|
* @param clients Array to which found client indexes will be written.
|
||||||
|
* @param size Maximum size of clients array.
|
||||||
|
* @return Number of client indexes written to clients array.
|
||||||
|
*/
|
||||||
|
native int GetClientsInRange(float origin[3], ClientRangeType rangeType, int[] clients, int size);
|
||||||
|
|
||||||
|
|
16
env/include/handles.inc
vendored
16
env/include/handles.inc
vendored
|
@ -36,9 +36,9 @@
|
||||||
#define _handles_included
|
#define _handles_included
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handle helper macros.
|
* Preset Handle values.
|
||||||
*/
|
*/
|
||||||
enum Handle
|
enum Handle: // Tag disables introducing "Handle" as a symbol.
|
||||||
{
|
{
|
||||||
INVALID_HANDLE = 0,
|
INVALID_HANDLE = 0,
|
||||||
};
|
};
|
||||||
|
@ -52,10 +52,9 @@ enum Handle
|
||||||
* sure you read the documentation on whatever provided the Handle.
|
* sure you read the documentation on whatever provided the Handle.
|
||||||
*
|
*
|
||||||
* @param hndl Handle to close.
|
* @param hndl Handle to close.
|
||||||
* @return True if successful, false if not closeable.
|
|
||||||
* @error Invalid handles will cause a run time error.
|
* @error Invalid handles will cause a run time error.
|
||||||
*/
|
*/
|
||||||
native bool:CloseHandle(Handle:hndl);
|
native CloseHandle(Handle:hndl);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Clones a Handle. When passing handles in between plugins, caching handles
|
* Clones a Handle. When passing handles in between plugins, caching handles
|
||||||
|
@ -76,6 +75,15 @@ native bool:CloseHandle(Handle:hndl);
|
||||||
*/
|
*/
|
||||||
native Handle:CloneHandle(Handle:hndl, Handle:plugin=INVALID_HANDLE);
|
native Handle:CloneHandle(Handle:hndl, Handle:plugin=INVALID_HANDLE);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Helper for object-oriented syntax.
|
||||||
|
*/
|
||||||
|
methodmap Handle __nullable__
|
||||||
|
{
|
||||||
|
public Close() = CloseHandle;
|
||||||
|
public ~Handle() = CloseHandle;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Do not use this function. Returns if a Handle and its contents
|
* Do not use this function. Returns if a Handle and its contents
|
||||||
* are readable, whereas INVALID_HANDLE only checks for the absence
|
* are readable, whereas INVALID_HANDLE only checks for the absence
|
||||||
|
|
53
env/include/helpers.inc
vendored
53
env/include/helpers.inc
vendored
|
@ -97,59 +97,45 @@ stock Handle:FindPluginByFile(const String:filename[])
|
||||||
* @deprecated Use FindTarget() or ProcessTargetString().
|
* @deprecated Use FindTarget() or ProcessTargetString().
|
||||||
*/
|
*/
|
||||||
#pragma deprecated Use FindTarget() or ProcessTargetString()
|
#pragma deprecated Use FindTarget() or ProcessTargetString()
|
||||||
stock SearchForClients(const String:pattern[], clients[], maxClients)
|
stock int SearchForClients(const char[] pattern, int[] clients, int maxClients)
|
||||||
{
|
{
|
||||||
new total = 0;
|
int total = 0;
|
||||||
|
|
||||||
if (maxClients == 0)
|
if (maxClients == 0)
|
||||||
{
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
|
||||||
|
|
||||||
if (pattern[0] == '#')
|
if (pattern[0] == '#') {
|
||||||
{
|
int input = StringToInt(pattern[1]);
|
||||||
new input = StringToInt(pattern[1]);
|
if (!input) {
|
||||||
if (!input)
|
char name[65];
|
||||||
{
|
for (int i=1; i<=MaxClients; i++) {
|
||||||
decl String:name[65]
|
|
||||||
for (new i=1; i<=MaxClients; i++)
|
|
||||||
{
|
|
||||||
if (!IsClientInGame(i))
|
if (!IsClientInGame(i))
|
||||||
{
|
|
||||||
continue;
|
continue;
|
||||||
}
|
|
||||||
GetClientName(i, name, sizeof(name));
|
GetClientName(i, name, sizeof(name));
|
||||||
if (strcmp(name, pattern, false) == 0)
|
if (strcmp(name, pattern, false) == 0) {
|
||||||
{
|
|
||||||
clients[0] = i;
|
clients[0] = i;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
new client = GetClientOfUserId(input);
|
int client = GetClientOfUserId(input);
|
||||||
if (client)
|
if (client) {
|
||||||
{
|
|
||||||
clients[0] = client;
|
clients[0] = client;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
decl String:name[65]
|
char name[65];
|
||||||
for (new i=1; i<=MaxClients; i++)
|
for (int i=1; i<=MaxClients; i++)
|
||||||
{
|
{
|
||||||
if (!IsClientInGame(i))
|
if (!IsClientInGame(i))
|
||||||
{
|
|
||||||
continue;
|
continue;
|
||||||
}
|
|
||||||
GetClientName(i, name, sizeof(name));
|
GetClientName(i, name, sizeof(name));
|
||||||
if (StrContains(name, pattern, false) != -1)
|
if (StrContains(name, pattern, false) != -1) {
|
||||||
{
|
|
||||||
clients[total++] = i;
|
clients[total++] = i;
|
||||||
if (total >= maxClients)
|
if (total >= maxClients)
|
||||||
{
|
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -255,18 +241,17 @@ stock FindTarget(client, const String:target[], bool:nobots = false, bool:immuni
|
||||||
|
|
||||||
ClearArray(array);
|
ClearArray(array);
|
||||||
|
|
||||||
new Handle:file = OpenFile(mapPath, "rt");
|
File file = OpenFile(mapPath, "rt");
|
||||||
if (file == INVALID_HANDLE)
|
if (!file) {
|
||||||
{
|
|
||||||
LogError("Could not open file: %s", mapPath);
|
LogError("Could not open file: %s", mapPath);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
LogMessage("Loading maps from file: %s", mapPath);
|
LogMessage("Loading maps from file: %s", mapPath);
|
||||||
|
|
||||||
decl String:buffer[64], len;
|
int len;
|
||||||
while (!IsEndOfFile(file) && ReadFileLine(file, buffer, sizeof(buffer)))
|
char buffer[64];
|
||||||
|
while (!file.EndOfFile() && file.ReadLine(buffer, sizeof(buffer)))
|
||||||
{
|
{
|
||||||
TrimString(buffer);
|
TrimString(buffer);
|
||||||
|
|
||||||
|
@ -288,6 +273,6 @@ stock FindTarget(client, const String:target[], bool:nobots = false, bool:immuni
|
||||||
PushArrayString(array, buffer);
|
PushArrayString(array, buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
CloseHandle(file);
|
file.Close();
|
||||||
return GetArraySize(array);
|
return GetArraySize(array);
|
||||||
}
|
}
|
||||||
|
|
366
env/include/keyvalues.inc
vendored
366
env/include/keyvalues.inc
vendored
|
@ -1,7 +1,7 @@
|
||||||
/**
|
/**
|
||||||
* vim: set ts=4 :
|
* vim: set ts=4 sw=4 tw=99 noet :
|
||||||
* =============================================================================
|
* =============================================================================
|
||||||
* SourceMod (C)2004-2008 AlliedModders LLC. All rights reserved.
|
* SourceMod (C)2004-2014 AlliedModders LLC. All rights reserved.
|
||||||
* =============================================================================
|
* =============================================================================
|
||||||
*
|
*
|
||||||
* This file is part of the SourceMod/SourcePawn SDK.
|
* This file is part of the SourceMod/SourcePawn SDK.
|
||||||
|
@ -52,6 +52,275 @@ enum KvDataTypes
|
||||||
KvData_NUMTYPES,
|
KvData_NUMTYPES,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
methodmap KeyValues < Handle
|
||||||
|
{
|
||||||
|
// Creates a new KeyValues structure. The Handle must be closed with
|
||||||
|
// CloseHandle() or delete.
|
||||||
|
//
|
||||||
|
// @param name Name of the root section.
|
||||||
|
// @param firstKey If non-empty, specifies the first key value.
|
||||||
|
// @param firstValue If firstKey is non-empty, specifies the first key's value.
|
||||||
|
public native KeyValues(const char[] name, const char[] firstKey="", const char[] firstValue="");
|
||||||
|
|
||||||
|
// Exports a KeyValues tree to a file. The tree is dumped from the current position.
|
||||||
|
//
|
||||||
|
// @param file File to dump write to.
|
||||||
|
// @return True on success, false otherwise.
|
||||||
|
public native bool ExportToFile(const char[] file);
|
||||||
|
|
||||||
|
// Imports a file in KeyValues format. The file is read into the current
|
||||||
|
// position of the tree.
|
||||||
|
//
|
||||||
|
// @param file File to read from.
|
||||||
|
// @return True on success, false otherwise.
|
||||||
|
public native bool ImportFromFile(const char[] file);
|
||||||
|
|
||||||
|
// Converts a given string to a KeyValues tree. The string is read into
|
||||||
|
// the current postion of the tree.
|
||||||
|
//
|
||||||
|
// @param buffer String buffer to load into the KeyValues.
|
||||||
|
// @param resourceName The resource name of the KeyValues, used for error tracking purposes.
|
||||||
|
// @return True on success, false otherwise.
|
||||||
|
public native bool ImportFromString(const char[] buffer, const char[] resourceName="StringToKeyValues");
|
||||||
|
|
||||||
|
// Imports subkeys in the given KeyValues, at the current position in that
|
||||||
|
// KeyValues, into the current position in this KeyValues. Note that this
|
||||||
|
// copies keys; it does not embed a reference to them.
|
||||||
|
//
|
||||||
|
// @param other Origin KeyValues Handle.
|
||||||
|
public native void Import(KeyValues other);
|
||||||
|
|
||||||
|
// Sets a string value of a KeyValues key.
|
||||||
|
//
|
||||||
|
// @param kv KeyValues Handle.
|
||||||
|
// @param key Name of the key, or NULL_STRING.
|
||||||
|
// @param value String value.
|
||||||
|
public native void SetString(const char[] key, const char[] value);
|
||||||
|
|
||||||
|
// Sets an integer value of a KeyValues key.
|
||||||
|
//
|
||||||
|
// @param key Name of the key, or NULL_STRING.
|
||||||
|
// @param value Value number.
|
||||||
|
public native void SetNum(const char[] key, int value);
|
||||||
|
|
||||||
|
// Sets a large integer value of a KeyValues key.
|
||||||
|
//
|
||||||
|
// @param key Name of the key, or NULL_STRING.
|
||||||
|
// @param value Large integer value (0=High bits, 1=Low bits)
|
||||||
|
public native void SetUInt64(const char[] key, const value[2]);
|
||||||
|
|
||||||
|
// Sets a floating point value of a KeyValues key.
|
||||||
|
//
|
||||||
|
// @param key Name of the key, or NULL_STRING.
|
||||||
|
// @param value Floating point value.
|
||||||
|
public native void SetFloat(const char[] key, float value);
|
||||||
|
|
||||||
|
// Sets a set of color values of a KeyValues key.
|
||||||
|
//
|
||||||
|
// @param key Name of the key, or NULL_STRING.
|
||||||
|
// @param r Red value.
|
||||||
|
// @param g Green value.
|
||||||
|
// @param b Blue value.
|
||||||
|
// @param a Alpha value.
|
||||||
|
public native void SetColor(const char[] key, int r, int g, int b, int a=0);
|
||||||
|
|
||||||
|
// Sets a set of color values of a KeyValues key.
|
||||||
|
//
|
||||||
|
// @param key Name of the key, or NULL_STRING.
|
||||||
|
// @param color Red, green, blue and alpha channels.
|
||||||
|
public void SetColor4(const char[] key, const int color[4]) {
|
||||||
|
this.SetColor(key, color[0], color[1], color[2], color[3]);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Sets a vector value of a KeyValues key.
|
||||||
|
//
|
||||||
|
// @param key Name of the key, or NULL_STRING.
|
||||||
|
// @param vec Vector value.
|
||||||
|
public native void SetVector(const char[] key, const float vec[3]);
|
||||||
|
|
||||||
|
// Retrieves a string value from a KeyValues key.
|
||||||
|
//
|
||||||
|
// @param key Name of the key, or NULL_STRING.
|
||||||
|
// @param value Buffer to store key value in.
|
||||||
|
// @param maxlength Maximum length of the value buffer.
|
||||||
|
// @param defvalue Optional default value to use if the key is not found.
|
||||||
|
public native void GetString(const char[] key, char[] value, int maxlength, const char[] defvalue="");
|
||||||
|
|
||||||
|
// Retrieves an integer value from a KeyValues key.
|
||||||
|
//
|
||||||
|
// @param key Name of the key, or NULL_STRING.
|
||||||
|
// @param defvalue Optional default value to use if the key is not found.
|
||||||
|
// @return Integer value of the key.
|
||||||
|
public native int GetNum(const char[] key, int defvalue=0);
|
||||||
|
|
||||||
|
// Retrieves a floating point value from a KeyValues key.
|
||||||
|
//
|
||||||
|
// @param key Name of the key, or NULL_STRING.
|
||||||
|
// @param defvalue Optional default value to use if the key is not found.
|
||||||
|
// @return Floating point value of the key.
|
||||||
|
public native float GetFloat(const char[] key, float defvalue=0.0);
|
||||||
|
|
||||||
|
// Retrieves a set of color values from a KeyValues key.
|
||||||
|
//
|
||||||
|
// @param key Name of the key, or NULL_STRING.
|
||||||
|
// @param r Red value, set by reference.
|
||||||
|
// @param g Green value, set by reference.
|
||||||
|
// @param b Blue value, set by reference.
|
||||||
|
// @param a Alpha value, set by reference.
|
||||||
|
public native void GetColor(const char[] key, &r, &g, &b, &a);
|
||||||
|
|
||||||
|
// Retrives a set of color values from a KeyValues key.
|
||||||
|
//
|
||||||
|
// @param key Name of the key, or NULL_STRING.
|
||||||
|
// @param color Red, green, blue, and alpha channels.
|
||||||
|
public void GetColor4(const char[] key, int color[4]) {
|
||||||
|
int r, g, b, a;
|
||||||
|
this.GetColor(key, r, g, b, a);
|
||||||
|
color[0] = r;
|
||||||
|
color[1] = g;
|
||||||
|
color[2] = b;
|
||||||
|
color[3] = a;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Retrieves a large integer value from a KeyValues key.
|
||||||
|
//
|
||||||
|
// @param key Name of the key, or NULL_STRING.
|
||||||
|
// @param value Array to represent the large integer.
|
||||||
|
// @param defvalue Optional default value to use if the key is not found.
|
||||||
|
public native void GetUInt64(const char[] key, int value[2], int defvalue[2]={0,0});
|
||||||
|
|
||||||
|
// Retrieves a vector value from a KeyValues key.
|
||||||
|
//
|
||||||
|
// @param key Name of the key, or NULL_STRING.
|
||||||
|
// @param vec Destination vector to store the value in.
|
||||||
|
// @param defvalue Optional default value to use if the key is not found.
|
||||||
|
public native void GetVector(const char[] key, float vec[3], const float defvalue[3]={0.0, 0.0, 0.0});
|
||||||
|
|
||||||
|
// Sets the current position in the KeyValues tree to the given key.
|
||||||
|
//
|
||||||
|
// @param key Name of the key.
|
||||||
|
// @param create If true, and the key does not exist, it will be created.
|
||||||
|
// @return True if the key exists, false if it does not and was not created.
|
||||||
|
public native bool JumpToKey(const char[] key, bool create=false);
|
||||||
|
|
||||||
|
// Sets the current position in the KeyValues tree to the given key.
|
||||||
|
//
|
||||||
|
// @param id KeyValues id.
|
||||||
|
// @return True if the key exists, false if it does not.
|
||||||
|
public native bool JumpToKeySymbol(int id);
|
||||||
|
|
||||||
|
// Sets the current position in the KeyValues tree to the first sub key.
|
||||||
|
// This native adds to the internal traversal stack.
|
||||||
|
//
|
||||||
|
// @param keyOnly If false, non-keys will be traversed (values).
|
||||||
|
// @return True on success, false if there was no first sub key.
|
||||||
|
public native bool GotoFirstSubKey(bool keyOnly=true);
|
||||||
|
|
||||||
|
// Sets the current position in the KeyValues tree to the next sub key.
|
||||||
|
// This native does NOT add to the internal traversal stack, and thus
|
||||||
|
// GoBack() is not needed for each successive call to this function.
|
||||||
|
//
|
||||||
|
// @param keyOnly If false, non-keys will be traversed (values).
|
||||||
|
// @return True on success, false if there was no next sub key.
|
||||||
|
public native bool GotoNextKey(bool keyOnly=true);
|
||||||
|
|
||||||
|
// Saves the current position in the traversal stack onto the traversal
|
||||||
|
// stack. This can be useful if you wish to use KvGotoNextKey() and
|
||||||
|
// have the previous key saved for backwards traversal.
|
||||||
|
//
|
||||||
|
// @param kv KeyValues Handle.
|
||||||
|
public native void SavePosition();
|
||||||
|
|
||||||
|
// Jumps back to the previous position. Returns false if there are no
|
||||||
|
// previous positions (i.e., at the root node). This should be called
|
||||||
|
// once for each successful Jump call, in order to return to the top node.
|
||||||
|
// This function pops one node off the internal traversal stack.
|
||||||
|
//
|
||||||
|
// @return True on success, false if there is no higher node.
|
||||||
|
public native bool GoBack();
|
||||||
|
|
||||||
|
// Removes the given key from the current position.
|
||||||
|
//
|
||||||
|
// @param key Name of the key.
|
||||||
|
// @return True on success, false if key did not exist.
|
||||||
|
public native bool DeleteKey(const char[] key);
|
||||||
|
|
||||||
|
// Removes the current sub-key and attempts to set the position
|
||||||
|
// to the sub-key after the removed one. If no such sub-key exists,
|
||||||
|
// the position will be the parent key in the traversal stack.
|
||||||
|
// Given the sub-key having position "N" in the traversal stack, the
|
||||||
|
// removal will always take place from position "N-1."
|
||||||
|
//
|
||||||
|
// @param kv KeyValues Handle.
|
||||||
|
// @return 1 if removal succeeded and there was another key.
|
||||||
|
// 0 if the current node was not contained in the
|
||||||
|
// previous node, or no previous node exists.
|
||||||
|
// -1 if removal succeeded and there were no more keys,
|
||||||
|
// thus the state is as if KvGoBack() was called.
|
||||||
|
public native int DeleteThis();
|
||||||
|
|
||||||
|
// Sets the position back to the top node, emptying the entire node
|
||||||
|
// traversal history. This can be used instead of looping KvGoBack()
|
||||||
|
// if recursive iteration is not important.
|
||||||
|
//
|
||||||
|
// @param kv KeyValues Handle.
|
||||||
|
public native void Rewind();
|
||||||
|
|
||||||
|
// Retrieves the current section name.
|
||||||
|
//
|
||||||
|
// @param section Buffer to store the section name.
|
||||||
|
// @param maxlength Maximum length of the name buffer.
|
||||||
|
// @return True on success, false on failure.
|
||||||
|
public native bool GetSectionName(char[] section, int maxlength);
|
||||||
|
|
||||||
|
// Sets the current section name.
|
||||||
|
//
|
||||||
|
// @param section Section name.
|
||||||
|
public native void SetSectionName(const char[] section);
|
||||||
|
|
||||||
|
// Returns the data type at a key.
|
||||||
|
//
|
||||||
|
// @param key Key name.
|
||||||
|
// @return KvDataType value of the key.
|
||||||
|
public native KvDataTypes GetDataType(const char[] key);
|
||||||
|
|
||||||
|
// Sets whether or not the KeyValues parser will read escape sequences.
|
||||||
|
// For example, \n would be read as a literal newline. This defaults
|
||||||
|
// to false for new KeyValues structures.
|
||||||
|
//
|
||||||
|
// @param useEscapes Whether or not to read escape sequences.
|
||||||
|
public native void SetEscapeSequences(bool useEscapes);
|
||||||
|
|
||||||
|
// Returns the position in the jump stack; I.e. the number of calls
|
||||||
|
// required for KvGoBack to return to the root node. If at the root node,
|
||||||
|
// 0 is returned.
|
||||||
|
//
|
||||||
|
// @return Number of non-root nodes in the jump stack.
|
||||||
|
public native int NodesInStack();
|
||||||
|
|
||||||
|
// Finds a KeyValues name by id.
|
||||||
|
//
|
||||||
|
// @param id KeyValues id.
|
||||||
|
// @param name Buffer to store the name.
|
||||||
|
// @param maxlength Maximum length of the value buffer.
|
||||||
|
// @return True on success, false if id not found.
|
||||||
|
public native bool FindKeyById(int id, char[] name, int maxlength);
|
||||||
|
|
||||||
|
// Finds a KeyValues id inside a KeyValues tree.
|
||||||
|
//
|
||||||
|
// @param key Key name.
|
||||||
|
// @param id Id of the found KeyValue.
|
||||||
|
// @return True on success, false if key not found.
|
||||||
|
public native bool GetNameSymbol(const char[] key, int &id);
|
||||||
|
|
||||||
|
// Retrieves the current section id.
|
||||||
|
//
|
||||||
|
// @param kv KeyValues Handle.
|
||||||
|
// @param id Id of the current section.
|
||||||
|
// @return True on success, false on failure.
|
||||||
|
public native bool GetSectionSymbol(int &id);
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new KeyValues structure. The Handle must always be closed.
|
* Creates a new KeyValues structure. The Handle must always be closed.
|
||||||
*
|
*
|
||||||
|
@ -60,7 +329,7 @@ enum KvDataTypes
|
||||||
* @param firstValue If firstKey is non-empty, specifies the first key's value.
|
* @param firstValue If firstKey is non-empty, specifies the first key's value.
|
||||||
* @return A Handle to a new KeyValues structure.
|
* @return A Handle to a new KeyValues structure.
|
||||||
*/
|
*/
|
||||||
native Handle:CreateKeyValues(const String:name[], const String:firstKey[]="", const String:firstValue[]="");
|
native KeyValues CreateKeyValues(const char[] name, const char[] firstKey="", const char[] firstValue="");
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets a string value of a KeyValues key.
|
* Sets a string value of a KeyValues key.
|
||||||
|
@ -68,10 +337,9 @@ native Handle:CreateKeyValues(const String:name[], const String:firstKey[]="", c
|
||||||
* @param kv KeyValues Handle.
|
* @param kv KeyValues Handle.
|
||||||
* @param key Name of the key, or NULL_STRING.
|
* @param key Name of the key, or NULL_STRING.
|
||||||
* @param value String value.
|
* @param value String value.
|
||||||
* @noreturn
|
|
||||||
* @error Invalid Handle.
|
* @error Invalid Handle.
|
||||||
*/
|
*/
|
||||||
native KvSetString(Handle:kv, const String:key[], const String:value[]);
|
native void KvSetString(Handle kv, const char[] key, const char[] value);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets an integer value of a KeyValues key.
|
* Sets an integer value of a KeyValues key.
|
||||||
|
@ -79,10 +347,9 @@ native KvSetString(Handle:kv, const String:key[], const String:value[]);
|
||||||
* @param kv KeyValues Handle.
|
* @param kv KeyValues Handle.
|
||||||
* @param key Name of the key, or NULL_STRING.
|
* @param key Name of the key, or NULL_STRING.
|
||||||
* @param value Value number.
|
* @param value Value number.
|
||||||
* @noreturn
|
|
||||||
* @error Invalid Handle.
|
* @error Invalid Handle.
|
||||||
*/
|
*/
|
||||||
native KvSetNum(Handle:kv, const String:key[], value);
|
native void KvSetNum(Handle kv, const char[] key, int value);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets a large integer value of a KeyValues key.
|
* Sets a large integer value of a KeyValues key.
|
||||||
|
@ -90,10 +357,9 @@ native KvSetNum(Handle:kv, const String:key[], value);
|
||||||
* @param kv KeyValues Handle.
|
* @param kv KeyValues Handle.
|
||||||
* @param key Name of the key, or NULL_STRING.
|
* @param key Name of the key, or NULL_STRING.
|
||||||
* @param value Large integer value (0=High bits, 1=Low bits)
|
* @param value Large integer value (0=High bits, 1=Low bits)
|
||||||
* @noreturn
|
|
||||||
* @error Invalid Handle.
|
* @error Invalid Handle.
|
||||||
*/
|
*/
|
||||||
native KvSetUInt64(Handle:kv, const String:key[], const value[2]);
|
native void KvSetUInt64(Handle kv, const char[] key, const value[2]);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets a floating point value of a KeyValues key.
|
* Sets a floating point value of a KeyValues key.
|
||||||
|
@ -101,10 +367,9 @@ native KvSetUInt64(Handle:kv, const String:key[], const value[2]);
|
||||||
* @param kv KeyValues Handle.
|
* @param kv KeyValues Handle.
|
||||||
* @param key Name of the key, or NULL_STRING.
|
* @param key Name of the key, or NULL_STRING.
|
||||||
* @param value Floating point value.
|
* @param value Floating point value.
|
||||||
* @noreturn
|
|
||||||
* @error Invalid Handle.
|
* @error Invalid Handle.
|
||||||
*/
|
*/
|
||||||
native KvSetFloat(Handle:kv, const String:key[], Float:value);
|
native void KvSetFloat(Handle kv, const char[] key, float value);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets a set of color values of a KeyValues key.
|
* Sets a set of color values of a KeyValues key.
|
||||||
|
@ -115,10 +380,9 @@ native KvSetFloat(Handle:kv, const String:key[], Float:value);
|
||||||
* @param g Green value.
|
* @param g Green value.
|
||||||
* @param b Blue value.
|
* @param b Blue value.
|
||||||
* @param a Alpha value.
|
* @param a Alpha value.
|
||||||
* @noreturn
|
|
||||||
* @error Invalid Handle.
|
* @error Invalid Handle.
|
||||||
*/
|
*/
|
||||||
native KvSetColor(Handle:kv, const String:key[], r, g, b, a=0);
|
native void KvSetColor(Handle kv, const char[] key, int r, int g, int b, int a=0);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets a vector value of a KeyValues key.
|
* Sets a vector value of a KeyValues key.
|
||||||
|
@ -126,10 +390,9 @@ native KvSetColor(Handle:kv, const String:key[], r, g, b, a=0);
|
||||||
* @param kv KeyValues Handle.
|
* @param kv KeyValues Handle.
|
||||||
* @param key Name of the key, or NULL_STRING.
|
* @param key Name of the key, or NULL_STRING.
|
||||||
* @param vec Vector value.
|
* @param vec Vector value.
|
||||||
* @noreturn
|
|
||||||
* @error Invalid Handle.
|
* @error Invalid Handle.
|
||||||
*/
|
*/
|
||||||
native KvSetVector(Handle:kv, const String:key[], const Float:vec[3]);
|
native void KvSetVector(Handle kv, const char[] key, const float vec[3]);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieves a string value from a KeyValues key.
|
* Retrieves a string value from a KeyValues key.
|
||||||
|
@ -139,10 +402,9 @@ native KvSetVector(Handle:kv, const String:key[], const Float:vec[3]);
|
||||||
* @param value Buffer to store key value in.
|
* @param value Buffer to store key value in.
|
||||||
* @param maxlength Maximum length of the value buffer.
|
* @param maxlength Maximum length of the value buffer.
|
||||||
* @param defvalue Optional default value to use if the key is not found.
|
* @param defvalue Optional default value to use if the key is not found.
|
||||||
* @noreturn
|
|
||||||
* @error Invalid Handle.
|
* @error Invalid Handle.
|
||||||
*/
|
*/
|
||||||
native KvGetString(Handle:kv, const String:key[], String:value[], maxlength, const String:defvalue[]="");
|
native void KvGetString(Handle kv, const char[] key, char[] value, int maxlength, const char[] defvalue="");
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieves an integer value from a KeyValues key.
|
* Retrieves an integer value from a KeyValues key.
|
||||||
|
@ -153,7 +415,7 @@ native KvGetString(Handle:kv, const String:key[], String:value[], maxlength, con
|
||||||
* @return Integer value of the key.
|
* @return Integer value of the key.
|
||||||
* @error Invalid Handle.
|
* @error Invalid Handle.
|
||||||
*/
|
*/
|
||||||
native KvGetNum(Handle:kv, const String:key[], defvalue=0);
|
native int KvGetNum(Handle kv, const char[] key, int defvalue=0);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieves a floating point value from a KeyValues key.
|
* Retrieves a floating point value from a KeyValues key.
|
||||||
|
@ -164,7 +426,7 @@ native KvGetNum(Handle:kv, const String:key[], defvalue=0);
|
||||||
* @return Floating point value of the key.
|
* @return Floating point value of the key.
|
||||||
* @error Invalid Handle.
|
* @error Invalid Handle.
|
||||||
*/
|
*/
|
||||||
native Float:KvGetFloat(Handle:kv, const String:key[], Float:defvalue=0.0);
|
native float KvGetFloat(Handle kv, const char[] key, float defvalue=0.0);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieves a set of color values from a KeyValues key.
|
* Retrieves a set of color values from a KeyValues key.
|
||||||
|
@ -175,10 +437,9 @@ native Float:KvGetFloat(Handle:kv, const String:key[], Float:defvalue=0.0);
|
||||||
* @param g Green value, set by reference.
|
* @param g Green value, set by reference.
|
||||||
* @param b Blue value, set by reference.
|
* @param b Blue value, set by reference.
|
||||||
* @param a Alpha value, set by reference.
|
* @param a Alpha value, set by reference.
|
||||||
* @noreturn
|
|
||||||
* @error Invalid Handle.
|
* @error Invalid Handle.
|
||||||
*/
|
*/
|
||||||
native KvGetColor(Handle:kv, const String:key[], &r, &g, &b, &a);
|
native void KvGetColor(Handle kv, const char[] key, int &r, int &g, int &b, int &a);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieves a large integer value from a KeyValues key.
|
* Retrieves a large integer value from a KeyValues key.
|
||||||
|
@ -187,10 +448,9 @@ native KvGetColor(Handle:kv, const String:key[], &r, &g, &b, &a);
|
||||||
* @param key Name of the key, or NULL_STRING.
|
* @param key Name of the key, or NULL_STRING.
|
||||||
* @param value Array to represent the large integer.
|
* @param value Array to represent the large integer.
|
||||||
* @param defvalue Optional default value to use if the key is not found.
|
* @param defvalue Optional default value to use if the key is not found.
|
||||||
* @noreturn
|
|
||||||
* @error Invalid Handle.
|
* @error Invalid Handle.
|
||||||
*/
|
*/
|
||||||
native KvGetUInt64(Handle:kv, const String:key[], value[2], defvalue[2]={0,0});
|
native void KvGetUInt64(Handle kv, const char[] key, int value[2], int defvalue[2]={0,0});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieves a vector value from a KeyValues key.
|
* Retrieves a vector value from a KeyValues key.
|
||||||
|
@ -199,10 +459,9 @@ native KvGetUInt64(Handle:kv, const String:key[], value[2], defvalue[2]={0,0});
|
||||||
* @param key Name of the key, or NULL_STRING.
|
* @param key Name of the key, or NULL_STRING.
|
||||||
* @param vec Destination vector to store the value in.
|
* @param vec Destination vector to store the value in.
|
||||||
* @param defvalue Optional default value to use if the key is not found.
|
* @param defvalue Optional default value to use if the key is not found.
|
||||||
* @noreturn
|
|
||||||
* @error Invalid Handle.
|
* @error Invalid Handle.
|
||||||
*/
|
*/
|
||||||
native KvGetVector(Handle:kv, const String:key[], Float:vec[3], const Float:defvalue[3]={0.0, 0.0, 0.0});
|
native void KvGetVector(Handle kv, const char[] key, float vec[3], const float defvalue[3]={0.0, 0.0, 0.0});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the current position in the KeyValues tree to the given key.
|
* Sets the current position in the KeyValues tree to the given key.
|
||||||
|
@ -212,7 +471,7 @@ native KvGetVector(Handle:kv, const String:key[], Float:vec[3], const Float:defv
|
||||||
* @param create If true, and the key does not exist, it will be created.
|
* @param create If true, and the key does not exist, it will be created.
|
||||||
* @return True if the key exists, false if it does not and was not created.
|
* @return True if the key exists, false if it does not and was not created.
|
||||||
*/
|
*/
|
||||||
native bool:KvJumpToKey(Handle:kv, const String:key[], bool:create=false);
|
native bool KvJumpToKey(Handle kv, const char[] key, bool create=false);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the current position in the KeyValues tree to the given key.
|
* Sets the current position in the KeyValues tree to the given key.
|
||||||
|
@ -221,7 +480,7 @@ native bool:KvJumpToKey(Handle:kv, const String:key[], bool:create=false);
|
||||||
* @param id KeyValues id.
|
* @param id KeyValues id.
|
||||||
* @return True if the key exists, false if it does not.
|
* @return True if the key exists, false if it does not.
|
||||||
*/
|
*/
|
||||||
native bool:KvJumpToKeySymbol(Handle:kv, id);
|
native bool KvJumpToKeySymbol(Handle kv, int id);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the current position in the KeyValues tree to the first sub key.
|
* Sets the current position in the KeyValues tree to the first sub key.
|
||||||
|
@ -232,7 +491,7 @@ native bool:KvJumpToKeySymbol(Handle:kv, id);
|
||||||
* @return True on success, false if there was no first sub key.
|
* @return True on success, false if there was no first sub key.
|
||||||
* @error Invalid Handle.
|
* @error Invalid Handle.
|
||||||
*/
|
*/
|
||||||
native bool:KvGotoFirstSubKey(Handle:kv, bool:keyOnly=true);
|
native bool KvGotoFirstSubKey(Handle kv, bool keyOnly=true);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the current position in the KeyValues tree to the next sub key.
|
* Sets the current position in the KeyValues tree to the next sub key.
|
||||||
|
@ -244,7 +503,7 @@ native bool:KvGotoFirstSubKey(Handle:kv, bool:keyOnly=true);
|
||||||
* @return True on success, false if there was no next sub key.
|
* @return True on success, false if there was no next sub key.
|
||||||
* @error Invalid Handle.
|
* @error Invalid Handle.
|
||||||
*/
|
*/
|
||||||
native bool:KvGotoNextKey(Handle:kv, bool:keyOnly=true);
|
native bool KvGotoNextKey(Handle kv, bool keyOnly=true);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Saves the current position in the traversal stack onto the traversal
|
* Saves the current position in the traversal stack onto the traversal
|
||||||
|
@ -252,10 +511,9 @@ native bool:KvGotoNextKey(Handle:kv, bool:keyOnly=true);
|
||||||
* have the previous key saved for backwards traversal.
|
* have the previous key saved for backwards traversal.
|
||||||
*
|
*
|
||||||
* @param kv KeyValues Handle.
|
* @param kv KeyValues Handle.
|
||||||
* @noreturn
|
|
||||||
* @error Invalid Handle.
|
* @error Invalid Handle.
|
||||||
*/
|
*/
|
||||||
native KvSavePosition(Handle:kv);
|
native void KvSavePosition(Handle kv);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Removes the given key from the current position.
|
* Removes the given key from the current position.
|
||||||
|
@ -265,7 +523,7 @@ native KvSavePosition(Handle:kv);
|
||||||
* @return True on success, false if key did not exist.
|
* @return True on success, false if key did not exist.
|
||||||
* @error Invalid Handle.
|
* @error Invalid Handle.
|
||||||
*/
|
*/
|
||||||
native bool:KvDeleteKey(Handle:kv, const String:key[]);
|
native bool KvDeleteKey(Handle kv, const char[] key);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Removes the current sub-key and attempts to set the position
|
* Removes the current sub-key and attempts to set the position
|
||||||
|
@ -282,7 +540,7 @@ native bool:KvDeleteKey(Handle:kv, const String:key[]);
|
||||||
* thus the state is as if KvGoBack() was called.
|
* thus the state is as if KvGoBack() was called.
|
||||||
* @error Invalid Handle.
|
* @error Invalid Handle.
|
||||||
*/
|
*/
|
||||||
native KvDeleteThis(Handle:kv);
|
native int KvDeleteThis(Handle kv);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Jumps back to the previous position. Returns false if there are no
|
* Jumps back to the previous position. Returns false if there are no
|
||||||
|
@ -294,7 +552,7 @@ native KvDeleteThis(Handle:kv);
|
||||||
* @return True on success, false if there is no higher node.
|
* @return True on success, false if there is no higher node.
|
||||||
* @error Invalid Handle.
|
* @error Invalid Handle.
|
||||||
*/
|
*/
|
||||||
native bool:KvGoBack(Handle:kv);
|
native bool KvGoBack(Handle kv);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the position back to the top node, emptying the entire node
|
* Sets the position back to the top node, emptying the entire node
|
||||||
|
@ -302,10 +560,9 @@ native bool:KvGoBack(Handle:kv);
|
||||||
* if recursive iteration is not important.
|
* if recursive iteration is not important.
|
||||||
*
|
*
|
||||||
* @param kv KeyValues Handle.
|
* @param kv KeyValues Handle.
|
||||||
* @noreturn
|
|
||||||
* @error Invalid Handle.
|
* @error Invalid Handle.
|
||||||
*/
|
*/
|
||||||
native KvRewind(Handle:kv);
|
native void KvRewind(Handle kv);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieves the current section name.
|
* Retrieves the current section name.
|
||||||
|
@ -316,17 +573,16 @@ native KvRewind(Handle:kv);
|
||||||
* @return True on success, false on failure.
|
* @return True on success, false on failure.
|
||||||
* @error Invalid Handle.
|
* @error Invalid Handle.
|
||||||
*/
|
*/
|
||||||
native bool:KvGetSectionName(Handle:kv, String:section[], maxlength);
|
native bool KvGetSectionName(Handle kv, char[] section, int maxlength);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the current section name.
|
* Sets the current section name.
|
||||||
*
|
*
|
||||||
* @param kv KeyValues Handle.
|
* @param kv KeyValues Handle.
|
||||||
* @param section Section name.
|
* @param section Section name.
|
||||||
* @noreturn
|
|
||||||
* @error Invalid Handle.
|
* @error Invalid Handle.
|
||||||
*/
|
*/
|
||||||
native KvSetSectionName(Handle:kv, const String:section[]);
|
native void KvSetSectionName(Handle kv, const char[] section);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the data type at a key.
|
* Returns the data type at a key.
|
||||||
|
@ -336,7 +592,7 @@ native KvSetSectionName(Handle:kv, const String:section[]);
|
||||||
* @return KvDataType value of the key.
|
* @return KvDataType value of the key.
|
||||||
* @error Invalid Handle.
|
* @error Invalid Handle.
|
||||||
*/
|
*/
|
||||||
native KvDataTypes:KvGetDataType(Handle:kv, const String:key[]);
|
native KvDataTypes KvGetDataType(Handle kv, const char[] key);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Converts a KeyValues tree to a file. The tree is dumped
|
* Converts a KeyValues tree to a file. The tree is dumped
|
||||||
|
@ -347,7 +603,7 @@ native KvDataTypes:KvGetDataType(Handle:kv, const String:key[]);
|
||||||
* @return True on success, false otherwise.
|
* @return True on success, false otherwise.
|
||||||
* @error Invalid Handle.
|
* @error Invalid Handle.
|
||||||
*/
|
*/
|
||||||
native bool:KeyValuesToFile(Handle:kv, const String:file[]);
|
native bool KeyValuesToFile(Handle kv, const char[] file);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Converts a file to a KeyValues tree. The file is read into
|
* Converts a file to a KeyValues tree. The file is read into
|
||||||
|
@ -358,7 +614,19 @@ native bool:KeyValuesToFile(Handle:kv, const String:file[]);
|
||||||
* @return True on success, false otherwise.
|
* @return True on success, false otherwise.
|
||||||
* @error Invalid Handle.
|
* @error Invalid Handle.
|
||||||
*/
|
*/
|
||||||
native bool:FileToKeyValues(Handle:kv, const String:file[]);
|
native bool FileToKeyValues(Handle kv, const char[] file);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Converts a given string to a KeyValues tree. The string is read into
|
||||||
|
* the current postion of the tree.
|
||||||
|
*
|
||||||
|
* @param kv KeyValues Handle.
|
||||||
|
* @param buffer String buffer to load into the KeyValues.
|
||||||
|
* @param resourceName The resource name of the KeyValues, used for error tracking purposes.
|
||||||
|
* @return True on success, false otherwise.
|
||||||
|
* @error Invalid Handle.
|
||||||
|
*/
|
||||||
|
native bool StringToKeyValues(Handle kv, const char[] buffer, const char[] resourceName="StringToKeyValues");
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets whether or not the KeyValues parser will read escape sequences.
|
* Sets whether or not the KeyValues parser will read escape sequences.
|
||||||
|
@ -367,10 +635,9 @@ native bool:FileToKeyValues(Handle:kv, const String:file[]);
|
||||||
*
|
*
|
||||||
* @param kv KeyValues Handle.
|
* @param kv KeyValues Handle.
|
||||||
* @param useEscapes Whether or not to read escape sequences.
|
* @param useEscapes Whether or not to read escape sequences.
|
||||||
* @noreturn
|
|
||||||
* @error Invalid Handle.
|
* @error Invalid Handle.
|
||||||
*/
|
*/
|
||||||
native KvSetEscapeSequences(Handle:kv, bool:useEscapes);
|
native void KvSetEscapeSequences(Handle kv, bool useEscapes);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the position in the jump stack; I.e. the number of calls
|
* Returns the position in the jump stack; I.e. the number of calls
|
||||||
|
@ -381,7 +648,7 @@ native KvSetEscapeSequences(Handle:kv, bool:useEscapes);
|
||||||
* @return Number of non-root nodes in the jump stack.
|
* @return Number of non-root nodes in the jump stack.
|
||||||
* @error Invalid Handle.
|
* @error Invalid Handle.
|
||||||
*/
|
*/
|
||||||
native KvNodesInStack(Handle:kv);
|
native int KvNodesInStack(Handle kv);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Makes a new copy of all subkeys in the origin KeyValues to
|
* Makes a new copy of all subkeys in the origin KeyValues to
|
||||||
|
@ -390,10 +657,9 @@ native KvNodesInStack(Handle:kv);
|
||||||
*
|
*
|
||||||
* @param origin Origin KeyValues Handle.
|
* @param origin Origin KeyValues Handle.
|
||||||
* @param dest Destination KeyValues Handle.
|
* @param dest Destination KeyValues Handle.
|
||||||
* @noreturn
|
|
||||||
* @error Invalid Handle.
|
* @error Invalid Handle.
|
||||||
*/
|
*/
|
||||||
native KvCopySubkeys(Handle:origin, Handle:dest);
|
native void KvCopySubkeys(Handle origin, Handle dest);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Finds a KeyValues name by id.
|
* Finds a KeyValues name by id.
|
||||||
|
@ -405,7 +671,7 @@ native KvCopySubkeys(Handle:origin, Handle:dest);
|
||||||
* @return True on success, false if id not found.
|
* @return True on success, false if id not found.
|
||||||
* @error Invalid Handle.
|
* @error Invalid Handle.
|
||||||
*/
|
*/
|
||||||
native bool:KvFindKeyById(Handle:kv, id, String:name[], maxlength);
|
native bool KvFindKeyById(Handle kv, int id, char[] name, int maxlength);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Finds a KeyValues id inside a KeyValues tree.
|
* Finds a KeyValues id inside a KeyValues tree.
|
||||||
|
@ -416,7 +682,7 @@ native bool:KvFindKeyById(Handle:kv, id, String:name[], maxlength);
|
||||||
* @return True on success, false if key not found.
|
* @return True on success, false if key not found.
|
||||||
* @error Invalid Handle.
|
* @error Invalid Handle.
|
||||||
*/
|
*/
|
||||||
native bool:KvGetNameSymbol(Handle:kv, const String:key[], &id);
|
native bool KvGetNameSymbol(Handle kv, const char[] key, int &id);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieves the current section id.
|
* Retrieves the current section id.
|
||||||
|
@ -426,4 +692,4 @@ native bool:KvGetNameSymbol(Handle:kv, const String:key[], &id);
|
||||||
* @return True on success, false on failure.
|
* @return True on success, false on failure.
|
||||||
* @error Invalid Handle.
|
* @error Invalid Handle.
|
||||||
*/
|
*/
|
||||||
native bool:KvGetSectionSymbol(Handle:kv, &id);
|
native bool KvGetSectionSymbol(Handle kv, int &id);
|
||||||
|
|
1
env/include/lang.inc
vendored
1
env/include/lang.inc
vendored
|
@ -59,7 +59,6 @@ native SetGlobalTransTarget(client);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieves the language number of a client.
|
* Retrieves the language number of a client.
|
||||||
* Currently this simply returns the server language index.
|
|
||||||
*
|
*
|
||||||
* @param client Client index.
|
* @param client Client index.
|
||||||
* @return Language number client is using.
|
* @return Language number client is using.
|
||||||
|
|
2
env/include/logging.inc
vendored
2
env/include/logging.inc
vendored
|
@ -123,7 +123,7 @@ forward Action:OnLogAction(Handle:source,
|
||||||
* @return Plugin_Handled or Plugin_Stop will prevent the message
|
* @return Plugin_Handled or Plugin_Stop will prevent the message
|
||||||
* from being written to the log file.
|
* from being written to the log file.
|
||||||
*/
|
*/
|
||||||
functag public Action:GameLogHook(const String:message[]);
|
typedef GameLogHook = function Action (const char[] message);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds a game log hook.
|
* Adds a game log hook.
|
||||||
|
|
4
env/include/mapchooser.inc
vendored
4
env/include/mapchooser.inc
vendored
|
@ -98,12 +98,12 @@ native bool:EndOfMapVoteEnabled();
|
||||||
* Called when mapchooser removes a nomination from its list.
|
* Called when mapchooser removes a nomination from its list.
|
||||||
* Nominations cleared on map start will not trigger this forward
|
* Nominations cleared on map start will not trigger this forward
|
||||||
*/
|
*/
|
||||||
forward OnNominationRemoved(const String:map[], owner);
|
forward void OnNominationRemoved(const char[] map, int owner);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when mapchooser starts a Map Vote.
|
* Called when mapchooser starts a Map Vote.
|
||||||
*/
|
*/
|
||||||
forward OnMapVoteStarted();
|
forward void OnMapVoteStarted();
|
||||||
|
|
||||||
|
|
||||||
public SharedPlugin:__pl_mapchooser =
|
public SharedPlugin:__pl_mapchooser =
|
||||||
|
|
465
env/include/menus.inc
vendored
465
env/include/menus.inc
vendored
|
@ -1,7 +1,7 @@
|
||||||
/**
|
/**
|
||||||
* vim: set ts=4 :
|
* vim: set ts=4 sw=4 tw=99 noet :
|
||||||
* =============================================================================
|
* =============================================================================
|
||||||
* SourceMod (C)2004-2008 AlliedModders LLC. All rights reserved.
|
* SourceMod (C)2004-2014 AlliedModders LLC. All rights reserved.
|
||||||
* =============================================================================
|
* =============================================================================
|
||||||
*
|
*
|
||||||
* This file is part of the SourceMod/SourcePawn SDK.
|
* This file is part of the SourceMod/SourcePawn SDK.
|
||||||
|
@ -150,9 +150,296 @@ enum MenuSource
|
||||||
* @param action The action of the menu.
|
* @param action The action of the menu.
|
||||||
* @param param1 First action parameter (usually the client).
|
* @param param1 First action parameter (usually the client).
|
||||||
* @param param2 Second action parameter (usually the item).
|
* @param param2 Second action parameter (usually the item).
|
||||||
* @noreturn
|
|
||||||
*/
|
*/
|
||||||
functag public MenuHandler(Handle:menu, MenuAction:action, param1, param2);
|
typedef MenuHandler = function int (Menu menu, MenuAction action, int param1, int param2);
|
||||||
|
|
||||||
|
// Panels are used for drawing raw menus without any extra helper functions.
|
||||||
|
// Handles must be closed via delete or CloseHandle().
|
||||||
|
methodmap Panel < Handle
|
||||||
|
{
|
||||||
|
// Constructor for a new Panel.
|
||||||
|
//
|
||||||
|
// @param hStyle MenuStyle Handle, or null to use the default style.
|
||||||
|
public native Panel(Handle hStyle = null);
|
||||||
|
|
||||||
|
// Sets the panel's title.
|
||||||
|
//
|
||||||
|
// @param text Text to set as the title.
|
||||||
|
// @param onlyIfEmpty If true, the title will only be set if no title is set.
|
||||||
|
public native void SetTitle(const char[] text, bool onlyIfEmpty=false);
|
||||||
|
|
||||||
|
// Draws an item on a panel. If the item takes up a slot, the position
|
||||||
|
// is returned.
|
||||||
|
//
|
||||||
|
// @param text Display text to use. If not a raw line,
|
||||||
|
// the style may automatically add color markup.
|
||||||
|
// No numbering or newlines are needed.
|
||||||
|
// @param style ITEMDRAW style flags.
|
||||||
|
// @return A slot position, or 0 if item was a rawline or could not be drawn.
|
||||||
|
public native void DrawItem(const char[] text, style=ITEMDRAW_DEFAULT);
|
||||||
|
|
||||||
|
// Draws a raw line of text on a panel, without any markup other than a
|
||||||
|
// newline.
|
||||||
|
//
|
||||||
|
// @param text Display text to use.
|
||||||
|
// @return True on success, false if raw lines are not supported.
|
||||||
|
public native bool DrawText(const char[] text);
|
||||||
|
|
||||||
|
// Returns whether or not the given drawing flags are supported by
|
||||||
|
// the menu style.
|
||||||
|
//
|
||||||
|
// @param style ITEMDRAW style flags.
|
||||||
|
// @return True if item is drawable, false otherwise.
|
||||||
|
public native bool CanDrawFlags(int style);
|
||||||
|
|
||||||
|
// Sets the selectable key map of a panel. This is not supported by
|
||||||
|
// all styles (only by Radio, as of this writing).
|
||||||
|
//
|
||||||
|
// @param keys An integer where each bit N allows key
|
||||||
|
// N+1 to be selected. If no keys are selectable,
|
||||||
|
// then key 0 (bit 9) is automatically set.
|
||||||
|
// @return True if supported, false otherwise.
|
||||||
|
public native bool SetKeys(int keys);
|
||||||
|
|
||||||
|
// Sends a panel to a client. Unlike full menus, the handler
|
||||||
|
// function will only receive the following actions, both of
|
||||||
|
// which will have null for a menu, and the client as param1.
|
||||||
|
//
|
||||||
|
// MenuAction_Select (param2 will be the key pressed)
|
||||||
|
// MenuAction_Cancel (param2 will be the reason)
|
||||||
|
//
|
||||||
|
// Also, if the menu fails to display, no callbacks will be called.
|
||||||
|
//
|
||||||
|
// @param client A client to draw to.
|
||||||
|
// @param handler The MenuHandler function to catch actions with.
|
||||||
|
// @param time Time to hold the menu for.
|
||||||
|
// @return True on success, false on failure.
|
||||||
|
public native bool Send(int client, MenuHandler handler, int time);
|
||||||
|
|
||||||
|
// Returns the amount of text the menu can still hold. If this is
|
||||||
|
// limit is reached or overflowed, the text is silently truncated.
|
||||||
|
//
|
||||||
|
// Radio menus: Currently 511 characters (512 bytes).
|
||||||
|
// Valve menus: Currently -1 (no meaning).
|
||||||
|
property int TextRemaining {
|
||||||
|
public native get();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Returns or sets the current key position, starting at 1. This cannot be
|
||||||
|
// used to traverse backwards.
|
||||||
|
property int CurrentKey {
|
||||||
|
public native get();
|
||||||
|
public native set(int key);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Returns the panel's style. Style handles are global and cannot be closed.
|
||||||
|
property Handle Style {
|
||||||
|
public native get();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// A menu is a helper object for managing in-game menus.
|
||||||
|
methodmap Menu < Handle
|
||||||
|
{
|
||||||
|
// Creates a new, empty menu using the default style.
|
||||||
|
//
|
||||||
|
// @param handler Function which will receive menu actions.
|
||||||
|
// @param actions Optionally set which actions to receive. Select,
|
||||||
|
// Cancel, and End will always be received regardless
|
||||||
|
// of whether they are set or not. They are also
|
||||||
|
// the only default actions.
|
||||||
|
public native Menu(MenuHandler handler, MenuAction actions=MENU_ACTIONS_DEFAULT);
|
||||||
|
|
||||||
|
// Displays a menu to a client.
|
||||||
|
//
|
||||||
|
// @param client Client index.
|
||||||
|
// @param time Maximum time to leave menu on the screen.
|
||||||
|
// @return True on success, false on failure.
|
||||||
|
// @error Client not in game.
|
||||||
|
public native bool Display(int client, int time);
|
||||||
|
|
||||||
|
// Displays a menu to a client, starting from the given item.
|
||||||
|
//
|
||||||
|
// @param client Client index.
|
||||||
|
// @param first_item First item to begin drawing from.
|
||||||
|
// @param time Maximum time to leave menu on the screen.
|
||||||
|
// @return True on success, false on failure.
|
||||||
|
// @error Client not in game.
|
||||||
|
///
|
||||||
|
public native bool DisplayAt(int client, int first_item, int time);
|
||||||
|
|
||||||
|
// Appends a new item to the end of a menu.
|
||||||
|
//
|
||||||
|
// @param info Item information string.
|
||||||
|
// @param display Default item display string.
|
||||||
|
// @param style Drawing style flags. Anything other than DEFAULT or
|
||||||
|
// DISABLED will be completely ignored when paginating.
|
||||||
|
// @return True on success, false on failure.
|
||||||
|
// @error Item limit reached.
|
||||||
|
public native bool AddItem(const char[] info, const char[] display, int style=ITEMDRAW_DEFAULT);
|
||||||
|
|
||||||
|
// Inserts an item into the menu before a certain position; the new item will
|
||||||
|
// be at the given position and all next items pushed forward.
|
||||||
|
//
|
||||||
|
// @param position Position, starting from 0.
|
||||||
|
// @param info Item information string.
|
||||||
|
// @param display Default item display string.
|
||||||
|
// @param style Drawing style flags. Anything other than DEFAULT or
|
||||||
|
// DISABLED will be completely ignored when paginating.
|
||||||
|
// @return True on success, false on failure.
|
||||||
|
// @error Invalid menu position.
|
||||||
|
public native bool InsertItem(int position, const char[] info,
|
||||||
|
const char[] display, int style=ITEMDRAW_DEFAULT);
|
||||||
|
|
||||||
|
// Removes an item from the menu.
|
||||||
|
//
|
||||||
|
// @param position Position, starting from 0.
|
||||||
|
// @return True on success, false on failure.
|
||||||
|
// @error Invalid menu position.
|
||||||
|
public native bool RemoveItem(int position);
|
||||||
|
|
||||||
|
// Removes all items from a menu.
|
||||||
|
public native void RemoveAllItems();
|
||||||
|
|
||||||
|
// Retrieves information about a menu item.
|
||||||
|
//
|
||||||
|
// @param position Position, starting from 0.
|
||||||
|
// @param infoBuf Info buffer.
|
||||||
|
// @param infoBufLen Maximum length of the info buffer.
|
||||||
|
// @param style By-reference variable to store drawing flags.
|
||||||
|
// @param dispBuf Display buffer.
|
||||||
|
// @param dispBufLen Maximum length of the display buffer.
|
||||||
|
// @return True on success, false if position is invalid.
|
||||||
|
public native bool GetItem(int position, char[] infoBuf, int infoBufLen,
|
||||||
|
int &style=0, char[] dispBuf="", int dispBufLen=0);
|
||||||
|
|
||||||
|
// Sets the menu's default title/instruction message.
|
||||||
|
//
|
||||||
|
// @param fmt Message string format
|
||||||
|
// @param ... Message string arguments.
|
||||||
|
public native void SetTitle(const char[] fmt, any ...);
|
||||||
|
|
||||||
|
// Returns the text of a menu's title.
|
||||||
|
//
|
||||||
|
// @param menu Menu Handle.
|
||||||
|
// @param buffer Buffer to store title.
|
||||||
|
// @param maxlength Maximum length of the buffer.
|
||||||
|
// @return Number of bytes written.
|
||||||
|
public native void GetTitle(char[] buffer, int maxlength);
|
||||||
|
|
||||||
|
// Creates a raw MenuPanel based off the menu's style.
|
||||||
|
// The Handle must be freed with CloseHandle().
|
||||||
|
//
|
||||||
|
// @param menu Menu Handle.
|
||||||
|
// @return A new MenuPanel Handle.
|
||||||
|
public native Panel ToPanel();
|
||||||
|
|
||||||
|
// Cancels a menu from displaying on all clients. While the
|
||||||
|
// cancellation is in progress, this menu cannot be re-displayed
|
||||||
|
// to any clients.
|
||||||
|
//
|
||||||
|
// The menu may still exist on the client's screen after this command.
|
||||||
|
// This simply verifies that the menu is not being used anywhere.
|
||||||
|
//
|
||||||
|
// If any vote is in progress on a menu, it will be cancelled.
|
||||||
|
public native void Cancel();
|
||||||
|
|
||||||
|
// Broadcasts a menu to a list of clients. The most selected item will be
|
||||||
|
// returned through MenuAction_End. On a tie, a random item will be returned
|
||||||
|
// from a list of the tied items.
|
||||||
|
//
|
||||||
|
// Note that MenuAction_VoteEnd and MenuAction_VoteStart are both
|
||||||
|
// default callbacks and do not need to be enabled.
|
||||||
|
//
|
||||||
|
// @param clients Array of clients to broadcast to.
|
||||||
|
// @param numClients Number of clients in the array.
|
||||||
|
// @param time Maximum time to leave menu on the screen.
|
||||||
|
// @param flags Optional voting flags.
|
||||||
|
// @return True on success, false if this menu already has a
|
||||||
|
// vote session in progress.
|
||||||
|
// @error A vote is already in progress.
|
||||||
|
public native bool DisplayVote(int[] clients, int numClients, int time, int flags=0);
|
||||||
|
|
||||||
|
// Sends a vote menu to all clients. See VoteMenu() for more information.
|
||||||
|
//
|
||||||
|
// @param time Maximum time to leave menu on the screen.
|
||||||
|
// @param flags Optional voting flags.
|
||||||
|
// @return True on success, false if this menu already has a
|
||||||
|
// vote session in progress.
|
||||||
|
public bool DisplayVoteToAll(int time, int flags=0) {
|
||||||
|
int total = 0;
|
||||||
|
int[] players = new int[MaxClients];
|
||||||
|
for (int i = 1; i <= MaxClients; i++) {
|
||||||
|
if (!IsClientInGame(i) || IsFakeClient(i))
|
||||||
|
continue;
|
||||||
|
players[total++] = i;
|
||||||
|
}
|
||||||
|
return this.DisplayVote(players, total, time, flags);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get or set the menu's pagination.
|
||||||
|
//
|
||||||
|
// If pgination is MENU_NO_PAGINATION, and the exit button flag is set,
|
||||||
|
// then the exit button flag is removed. It can be re-applied if desired.
|
||||||
|
property int Pagination {
|
||||||
|
public native get();
|
||||||
|
public native set(int value);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get or set the menu's option flags.
|
||||||
|
//
|
||||||
|
// If a certain bit is not supported, it will be stripped before being set.
|
||||||
|
property int OptionFlags {
|
||||||
|
public native get();
|
||||||
|
public native set(int value);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Returns whether or not the menu has an exit button. By default, menus
|
||||||
|
// have an exit button.
|
||||||
|
property bool ExitButton {
|
||||||
|
public native get();
|
||||||
|
public native set(bool value);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Controls whether or not the menu has an "exit back" button. By default,
|
||||||
|
// menus do not have an exit back button.
|
||||||
|
//
|
||||||
|
// Exit Back buttons appear as "Back" on page 1 of paginated menus and have
|
||||||
|
// functionality defined by the user in MenuEnd_ExitBack.
|
||||||
|
property bool ExitBackButton {
|
||||||
|
public native get();
|
||||||
|
public native set(bool value);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Sets whether or not the menu has a "no vote" button in slot 1.
|
||||||
|
// By default, menus do not have a no vote button.
|
||||||
|
property bool NoVoteButton {
|
||||||
|
public native set(bool value);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Sets an advanced vote handling callback. If this callback is set,
|
||||||
|
// MenuAction_VoteEnd will not be called.
|
||||||
|
property VoteHandler VoteResultCallback {
|
||||||
|
public native set(VoteHandler handler);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Returns the number of items in a menu.
|
||||||
|
property int ItemCount {
|
||||||
|
public native get();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Returns the menu style. The Handle is global and cannot be closed.
|
||||||
|
property Handle Style {
|
||||||
|
public native get();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Returns the first item on the page of a currently selected menu.
|
||||||
|
//
|
||||||
|
// This is only valid inside a MenuAction_Select callback.
|
||||||
|
property int Selection {
|
||||||
|
public native get();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new, empty menu using the default style.
|
* Creates a new, empty menu using the default style.
|
||||||
|
@ -164,7 +451,7 @@ functag public MenuHandler(Handle:menu, MenuAction:action, param1, param2);
|
||||||
* the only default actions.
|
* the only default actions.
|
||||||
* @return A new menu Handle.
|
* @return A new menu Handle.
|
||||||
*/
|
*/
|
||||||
native Handle:CreateMenu(MenuHandler:handler, MenuAction:actions=MENU_ACTIONS_DEFAULT);
|
native Menu CreateMenu(MenuHandler handler, MenuAction actions=MENU_ACTIONS_DEFAULT);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Displays a menu to a client.
|
* Displays a menu to a client.
|
||||||
|
@ -175,7 +462,7 @@ native Handle:CreateMenu(MenuHandler:handler, MenuAction:actions=MENU_ACTIONS_DE
|
||||||
* @return True on success, false on failure.
|
* @return True on success, false on failure.
|
||||||
* @error Invalid Handle or client not in game.
|
* @error Invalid Handle or client not in game.
|
||||||
*/
|
*/
|
||||||
native bool:DisplayMenu(Handle:menu, client, time);
|
native bool DisplayMenu(Handle menu, int client, int time);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Displays a menu to a client, starting from the given item.
|
* Displays a menu to a client, starting from the given item.
|
||||||
|
@ -187,7 +474,7 @@ native bool:DisplayMenu(Handle:menu, client, time);
|
||||||
* @return True on success, false on failure.
|
* @return True on success, false on failure.
|
||||||
* @error Invalid Handle or client not in game.
|
* @error Invalid Handle or client not in game.
|
||||||
*/
|
*/
|
||||||
native bool:DisplayMenuAtItem(Handle:menu, client, first_item, time);
|
native bool DisplayMenuAtItem(Handle menu, int client, int first_item, int time);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Appends a new item to the end of a menu.
|
* Appends a new item to the end of a menu.
|
||||||
|
@ -200,10 +487,10 @@ native bool:DisplayMenuAtItem(Handle:menu, client, first_item, time);
|
||||||
* @return True on success, false on failure.
|
* @return True on success, false on failure.
|
||||||
* @error Invalid Handle or item limit reached.
|
* @error Invalid Handle or item limit reached.
|
||||||
*/
|
*/
|
||||||
native AddMenuItem(Handle:menu,
|
native bool AddMenuItem(Handle menu,
|
||||||
const String:info[],
|
const char[] info,
|
||||||
const String:display[],
|
const char[] display,
|
||||||
style=ITEMDRAW_DEFAULT);
|
int style=ITEMDRAW_DEFAULT);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Inserts an item into the menu before a certain position; the new item will
|
* Inserts an item into the menu before a certain position; the new item will
|
||||||
|
@ -218,11 +505,11 @@ native AddMenuItem(Handle:menu,
|
||||||
* @return True on success, false on failure.
|
* @return True on success, false on failure.
|
||||||
* @error Invalid Handle or menu position.
|
* @error Invalid Handle or menu position.
|
||||||
*/
|
*/
|
||||||
native bool:InsertMenuItem(Handle:menu,
|
native bool InsertMenuItem(Handle menu,
|
||||||
position,
|
position,
|
||||||
const String:info[],
|
const char[] info,
|
||||||
const String:display[],
|
const char[] display,
|
||||||
style=ITEMDRAW_DEFAULT);
|
int style=ITEMDRAW_DEFAULT);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Removes an item from the menu.
|
* Removes an item from the menu.
|
||||||
|
@ -232,16 +519,15 @@ native bool:InsertMenuItem(Handle:menu,
|
||||||
* @return True on success, false on failure.
|
* @return True on success, false on failure.
|
||||||
* @error Invalid Handle or menu position.
|
* @error Invalid Handle or menu position.
|
||||||
*/
|
*/
|
||||||
native bool:RemoveMenuItem(Handle:menu, position);
|
native bool RemoveMenuItem(Handle menu, int position);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Removes all items from a menu.
|
* Removes all items from a menu.
|
||||||
*
|
*
|
||||||
* @param menu Menu Handle.
|
* @param menu Menu Handle.
|
||||||
* @noreturn
|
|
||||||
* @error Invalid Handle or menu position.
|
* @error Invalid Handle or menu position.
|
||||||
*/
|
*/
|
||||||
native RemoveAllMenuItems(Handle:menu);
|
native void RemoveAllMenuItems(Handle menu);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieves information about a menu item.
|
* Retrieves information about a menu item.
|
||||||
|
@ -256,13 +542,13 @@ native RemoveAllMenuItems(Handle:menu);
|
||||||
* @return True on success, false if position is invalid.
|
* @return True on success, false if position is invalid.
|
||||||
* @error Invalid Handle.
|
* @error Invalid Handle.
|
||||||
*/
|
*/
|
||||||
native bool:GetMenuItem(Handle:menu,
|
native bool GetMenuItem(Handle menu,
|
||||||
position,
|
int position,
|
||||||
String:infoBuf[],
|
char[] infoBuf,
|
||||||
infoBufLen,
|
int infoBufLen,
|
||||||
&style=0,
|
int &style=0,
|
||||||
String:dispBuf[]="",
|
char[] dispBuf="",
|
||||||
dispBufLen=0);
|
int dispBufLen=0);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the first item on the page of a currently selected menu.
|
* Returns the first item on the page of a currently selected menu.
|
||||||
|
@ -275,7 +561,7 @@ native bool:GetMenuItem(Handle:menu,
|
||||||
* position.
|
* position.
|
||||||
* @error Not called from inside a MenuAction_Select callback.
|
* @error Not called from inside a MenuAction_Select callback.
|
||||||
*/
|
*/
|
||||||
native GetMenuSelectionPosition();
|
native int GetMenuSelectionPosition();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the number of items in a menu.
|
* Returns the number of items in a menu.
|
||||||
|
@ -284,7 +570,7 @@ native GetMenuSelectionPosition();
|
||||||
* @return Number of items in the menu.
|
* @return Number of items in the menu.
|
||||||
* @error Invalid Handle.
|
* @error Invalid Handle.
|
||||||
*/
|
*/
|
||||||
native GetMenuItemCount(Handle:menu);
|
native int GetMenuItemCount(Handle menu);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets whether the menu should be paginated or not.
|
* Sets whether the menu should be paginated or not.
|
||||||
|
@ -298,7 +584,7 @@ native GetMenuItemCount(Handle:menu);
|
||||||
* low.
|
* low.
|
||||||
* @error Invalid Handle.
|
* @error Invalid Handle.
|
||||||
*/
|
*/
|
||||||
native bool:SetMenuPagination(Handle:menu, itemsPerPage);
|
native bool SetMenuPagination(Handle menu, int itemsPerPage);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a menu's pagination setting.
|
* Returns a menu's pagination setting.
|
||||||
|
@ -307,7 +593,7 @@ native bool:SetMenuPagination(Handle:menu, itemsPerPage);
|
||||||
* @return Pagination setting.
|
* @return Pagination setting.
|
||||||
* @error Invalid Handle.
|
* @error Invalid Handle.
|
||||||
*/
|
*/
|
||||||
native GetMenuPagination(Handle:menu);
|
native int GetMenuPagination(Handle menu);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a menu's MenuStyle Handle. The Handle
|
* Returns a menu's MenuStyle Handle. The Handle
|
||||||
|
@ -317,7 +603,7 @@ native GetMenuPagination(Handle:menu);
|
||||||
* @return Handle to the menu's draw style.
|
* @return Handle to the menu's draw style.
|
||||||
* @error Invalid Handle.
|
* @error Invalid Handle.
|
||||||
*/
|
*/
|
||||||
native Handle:GetMenuStyle(Handle:menu);
|
native Handle GetMenuStyle(Handle menu);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the menu's default title/instruction message.
|
* Sets the menu's default title/instruction message.
|
||||||
|
@ -325,10 +611,9 @@ native Handle:GetMenuStyle(Handle:menu);
|
||||||
* @param menu Menu Handle.
|
* @param menu Menu Handle.
|
||||||
* @param fmt Message string format
|
* @param fmt Message string format
|
||||||
* @param ... Message string arguments.
|
* @param ... Message string arguments.
|
||||||
* @noreturn
|
|
||||||
* @error Invalid Handle.
|
* @error Invalid Handle.
|
||||||
*/
|
*/
|
||||||
native SetMenuTitle(Handle:menu, const String:fmt[], any:...);
|
native void SetMenuTitle(Handle menu, const char[] fmt, any ...);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the text of a menu's title.
|
* Returns the text of a menu's title.
|
||||||
|
@ -339,7 +624,7 @@ native SetMenuTitle(Handle:menu, const String:fmt[], any:...);
|
||||||
* @return Number of bytes written.
|
* @return Number of bytes written.
|
||||||
* @error Invalid Handle/
|
* @error Invalid Handle/
|
||||||
*/
|
*/
|
||||||
native GetMenuTitle(Handle:menu, String:buffer[], maxlength);
|
native int GetMenuTitle(Handle menu, char[] buffer, int maxlength);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a raw MenuPanel based off the menu's style.
|
* Creates a raw MenuPanel based off the menu's style.
|
||||||
|
@ -349,7 +634,7 @@ native GetMenuTitle(Handle:menu, String:buffer[], maxlength);
|
||||||
* @return A new MenuPanel Handle.
|
* @return A new MenuPanel Handle.
|
||||||
* @error Invalid Handle.
|
* @error Invalid Handle.
|
||||||
*/
|
*/
|
||||||
native Handle:CreatePanelFromMenu(Handle:menu);
|
native Panel CreatePanelFromMenu(Handle menu);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns whether or not the menu has an exit button.
|
* Returns whether or not the menu has an exit button.
|
||||||
|
@ -359,7 +644,7 @@ native Handle:CreatePanelFromMenu(Handle:menu);
|
||||||
* @return True if the menu has an exit button; false otherwise.
|
* @return True if the menu has an exit button; false otherwise.
|
||||||
* @error Invalid Handle.
|
* @error Invalid Handle.
|
||||||
*/
|
*/
|
||||||
native bool:GetMenuExitButton(Handle:menu);
|
native bool GetMenuExitButton(Handle menu);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets whether or not the menu has an exit button. By default, paginated menus
|
* Sets whether or not the menu has an exit button. By default, paginated menus
|
||||||
|
@ -377,7 +662,7 @@ native bool:GetMenuExitButton(Handle:menu);
|
||||||
* @return True if allowed; false on failure.
|
* @return True if allowed; false on failure.
|
||||||
* @error Invalid Handle.
|
* @error Invalid Handle.
|
||||||
*/
|
*/
|
||||||
native bool:SetMenuExitButton(Handle:menu, bool:button);
|
native bool SetMenuExitButton(Handle menu, bool button);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns whether or not the menu has an "exit back" button. By default,
|
* Returns whether or not the menu has an "exit back" button. By default,
|
||||||
|
@ -390,7 +675,7 @@ native bool:SetMenuExitButton(Handle:menu, bool:button);
|
||||||
* @return True if the menu has an exit back button; false otherwise.
|
* @return True if the menu has an exit back button; false otherwise.
|
||||||
* @error Invalid Handle.
|
* @error Invalid Handle.
|
||||||
*/
|
*/
|
||||||
native bool:GetMenuExitBackButton(Handle:menu);
|
native bool GetMenuExitBackButton(Handle menu);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets whether or not the menu has an "exit back" button. By default, menus
|
* Sets whether or not the menu has an "exit back" button. By default, menus
|
||||||
|
@ -403,7 +688,7 @@ native bool:GetMenuExitBackButton(Handle:menu);
|
||||||
* @param button True to enable the button, false to remove it.
|
* @param button True to enable the button, false to remove it.
|
||||||
* @error Invalid Handle.
|
* @error Invalid Handle.
|
||||||
*/
|
*/
|
||||||
native SetMenuExitBackButton(Handle:menu, bool:button);
|
native void SetMenuExitBackButton(Handle menu, bool button);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets whether or not the menu has a "no vote" button in slot 1.
|
* Sets whether or not the menu has a "no vote" button in slot 1.
|
||||||
|
@ -414,7 +699,7 @@ native SetMenuExitBackButton(Handle:menu, bool:button);
|
||||||
* @return True if allowed; false on failure.
|
* @return True if allowed; false on failure.
|
||||||
* @error Invalid Handle.
|
* @error Invalid Handle.
|
||||||
*/
|
*/
|
||||||
native bool:SetMenuNoVoteButton(Handle:menu, bool:button);
|
native bool SetMenuNoVoteButton(Handle menu, bool button);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Cancels a menu from displaying on all clients. While the
|
* Cancels a menu from displaying on all clients. While the
|
||||||
|
@ -427,10 +712,9 @@ native bool:SetMenuNoVoteButton(Handle:menu, bool:button);
|
||||||
* If any vote is in progress on a menu, it will be cancelled.
|
* If any vote is in progress on a menu, it will be cancelled.
|
||||||
*
|
*
|
||||||
* @param menu Menu Handle.
|
* @param menu Menu Handle.
|
||||||
* @noreturn
|
|
||||||
* @error Invalid Handle.
|
* @error Invalid Handle.
|
||||||
*/
|
*/
|
||||||
native CancelMenu(Handle:menu);
|
native void CancelMenu(Handle menu);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieves a menu's option flags.
|
* Retrieves a menu's option flags.
|
||||||
|
@ -439,7 +723,7 @@ native CancelMenu(Handle:menu);
|
||||||
* @return A bitstring of MENUFLAG bits.
|
* @return A bitstring of MENUFLAG bits.
|
||||||
* @error Invalid Handle.
|
* @error Invalid Handle.
|
||||||
*/
|
*/
|
||||||
native GetMenuOptionFlags(Handle:menu);
|
native int GetMenuOptionFlags(Handle menu);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets a menu's option flags.
|
* Sets a menu's option flags.
|
||||||
|
@ -450,10 +734,9 @@ native GetMenuOptionFlags(Handle:menu);
|
||||||
*
|
*
|
||||||
* @param menu Menu Handle.
|
* @param menu Menu Handle.
|
||||||
* @param flags A new bitstring of MENUFLAG bits.
|
* @param flags A new bitstring of MENUFLAG bits.
|
||||||
* @noreturn
|
|
||||||
* @error Invalid Handle.
|
* @error Invalid Handle.
|
||||||
*/
|
*/
|
||||||
native SetMenuOptionFlags(Handle:menu, flags);
|
native void SetMenuOptionFlags(Handle menu, int flags);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns whether a vote is in progress.
|
* Returns whether a vote is in progress.
|
||||||
|
@ -461,15 +744,14 @@ native SetMenuOptionFlags(Handle:menu, flags);
|
||||||
* @param menu Deprecated; no longer used.
|
* @param menu Deprecated; no longer used.
|
||||||
* @return True if a vote is in progress, false otherwise.
|
* @return True if a vote is in progress, false otherwise.
|
||||||
*/
|
*/
|
||||||
native bool:IsVoteInProgress(Handle:menu=INVALID_HANDLE);
|
native bool IsVoteInProgress(Handle menu=INVALID_HANDLE);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Cancels the vote in progress.
|
* Cancels the vote in progress.
|
||||||
*
|
*
|
||||||
* @noreturn
|
|
||||||
* @error If no vote is in progress.
|
* @error If no vote is in progress.
|
||||||
*/
|
*/
|
||||||
native CancelVote();
|
native void CancelVote();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Broadcasts a menu to a list of clients. The most selected item will be
|
* Broadcasts a menu to a list of clients. The most selected item will be
|
||||||
|
@ -488,7 +770,7 @@ native CancelVote();
|
||||||
* in progress.
|
* in progress.
|
||||||
* @error Invalid Handle, or a vote is already in progress.
|
* @error Invalid Handle, or a vote is already in progress.
|
||||||
*/
|
*/
|
||||||
native bool:VoteMenu(Handle:menu, clients[], numClients, time, flags=0);
|
native bool VoteMenu(Handle menu, int[] clients, int numClients, int time, int flags=0);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sends a vote menu to all clients. See VoteMenu() for more information.
|
* Sends a vote menu to all clients. See VoteMenu() for more information.
|
||||||
|
@ -500,7 +782,7 @@ native bool:VoteMenu(Handle:menu, clients[], numClients, time, flags=0);
|
||||||
* in progress.
|
* in progress.
|
||||||
* @error Invalid Handle.
|
* @error Invalid Handle.
|
||||||
*/
|
*/
|
||||||
stock bool:VoteMenuToAll(Handle:menu, time, flags=0)
|
stock bool VoteMenuToAll(Handle menu, int time, int flags=0)
|
||||||
{
|
{
|
||||||
new total;
|
new total;
|
||||||
decl players[MaxClients];
|
decl players[MaxClients];
|
||||||
|
@ -516,6 +798,7 @@ stock bool:VoteMenuToAll(Handle:menu, time, flags=0)
|
||||||
|
|
||||||
return VoteMenu(menu, players, total, time, flags);
|
return VoteMenu(menu, players, total, time, flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Callback for when a vote has ended and results are available.
|
* Callback for when a vote has ended and results are available.
|
||||||
*
|
*
|
||||||
|
@ -526,14 +809,29 @@ stock bool:VoteMenuToAll(Handle:menu, time, flags=0)
|
||||||
* @param num_items Number of unique items that were selected.
|
* @param num_items Number of unique items that were selected.
|
||||||
* @param item_info Array of items, sorted by count. Use VOTEINFO_ITEM
|
* @param item_info Array of items, sorted by count. Use VOTEINFO_ITEM
|
||||||
* defines.
|
* defines.
|
||||||
* @noreturn
|
|
||||||
*/
|
*/
|
||||||
functag public VoteHandler(Handle:menu,
|
typeset VoteHandler
|
||||||
num_votes,
|
{
|
||||||
num_clients,
|
// old style
|
||||||
const client_info[][2],
|
function void(
|
||||||
num_items,
|
Menu menu,
|
||||||
const item_info[][2]);
|
int num_votes,
|
||||||
|
int num_clients,
|
||||||
|
const int client_info[][2],
|
||||||
|
int num_items,
|
||||||
|
const int item_info[][2]
|
||||||
|
);
|
||||||
|
|
||||||
|
// new style
|
||||||
|
function void(
|
||||||
|
Menu menu,
|
||||||
|
int num_votes,
|
||||||
|
int num_clients,
|
||||||
|
const int[][] client_info,
|
||||||
|
int num_items,
|
||||||
|
const int[][] item_info
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets an advanced vote handling callback. If this callback is set,
|
* Sets an advanced vote handling callback. If this callback is set,
|
||||||
|
@ -541,10 +839,9 @@ functag public VoteHandler(Handle:menu,
|
||||||
*
|
*
|
||||||
* @param menu Menu Handle.
|
* @param menu Menu Handle.
|
||||||
* @param callback Callback function.
|
* @param callback Callback function.
|
||||||
* @noreturn
|
|
||||||
* @error Invalid Handle or callback.
|
* @error Invalid Handle or callback.
|
||||||
*/
|
*/
|
||||||
native SetVoteResultCallback(Handle:menu, VoteHandler:callback);
|
native void SetVoteResultCallback(Handle menu, VoteHandler callback);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the number of seconds you should "wait" before displaying
|
* Returns the number of seconds you should "wait" before displaying
|
||||||
|
@ -553,7 +850,7 @@ native SetVoteResultCallback(Handle:menu, VoteHandler:callback);
|
||||||
*
|
*
|
||||||
* @return Number of seconds to wait, or 0 for none.
|
* @return Number of seconds to wait, or 0 for none.
|
||||||
*/
|
*/
|
||||||
native CheckVoteDelay();
|
native int CheckVoteDelay();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns whether a client is in the pool of clients allowed
|
* Returns whether a client is in the pool of clients allowed
|
||||||
|
@ -564,7 +861,7 @@ native CheckVoteDelay();
|
||||||
* @return True if client is allowed to vote, false otherwise.
|
* @return True if client is allowed to vote, false otherwise.
|
||||||
* @error If no vote is in progress or client index is invalid.
|
* @error If no vote is in progress or client index is invalid.
|
||||||
*/
|
*/
|
||||||
native bool:IsClientInVotePool(client);
|
native bool IsClientInVotePool(int client);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Redraws the current vote menu to a client in the voting pool.
|
* Redraws the current vote menu to a client in the voting pool.
|
||||||
|
@ -573,10 +870,10 @@ native bool:IsClientInVotePool(client);
|
||||||
* @param revotes True to allow revotes, false otherwise.
|
* @param revotes True to allow revotes, false otherwise.
|
||||||
* @return True on success, false if the client is in the vote pool
|
* @return True on success, false if the client is in the vote pool
|
||||||
* but cannot vote again.
|
* but cannot vote again.
|
||||||
* @error No vote in progress, client is not in the voting pool,
|
* @error No vote in progress, int client is not in the voting pool,
|
||||||
* or client index is invalid.
|
* or client index is invalid.
|
||||||
*/
|
*/
|
||||||
native bool:RedrawClientVoteMenu(client, bool:revotes=true);
|
native bool RedrawClientVoteMenu(int client, bool revotes=true);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a style's global Handle.
|
* Returns a style's global Handle.
|
||||||
|
@ -584,7 +881,7 @@ native bool:RedrawClientVoteMenu(client, bool:revotes=true);
|
||||||
* @param style Menu Style.
|
* @param style Menu Style.
|
||||||
* @return A Handle, or INVALID_HANDLE if not found or unusable.
|
* @return A Handle, or INVALID_HANDLE if not found or unusable.
|
||||||
*/
|
*/
|
||||||
native Handle:GetMenuStyleHandle(MenuStyle:style);
|
native Handle GetMenuStyleHandle(MenuStyle style);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a MenuPanel from a MenuStyle. Panels are used for drawing raw
|
* Creates a MenuPanel from a MenuStyle. Panels are used for drawing raw
|
||||||
|
@ -595,7 +892,7 @@ native Handle:GetMenuStyleHandle(MenuStyle:style);
|
||||||
* @return A new MenuPanel Handle.
|
* @return A new MenuPanel Handle.
|
||||||
* @error Invalid Handle other than INVALID_HANDLE.
|
* @error Invalid Handle other than INVALID_HANDLE.
|
||||||
*/
|
*/
|
||||||
native Handle:CreatePanel(Handle:hStyle=INVALID_HANDLE);
|
native Panel CreatePanel(Handle hStyle=INVALID_HANDLE);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a Menu from a MenuStyle. The Handle must be closed with
|
* Creates a Menu from a MenuStyle. The Handle must be closed with
|
||||||
|
@ -610,7 +907,7 @@ native Handle:CreatePanel(Handle:hStyle=INVALID_HANDLE);
|
||||||
* @return A new menu Handle.
|
* @return A new menu Handle.
|
||||||
* @error Invalid Handle other than INVALID_HANDLE.
|
* @error Invalid Handle other than INVALID_HANDLE.
|
||||||
*/
|
*/
|
||||||
native Handle:CreateMenuEx(Handle:hStyle=INVALID_HANDLE, MenuHandler:handler, MenuAction:actions=MENU_ACTIONS_DEFAULT);
|
native Menu CreateMenuEx(Handle hStyle=INVALID_HANDLE, MenuHandler handler, MenuAction actions=MENU_ACTIONS_DEFAULT);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns whether a client is viewing a menu.
|
* Returns whether a client is viewing a menu.
|
||||||
|
@ -618,9 +915,9 @@ native Handle:CreateMenuEx(Handle:hStyle=INVALID_HANDLE, MenuHandler:handler, Me
|
||||||
* @param client Client index.
|
* @param client Client index.
|
||||||
* @param hStyle MenuStyle Handle, or INVALID_HANDLE to use the default style.
|
* @param hStyle MenuStyle Handle, or INVALID_HANDLE to use the default style.
|
||||||
* @return A MenuSource value.
|
* @return A MenuSource value.
|
||||||
* @error Invalid Handle other than INVALID_HANDLE.
|
* @error Invalid Handle other than null.
|
||||||
*/
|
*/
|
||||||
native MenuSource:GetClientMenu(client, Handle:hStyle=INVALID_HANDLE);
|
native MenuSource GetClientMenu(int client, Handle hStyle=null);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Cancels a menu on a client. This will only affect non-external menus.
|
* Cancels a menu on a client. This will only affect non-external menus.
|
||||||
|
@ -631,7 +928,7 @@ native MenuSource:GetClientMenu(client, Handle:hStyle=INVALID_HANDLE);
|
||||||
* the cancellation process.
|
* the cancellation process.
|
||||||
* @return True if a menu was cancelled, false otherwise.
|
* @return True if a menu was cancelled, false otherwise.
|
||||||
*/
|
*/
|
||||||
native bool:CancelClientMenu(client, bool:autoIgnore=false, Handle:hStyle=INVALID_HANDLE);
|
native bool CancelClientMenu(int client, bool autoIgnore=false, Handle hStyle=INVALID_HANDLE);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a style's maximum items per page.
|
* Returns a style's maximum items per page.
|
||||||
|
@ -640,7 +937,7 @@ native bool:CancelClientMenu(client, bool:autoIgnore=false, Handle:hStyle=INVALI
|
||||||
* @return Maximum items per page.
|
* @return Maximum items per page.
|
||||||
* @error Invalid Handle other than INVALID_HANDLE.
|
* @error Invalid Handle other than INVALID_HANDLE.
|
||||||
*/
|
*/
|
||||||
native GetMaxPageItems(Handle:hStyle=INVALID_HANDLE);
|
native int GetMaxPageItems(Handle hStyle=INVALID_HANDLE);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a MenuPanel's parent style.
|
* Returns a MenuPanel's parent style.
|
||||||
|
@ -649,7 +946,7 @@ native GetMaxPageItems(Handle:hStyle=INVALID_HANDLE);
|
||||||
* @return The MenuStyle Handle that created the panel.
|
* @return The MenuStyle Handle that created the panel.
|
||||||
* @error Invalid Handle.
|
* @error Invalid Handle.
|
||||||
*/
|
*/
|
||||||
native Handle:GetPanelStyle(Handle:panel);
|
native Handle GetPanelStyle(Handle panel);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the panel's title.
|
* Sets the panel's title.
|
||||||
|
@ -657,10 +954,9 @@ native Handle:GetPanelStyle(Handle:panel);
|
||||||
* @param panel A MenuPanel Handle.
|
* @param panel A MenuPanel Handle.
|
||||||
* @param text Text to set as the title.
|
* @param text Text to set as the title.
|
||||||
* @param onlyIfEmpty If true, the title will only be set if no title is set.
|
* @param onlyIfEmpty If true, the title will only be set if no title is set.
|
||||||
* @noreturn
|
|
||||||
* @error Invalid Handle.
|
* @error Invalid Handle.
|
||||||
*/
|
*/
|
||||||
native Handle:SetPanelTitle(Handle:panel, const String:text[], bool:onlyIfEmpty=false);
|
native void SetPanelTitle(Handle panel, const char[] text, bool onlyIfEmpty=false);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Draws an item on a panel. If the item takes up a slot, the position
|
* Draws an item on a panel. If the item takes up a slot, the position
|
||||||
|
@ -674,7 +970,7 @@ native Handle:SetPanelTitle(Handle:panel, const String:text[], bool:onlyIfEmpty=
|
||||||
* @return A slot position, or 0 if item was a rawline or could not be drawn.
|
* @return A slot position, or 0 if item was a rawline or could not be drawn.
|
||||||
* @error Invalid Handle.
|
* @error Invalid Handle.
|
||||||
*/
|
*/
|
||||||
native DrawPanelItem(Handle:panel, const String:text[], style=ITEMDRAW_DEFAULT);
|
native int DrawPanelItem(Handle panel, const char[] text, style=ITEMDRAW_DEFAULT);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Draws a raw line of text on a panel, without any markup other than a newline.
|
* Draws a raw line of text on a panel, without any markup other than a newline.
|
||||||
|
@ -685,7 +981,7 @@ native DrawPanelItem(Handle:panel, const String:text[], style=ITEMDRAW_DEFAULT);
|
||||||
* @return True on success, false if raw lines are not supported.
|
* @return True on success, false if raw lines are not supported.
|
||||||
* @error Invalid Handle.
|
* @error Invalid Handle.
|
||||||
*/
|
*/
|
||||||
native DrawPanelText(Handle:panel, const String:text[]);
|
native bool DrawPanelText(Handle panel, const char[] text);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns whether or not the given drawing flags are supported by
|
* Returns whether or not the given drawing flags are supported by
|
||||||
|
@ -696,7 +992,7 @@ native DrawPanelText(Handle:panel, const String:text[]);
|
||||||
* @return True if item is drawable, false otherwise.
|
* @return True if item is drawable, false otherwise.
|
||||||
* @error Invalid Handle.
|
* @error Invalid Handle.
|
||||||
*/
|
*/
|
||||||
native CanPanelDrawFlags(Handle:panel, style);
|
native bool CanPanelDrawFlags(Handle panel, style);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the selectable key map of a panel. This is not supported by
|
* Sets the selectable key map of a panel. This is not supported by
|
||||||
|
@ -708,7 +1004,7 @@ native CanPanelDrawFlags(Handle:panel, style);
|
||||||
* then key 0 (bit 9) is automatically set.
|
* then key 0 (bit 9) is automatically set.
|
||||||
* @return True if supported, false otherwise.
|
* @return True if supported, false otherwise.
|
||||||
*/
|
*/
|
||||||
native bool:SetPanelKeys(Handle:panel, keys);
|
native bool SetPanelKeys(Handle panel, int keys);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sends a panel to a client. Unlike full menus, the handler
|
* Sends a panel to a client. Unlike full menus, the handler
|
||||||
|
@ -728,7 +1024,7 @@ native bool:SetPanelKeys(Handle:panel, keys);
|
||||||
* @return True on success, false on failure.
|
* @return True on success, false on failure.
|
||||||
* @error Invalid Handle.
|
* @error Invalid Handle.
|
||||||
*/
|
*/
|
||||||
native bool:SendPanelToClient(Handle:panel, client, MenuHandler:handler, time);
|
native bool SendPanelToClient(Handle panel, int client, MenuHandler handler, int time);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Returns the amount of text the menu can still hold. If this is
|
* @brief Returns the amount of text the menu can still hold. If this is
|
||||||
|
@ -742,7 +1038,7 @@ native bool:SendPanelToClient(Handle:panel, client, MenuHandler:handler, time);
|
||||||
* or -1 if there is no known limit.
|
* or -1 if there is no known limit.
|
||||||
* @error Invalid Handle.
|
* @error Invalid Handle.
|
||||||
*/
|
*/
|
||||||
native GetPanelTextRemaining(Handle:panel);
|
native int GetPanelTextRemaining(Handle panel);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Returns the current key position.
|
* @brief Returns the current key position.
|
||||||
|
@ -751,7 +1047,7 @@ native GetPanelTextRemaining(Handle:panel);
|
||||||
* @return Current key position starting at 1.
|
* @return Current key position starting at 1.
|
||||||
* @error Invalid Handle.
|
* @error Invalid Handle.
|
||||||
*/
|
*/
|
||||||
native GetPanelCurrentKey(Handle:panel);
|
native int GetPanelCurrentKey(Handle panel);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Sets the next key position. This cannot be used
|
* @brief Sets the next key position. This cannot be used
|
||||||
|
@ -763,7 +1059,7 @@ native GetPanelCurrentKey(Handle:panel);
|
||||||
* @return True on success, false otherwise.
|
* @return True on success, false otherwise.
|
||||||
* @error Invalid Handle.
|
* @error Invalid Handle.
|
||||||
*/
|
*/
|
||||||
native bool:SetPanelCurrentKey(Handle:panel, key);
|
native bool SetPanelCurrentKey(Handle panel, int key);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Redraws menu text from inside a MenuAction_DisplayItem callback.
|
* @brief Redraws menu text from inside a MenuAction_DisplayItem callback.
|
||||||
|
@ -771,7 +1067,7 @@ native bool:SetPanelCurrentKey(Handle:panel, key);
|
||||||
* @param text Menu text to draw.
|
* @param text Menu text to draw.
|
||||||
* @return Item position; must be returned via the callback.
|
* @return Item position; must be returned via the callback.
|
||||||
*/
|
*/
|
||||||
native RedrawMenuItem(const String:text[]);
|
native int RedrawMenuItem(const char[] text);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This function is provided for legacy code only. Some older plugins may use
|
* This function is provided for legacy code only. Some older plugins may use
|
||||||
|
@ -791,7 +1087,7 @@ native RedrawMenuItem(const String:text[]);
|
||||||
* @return True on success, false on failure.
|
* @return True on success, false on failure.
|
||||||
* @error Invalid client index, or radio menus not supported.
|
* @error Invalid client index, or radio menus not supported.
|
||||||
*/
|
*/
|
||||||
native bool:InternalShowMenu(client, const String:str[], time, keys=-1, MenuHandler:handler=MenuHandler:-1);
|
native bool InternalShowMenu(int client, const char[] str, int time, int keys=-1, MenuHandler handler=INVALID_FUNCTION);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieves voting information from MenuAction_VoteEnd.
|
* Retrieves voting information from MenuAction_VoteEnd.
|
||||||
|
@ -799,9 +1095,8 @@ native bool:InternalShowMenu(client, const String:str[], time, keys=-1, MenuHand
|
||||||
* @param param2 Second parameter of MenuAction_VoteEnd.
|
* @param param2 Second parameter of MenuAction_VoteEnd.
|
||||||
* @param winningVotes Number of votes received by the winning option.
|
* @param winningVotes Number of votes received by the winning option.
|
||||||
* @param totalVotes Number of total votes received.
|
* @param totalVotes Number of total votes received.
|
||||||
* @noreturn
|
|
||||||
*/
|
*/
|
||||||
stock GetMenuVoteInfo(param2, &winningVotes, &totalVotes)
|
stock void GetMenuVoteInfo(param2, &winningVotes, &totalVotes)
|
||||||
{
|
{
|
||||||
winningVotes = param2 & 0xFFFF;
|
winningVotes = param2 & 0xFFFF;
|
||||||
totalVotes = param2 >> 16;
|
totalVotes = param2 >> 16;
|
||||||
|
@ -815,7 +1110,7 @@ stock GetMenuVoteInfo(param2, &winningVotes, &totalVotes)
|
||||||
* @return True if voting is allowed, false if voting is in progress
|
* @return True if voting is allowed, false if voting is in progress
|
||||||
* or the cooldown is active.
|
* or the cooldown is active.
|
||||||
*/
|
*/
|
||||||
stock bool:IsNewVoteAllowed()
|
stock bool IsNewVoteAllowed()
|
||||||
{
|
{
|
||||||
if (IsVoteInProgress() || CheckVoteDelay() != 0)
|
if (IsVoteInProgress() || CheckVoteDelay() != 0)
|
||||||
{
|
{
|
||||||
|
|
23
env/include/profiler.inc
vendored
23
env/include/profiler.inc
vendored
|
@ -75,3 +75,26 @@ native StopProfiling(Handle:prof);
|
||||||
* @error Invalid Handle.
|
* @error Invalid Handle.
|
||||||
*/
|
*/
|
||||||
native Float:GetProfilerTime(Handle:prof);
|
native Float:GetProfilerTime(Handle:prof);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Mark the start of a profiling event.
|
||||||
|
*
|
||||||
|
* @param group Budget group. This can be "all" for a default, or a short
|
||||||
|
* description like "Timers" or "Events".
|
||||||
|
* @param name A name to attribute to this profiling event.
|
||||||
|
* @noreturn
|
||||||
|
*/
|
||||||
|
native EnterProfilingEvent(const String:group[], const String:name[]);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Mark the end of the last profiling event. This must be called in the same
|
||||||
|
* stack frame as StartProfilingEvent(). Not doing so, or throwing errors,
|
||||||
|
* will make the resulting profile very wrong.
|
||||||
|
*/
|
||||||
|
native LeaveProfilingEvent();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns true if the global profiler is enabled; false otherwise. It is
|
||||||
|
* not necessary to call this before Enter/LeaveProfilingEvent.
|
||||||
|
*/
|
||||||
|
native bool:IsProfilingActive();
|
||||||
|
|
308
env/include/protobuf.inc
vendored
308
env/include/protobuf.inc
vendored
|
@ -1,5 +1,5 @@
|
||||||
/**
|
/**
|
||||||
* vim: set ts=4 :
|
* vim: set ts=4 sw=4 tw=99 noet :
|
||||||
* =============================================================================
|
* =============================================================================
|
||||||
* SourceMod (C)2013 AlliedModders LLC. All rights reserved.
|
* SourceMod (C)2013 AlliedModders LLC. All rights reserved.
|
||||||
* =============================================================================
|
* =============================================================================
|
||||||
|
@ -37,6 +37,232 @@
|
||||||
|
|
||||||
#define PB_FIELD_NOT_REPEATED -1
|
#define PB_FIELD_NOT_REPEATED -1
|
||||||
|
|
||||||
|
methodmap Protobuf < Handle
|
||||||
|
{
|
||||||
|
// Reads an int32, uint32, sint32, fixed32, sfixed32, or enum value from a protobuf message.
|
||||||
|
//
|
||||||
|
// @param field Field name.
|
||||||
|
// @param index Index into repeated field.
|
||||||
|
// @return Integer value read.
|
||||||
|
// @error Non-existent field, or incorrect field type.
|
||||||
|
public native int ReadInt(const char[] field, int index = PB_FIELD_NOT_REPEATED);
|
||||||
|
|
||||||
|
// Reads a float or downcasted double from a protobuf message.
|
||||||
|
//
|
||||||
|
// @param field Field name.
|
||||||
|
// @param index Index into repeated field.
|
||||||
|
// @return Float value read.
|
||||||
|
// @error Non-existent field, or incorrect field type.
|
||||||
|
public native float ReadFloat(const char[] field, int index = PB_FIELD_NOT_REPEATED);
|
||||||
|
|
||||||
|
// Reads a bool from a protobuf message.
|
||||||
|
//
|
||||||
|
// @param field Field name.
|
||||||
|
// @param index Index into repeated field.
|
||||||
|
// @return Boolean value read.
|
||||||
|
// @error Non-existent field, or incorrect field type.
|
||||||
|
public native bool ReadBool(const char[] field, int index = PB_FIELD_NOT_REPEATED);
|
||||||
|
|
||||||
|
// Reads a string from a protobuf message.
|
||||||
|
//
|
||||||
|
// @param field Field name.
|
||||||
|
// @param buffer Destination string buffer.
|
||||||
|
// @param maxlength Maximum length of output string buffer.
|
||||||
|
// @param index Index into repeated field.
|
||||||
|
// @error Non-existent field, or incorrect field type.
|
||||||
|
public native void ReadString(const char[] field, char[] buffer, int maxlength, int index = PB_FIELD_NOT_REPEATED);
|
||||||
|
|
||||||
|
// Reads an RGBA color value from a protobuf message.
|
||||||
|
//
|
||||||
|
// @param field Field name.
|
||||||
|
// @param buffer Destination color buffer.
|
||||||
|
// @param index Index into repeated field.
|
||||||
|
// @error Non-existent field, or incorrect field type.
|
||||||
|
public native void ReadColor(const char[] field, int buffer[4], int index = PB_FIELD_NOT_REPEATED);
|
||||||
|
|
||||||
|
// Reads an XYZ angle value from a protobuf message.
|
||||||
|
//
|
||||||
|
// @param field Field name.
|
||||||
|
// @param buffer Destination angle buffer.
|
||||||
|
// @param index Index into repeated field.
|
||||||
|
// @error Non-existent field, or incorrect field type.
|
||||||
|
public native void ReadAngle(const char[] field, float buffer[3], int index = PB_FIELD_NOT_REPEATED);
|
||||||
|
|
||||||
|
// Reads an XYZ vector value from a protobuf message.
|
||||||
|
//
|
||||||
|
// @param pb protobuf handle.
|
||||||
|
// @param field Field name.
|
||||||
|
// @param buffer Destination vector buffer.
|
||||||
|
// @param index Index into repeated field.
|
||||||
|
// @error Non-existent field, or incorrect field type.
|
||||||
|
public native void ReadVector(const char[] field, float buffer[3], int index = PB_FIELD_NOT_REPEATED);
|
||||||
|
|
||||||
|
// Reads an XY vector value from a protobuf message.
|
||||||
|
//
|
||||||
|
// @param field Field name.
|
||||||
|
// @param buffer Destination vector buffer.
|
||||||
|
// @param index Index into repeated field.
|
||||||
|
// @error Non-existent field, or incorrect field type.
|
||||||
|
public native void ReadVector2D(const char[] field, float buffer[2], int index = PB_FIELD_NOT_REPEATED);
|
||||||
|
|
||||||
|
// Gets the number of elements in a repeated field of a protobuf message.
|
||||||
|
//
|
||||||
|
// @param field Field name.
|
||||||
|
// @return Number of elements in the field.
|
||||||
|
// @error Non-existent field, or incorrect field type.
|
||||||
|
public native int GetRepeatedFieldCount(const char[] field);
|
||||||
|
|
||||||
|
// Sets an int32, uint32, sint32, fixed32, sfixed32, or enum value on a protobuf message.
|
||||||
|
//
|
||||||
|
// @param field Field name.
|
||||||
|
// @param value Integer value to set.
|
||||||
|
// @param index Index into repeated field.
|
||||||
|
// @error Non-existent field, or incorrect field type.
|
||||||
|
public native int SetInt(const char[] field, int value, int index = PB_FIELD_NOT_REPEATED);
|
||||||
|
|
||||||
|
// Sets a float or double on a protobuf message.
|
||||||
|
//
|
||||||
|
// @param field Field name.
|
||||||
|
// @param value Float value to set.
|
||||||
|
// @param index Index into repeated field.
|
||||||
|
// @error Non-existent field, or incorrect field type.
|
||||||
|
public native void SetFloat(const char[] field, float value, int index = PB_FIELD_NOT_REPEATED);
|
||||||
|
|
||||||
|
// Sets a bool on a protobuf message.
|
||||||
|
//
|
||||||
|
// @param field Field name.
|
||||||
|
// @param value Boolean value to set.
|
||||||
|
// @param index Index into repeated field.
|
||||||
|
// @error Non-existent field, or incorrect field type.
|
||||||
|
public native void SetBool(const char[] field, bool value, int index = PB_FIELD_NOT_REPEATED);
|
||||||
|
|
||||||
|
// Sets a string on a protobuf message.
|
||||||
|
//
|
||||||
|
// @param field Field name.
|
||||||
|
// @param value String value to set.
|
||||||
|
// @param index Index into repeated field.
|
||||||
|
// @error Non-existent field, or incorrect field type.
|
||||||
|
public native void SetString(const char[] field, const char[] value, int index = PB_FIELD_NOT_REPEATED);
|
||||||
|
|
||||||
|
// Sets an RGBA color on a protobuf message.
|
||||||
|
//
|
||||||
|
// @param field Field name.
|
||||||
|
// @param color Color value to set.
|
||||||
|
// @param index Index into repeated field.
|
||||||
|
// @error Non-existent field, or incorrect field type.
|
||||||
|
public native void SetColor(const char[] field, const int color[4], int index = PB_FIELD_NOT_REPEATED);
|
||||||
|
|
||||||
|
// Sets an XYZ angle on a protobuf message.
|
||||||
|
//
|
||||||
|
// @param field Field name.
|
||||||
|
// @param angle Angle value to set.
|
||||||
|
// @param index Index into repeated field.
|
||||||
|
// @error Non-existent field, or incorrect field type.
|
||||||
|
public native void SetAngle(const char[] field, const float angle[3], int index = PB_FIELD_NOT_REPEATED);
|
||||||
|
|
||||||
|
// Sets an XYZ vector on a protobuf message.
|
||||||
|
//
|
||||||
|
// @param field Field name.
|
||||||
|
// @param vec Vector value to set.
|
||||||
|
// @param index Index into repeated field.
|
||||||
|
// @error Non-existent field, or incorrect field type.
|
||||||
|
public native void SetVector(const char[] field, const float vec[3], int index = PB_FIELD_NOT_REPEATED);
|
||||||
|
|
||||||
|
// Sets an XY vector on a protobuf message.
|
||||||
|
//
|
||||||
|
// @param field Field name.
|
||||||
|
// @param vec Vector value to set.
|
||||||
|
// @param index Index into repeated field.
|
||||||
|
// @error Non-existent field, or incorrect field type.
|
||||||
|
public native void SetVector2D(const char[] field, const float vec[2], int index = PB_FIELD_NOT_REPEATED);
|
||||||
|
|
||||||
|
// Add an int32, uint32, sint32, fixed32, sfixed32, or enum value to a protobuf message repeated field.
|
||||||
|
//
|
||||||
|
// @param field Field name.
|
||||||
|
// @param value Integer value to add.
|
||||||
|
// @error Non-existent field, or incorrect field type.
|
||||||
|
public native void AddInt(const char[] field, int value);
|
||||||
|
|
||||||
|
// Add a float or double to a protobuf message repeated field.
|
||||||
|
//
|
||||||
|
// @param field Field name.
|
||||||
|
// @param value Float value to add.
|
||||||
|
// @error Non-existent field, or incorrect field type.
|
||||||
|
public native void AddFloat(const char[] field, float value);
|
||||||
|
|
||||||
|
// Add a bool to a protobuf message repeated field.
|
||||||
|
//
|
||||||
|
// @param field Field name.
|
||||||
|
// @param value Boolean value to add.
|
||||||
|
// @error Non-existent field, or incorrect field type.
|
||||||
|
public native void AddBool(const char[] field, bool value);
|
||||||
|
|
||||||
|
// Add a string to a protobuf message repeated field.
|
||||||
|
//
|
||||||
|
// @param field Field name.
|
||||||
|
// @param value String value to add.
|
||||||
|
// @error Non-existent field, or incorrect field type.
|
||||||
|
public native void AddString(const char[] field, const char[] value);
|
||||||
|
|
||||||
|
// Add an RGBA color to a protobuf message repeated field.
|
||||||
|
//
|
||||||
|
// @param field Field name.
|
||||||
|
// @param color Color value to add.
|
||||||
|
// @error Non-existent field, or incorrect field type.
|
||||||
|
public native void AddColor(const char[] field, const int color[4]);
|
||||||
|
|
||||||
|
// Add an XYZ angle to a protobuf message repeated field.
|
||||||
|
//
|
||||||
|
// @param field Field name.
|
||||||
|
// @param angle Angle value to add.
|
||||||
|
// @error Non-existent field, or incorrect field type.
|
||||||
|
public native void AddAngle(const char[] field, const float angle[3]);
|
||||||
|
|
||||||
|
// Add an XYZ vector to a protobuf message repeated field.
|
||||||
|
//
|
||||||
|
// @param field Field name.
|
||||||
|
// @param vec Vector value to add.
|
||||||
|
// @error Non-existent field, or incorrect field type.
|
||||||
|
public native void AddVector(const char[] field, const float vec[3]);
|
||||||
|
|
||||||
|
// Add an XY vector to a protobuf message repeated field.
|
||||||
|
//
|
||||||
|
// @param field Field name.
|
||||||
|
// @param vec Vector value to add.
|
||||||
|
// @error Non-existent field, or incorrect field type.
|
||||||
|
public native void AddVector2D(const char[] field, const float vec[2]);
|
||||||
|
|
||||||
|
// Removes a value by index from a protobuf message repeated field.
|
||||||
|
//
|
||||||
|
// @param field Field name.
|
||||||
|
// @param index Index into repeated field.
|
||||||
|
// @error Non-existent field, or incorrect field type.
|
||||||
|
public native void RemoveRepeatedFieldValue(const char[] field, int index);
|
||||||
|
|
||||||
|
// Retrieve a handle to an embedded protobuf message in a protobuf message.
|
||||||
|
//
|
||||||
|
// @param field Field name.
|
||||||
|
// @return Protobuf handle to embedded message.
|
||||||
|
// @error Non-existent field, or incorrect field type.
|
||||||
|
public native Protobuf ReadMessage(const char[] field);
|
||||||
|
|
||||||
|
// Retrieve a handle to an embedded protobuf message in a protobuf message
|
||||||
|
// repeated field.
|
||||||
|
//
|
||||||
|
// @param field Field name.
|
||||||
|
// @param index Index in the repeated field.
|
||||||
|
// @return Protobuf handle to embedded message.
|
||||||
|
// @error Non-existent field, or incorrect field type.
|
||||||
|
public native Protobuf ReadRepeatedMessage(const char[] field, int index);
|
||||||
|
|
||||||
|
// Adds an embedded protobuf message to a protobuf message repeated field.
|
||||||
|
//
|
||||||
|
// @param field Field name.
|
||||||
|
// @return Protobuf handle to added, embedded message.
|
||||||
|
// @error Non-existent field, or incorrect field type.
|
||||||
|
public native Protobuf AddMessage(const char[] field);
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reads an int32, uint32, sint32, fixed32, sfixed32, or enum value from a protobuf message.
|
* Reads an int32, uint32, sint32, fixed32, sfixed32, or enum value from a protobuf message.
|
||||||
*
|
*
|
||||||
|
@ -46,7 +272,7 @@
|
||||||
* @return Integer value read.
|
* @return Integer value read.
|
||||||
* @error Invalid or incorrect Handle, non-existent field, or incorrect field type.
|
* @error Invalid or incorrect Handle, non-existent field, or incorrect field type.
|
||||||
*/
|
*/
|
||||||
native PbReadInt(Handle:pb, const String:field[], index=PB_FIELD_NOT_REPEATED);
|
native int PbReadInt(Handle pb, const char[] field, int index = PB_FIELD_NOT_REPEATED);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reads a float or downcasted double from a protobuf message.
|
* Reads a float or downcasted double from a protobuf message.
|
||||||
|
@ -57,7 +283,7 @@ native PbReadInt(Handle:pb, const String:field[], index=PB_FIELD_NOT_REPEATED);
|
||||||
* @return Float value read.
|
* @return Float value read.
|
||||||
* @error Invalid or incorrect Handle, non-existent field, or incorrect field type.
|
* @error Invalid or incorrect Handle, non-existent field, or incorrect field type.
|
||||||
*/
|
*/
|
||||||
native Float:PbReadFloat(Handle:pb, const String:field[], index=PB_FIELD_NOT_REPEATED);
|
native float PbReadFloat(Handle pb, const char[] field, int index = PB_FIELD_NOT_REPEATED);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reads a bool from a protobuf message.
|
* Reads a bool from a protobuf message.
|
||||||
|
@ -68,7 +294,7 @@ native Float:PbReadFloat(Handle:pb, const String:field[], index=PB_FIELD_NOT_REP
|
||||||
* @return Boolean value read.
|
* @return Boolean value read.
|
||||||
* @error Invalid or incorrect Handle, non-existent field, or incorrect field type.
|
* @error Invalid or incorrect Handle, non-existent field, or incorrect field type.
|
||||||
*/
|
*/
|
||||||
native bool:PbReadBool(Handle:pb, const String:field[], index=PB_FIELD_NOT_REPEATED);
|
native bool PbReadBool(Handle pb, const char[] field, int index = PB_FIELD_NOT_REPEATED);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reads a string from a protobuf message.
|
* Reads a string from a protobuf message.
|
||||||
|
@ -78,10 +304,9 @@ native bool:PbReadBool(Handle:pb, const String:field[], index=PB_FIELD_NOT_REPEA
|
||||||
* @param buffer Destination string buffer.
|
* @param buffer Destination string buffer.
|
||||||
* @param maxlength Maximum length of output string buffer.
|
* @param maxlength Maximum length of output string buffer.
|
||||||
* @param index Index into repeated field.
|
* @param index Index into repeated field.
|
||||||
* @noreturn
|
|
||||||
* @error Invalid or incorrect Handle, non-existent field, or incorrect field type.
|
* @error Invalid or incorrect Handle, non-existent field, or incorrect field type.
|
||||||
*/
|
*/
|
||||||
native PbReadString(Handle:pb, const String:field[], String:buffer[], maxlength, index=PB_FIELD_NOT_REPEATED);
|
native void PbReadString(Handle pb, const char[] field, String:buffer[], maxlength, int index = PB_FIELD_NOT_REPEATED);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reads an RGBA color value from a protobuf message.
|
* Reads an RGBA color value from a protobuf message.
|
||||||
|
@ -90,10 +315,9 @@ native PbReadString(Handle:pb, const String:field[], String:buffer[], maxlength,
|
||||||
* @param field Field name.
|
* @param field Field name.
|
||||||
* @param buffer Destination color buffer.
|
* @param buffer Destination color buffer.
|
||||||
* @param index Index into repeated field.
|
* @param index Index into repeated field.
|
||||||
* @noreturn
|
|
||||||
* @error Invalid or incorrect Handle, non-existent field, or incorrect field type.
|
* @error Invalid or incorrect Handle, non-existent field, or incorrect field type.
|
||||||
*/
|
*/
|
||||||
native PbReadColor(Handle:pb, const String:field[], buffer[4], index=PB_FIELD_NOT_REPEATED);
|
native void PbReadColor(Handle pb, const char[] field, buffer[4], int index = PB_FIELD_NOT_REPEATED);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reads an XYZ angle value from a protobuf message.
|
* Reads an XYZ angle value from a protobuf message.
|
||||||
|
@ -102,10 +326,9 @@ native PbReadColor(Handle:pb, const String:field[], buffer[4], index=PB_FIELD_NO
|
||||||
* @param field Field name.
|
* @param field Field name.
|
||||||
* @param buffer Destination angle buffer.
|
* @param buffer Destination angle buffer.
|
||||||
* @param index Index into repeated field.
|
* @param index Index into repeated field.
|
||||||
* @noreturn
|
|
||||||
* @error Invalid or incorrect Handle, non-existent field, or incorrect field type.
|
* @error Invalid or incorrect Handle, non-existent field, or incorrect field type.
|
||||||
*/
|
*/
|
||||||
native PbReadAngle(Handle:pb, const String:field[], Float:buffer[3], index=PB_FIELD_NOT_REPEATED);
|
native void PbReadAngle(Handle pb, const char[] field, float buffer[3], int index = PB_FIELD_NOT_REPEATED);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reads an XYZ vector value from a protobuf message.
|
* Reads an XYZ vector value from a protobuf message.
|
||||||
|
@ -114,10 +337,9 @@ native PbReadAngle(Handle:pb, const String:field[], Float:buffer[3], index=PB_FI
|
||||||
* @param field Field name.
|
* @param field Field name.
|
||||||
* @param buffer Destination vector buffer.
|
* @param buffer Destination vector buffer.
|
||||||
* @param index Index into repeated field.
|
* @param index Index into repeated field.
|
||||||
* @noreturn
|
|
||||||
* @error Invalid or incorrect Handle, non-existent field, or incorrect field type.
|
* @error Invalid or incorrect Handle, non-existent field, or incorrect field type.
|
||||||
*/
|
*/
|
||||||
native PbReadVector(Handle:pb, const String:field[], Float:buffer[3], index=PB_FIELD_NOT_REPEATED);
|
native void PbReadVector(Handle pb, const char[] field, float buffer[3], int index = PB_FIELD_NOT_REPEATED);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reads an XY vector value from a protobuf message.
|
* Reads an XY vector value from a protobuf message.
|
||||||
|
@ -126,10 +348,9 @@ native PbReadVector(Handle:pb, const String:field[], Float:buffer[3], index=PB_F
|
||||||
* @param field Field name.
|
* @param field Field name.
|
||||||
* @param buffer Destination vector buffer.
|
* @param buffer Destination vector buffer.
|
||||||
* @param index Index into repeated field.
|
* @param index Index into repeated field.
|
||||||
* @noreturn
|
|
||||||
* @error Invalid or incorrect Handle, non-existent field, or incorrect field type.
|
* @error Invalid or incorrect Handle, non-existent field, or incorrect field type.
|
||||||
*/
|
*/
|
||||||
native PbReadVector2D(Handle:pb, const String:field[], Float:buffer[2], index=PB_FIELD_NOT_REPEATED);
|
native void PbReadVector2D(Handle pb, const char[] field, float buffer[2], int index = PB_FIELD_NOT_REPEATED);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the number of elements in a repeated field of a protobuf message.
|
* Gets the number of elements in a repeated field of a protobuf message.
|
||||||
|
@ -139,7 +360,7 @@ native PbReadVector2D(Handle:pb, const String:field[], Float:buffer[2], index=PB
|
||||||
* @return Number of elements in the field.
|
* @return Number of elements in the field.
|
||||||
* @error Invalid or incorrect Handle, non-existent field, or incorrect field type.
|
* @error Invalid or incorrect Handle, non-existent field, or incorrect field type.
|
||||||
*/
|
*/
|
||||||
native PbGetRepeatedFieldCount(Handle:pb, const String:field[]);
|
native int PbGetRepeatedFieldCount(Handle pb, const char[] field);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets an int32, uint32, sint32, fixed32, sfixed32, or enum value on a protobuf message.
|
* Sets an int32, uint32, sint32, fixed32, sfixed32, or enum value on a protobuf message.
|
||||||
|
@ -148,10 +369,9 @@ native PbGetRepeatedFieldCount(Handle:pb, const String:field[]);
|
||||||
* @param field Field name.
|
* @param field Field name.
|
||||||
* @param value Integer value to set.
|
* @param value Integer value to set.
|
||||||
* @param index Index into repeated field.
|
* @param index Index into repeated field.
|
||||||
* @noreturn
|
|
||||||
* @error Invalid or incorrect Handle, non-existent field, or incorrect field type.
|
* @error Invalid or incorrect Handle, non-existent field, or incorrect field type.
|
||||||
*/
|
*/
|
||||||
native PbSetInt(Handle:pb, const String:field[], value, index=PB_FIELD_NOT_REPEATED);
|
native void PbSetInt(Handle pb, const char[] field, int value, int index = PB_FIELD_NOT_REPEATED);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets a float or double on a protobuf message.
|
* Sets a float or double on a protobuf message.
|
||||||
|
@ -160,10 +380,9 @@ native PbSetInt(Handle:pb, const String:field[], value, index=PB_FIELD_NOT_REPEA
|
||||||
* @param field Field name.
|
* @param field Field name.
|
||||||
* @param value Float value to set.
|
* @param value Float value to set.
|
||||||
* @param index Index into repeated field.
|
* @param index Index into repeated field.
|
||||||
* @noreturn
|
|
||||||
* @error Invalid or incorrect Handle, non-existent field, or incorrect field type.
|
* @error Invalid or incorrect Handle, non-existent field, or incorrect field type.
|
||||||
*/
|
*/
|
||||||
native PbSetFloat(Handle:pb, const String:field[], Float:value, index=PB_FIELD_NOT_REPEATED);
|
native void PbSetFloat(Handle pb, const char[] field, float value, int index = PB_FIELD_NOT_REPEATED);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets a bool on a protobuf message.
|
* Sets a bool on a protobuf message.
|
||||||
|
@ -172,10 +391,9 @@ native PbSetFloat(Handle:pb, const String:field[], Float:value, index=PB_FIELD_N
|
||||||
* @param field Field name.
|
* @param field Field name.
|
||||||
* @param value Boolean value to set.
|
* @param value Boolean value to set.
|
||||||
* @param index Index into repeated field.
|
* @param index Index into repeated field.
|
||||||
* @noreturn
|
|
||||||
* @error Invalid or incorrect Handle, non-existent field, or incorrect field type.
|
* @error Invalid or incorrect Handle, non-existent field, or incorrect field type.
|
||||||
*/
|
*/
|
||||||
native PbSetBool(Handle:pb, const String:field[], bool:value, index=PB_FIELD_NOT_REPEATED);
|
native void PbSetBool(Handle pb, const char[] field, bool value, int index = PB_FIELD_NOT_REPEATED);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets a string on a protobuf message.
|
* Sets a string on a protobuf message.
|
||||||
|
@ -184,10 +402,9 @@ native PbSetBool(Handle:pb, const String:field[], bool:value, index=PB_FIELD_NOT
|
||||||
* @param field Field name.
|
* @param field Field name.
|
||||||
* @param value String value to set.
|
* @param value String value to set.
|
||||||
* @param index Index into repeated field.
|
* @param index Index into repeated field.
|
||||||
* @noreturn
|
|
||||||
* @error Invalid or incorrect Handle, non-existent field, or incorrect field type.
|
* @error Invalid or incorrect Handle, non-existent field, or incorrect field type.
|
||||||
*/
|
*/
|
||||||
native PbSetString(Handle:pb, const String:field[], const String:value[], index=PB_FIELD_NOT_REPEATED);
|
native void PbSetString(Handle pb, const char[] field, const char[] value, int index = PB_FIELD_NOT_REPEATED);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets an RGBA color on a protobuf message.
|
* Sets an RGBA color on a protobuf message.
|
||||||
|
@ -196,10 +413,9 @@ native PbSetString(Handle:pb, const String:field[], const String:value[], index=
|
||||||
* @param field Field name.
|
* @param field Field name.
|
||||||
* @param color Color value to set.
|
* @param color Color value to set.
|
||||||
* @param index Index into repeated field.
|
* @param index Index into repeated field.
|
||||||
* @noreturn
|
|
||||||
* @error Invalid or incorrect Handle, non-existent field, or incorrect field type.
|
* @error Invalid or incorrect Handle, non-existent field, or incorrect field type.
|
||||||
*/
|
*/
|
||||||
native PbSetColor(Handle:pb, const String:field[], const color[4], index=PB_FIELD_NOT_REPEATED);
|
native void PbSetColor(Handle pb, const char[] field, const int color[4], int index = PB_FIELD_NOT_REPEATED);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets an XYZ angle on a protobuf message.
|
* Sets an XYZ angle on a protobuf message.
|
||||||
|
@ -208,10 +424,9 @@ native PbSetColor(Handle:pb, const String:field[], const color[4], index=PB_FIEL
|
||||||
* @param field Field name.
|
* @param field Field name.
|
||||||
* @param angle Angle value to set.
|
* @param angle Angle value to set.
|
||||||
* @param index Index into repeated field.
|
* @param index Index into repeated field.
|
||||||
* @noreturn
|
|
||||||
* @error Invalid or incorrect Handle, non-existent field, or incorrect field type.
|
* @error Invalid or incorrect Handle, non-existent field, or incorrect field type.
|
||||||
*/
|
*/
|
||||||
native PbSetAngle(Handle:pb, const String:field[], const Float:angle[3], index=PB_FIELD_NOT_REPEATED);
|
native void PbSetAngle(Handle pb, const char[] field, const float angle[3], int index = PB_FIELD_NOT_REPEATED);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets an XYZ vector on a protobuf message.
|
* Sets an XYZ vector on a protobuf message.
|
||||||
|
@ -220,10 +435,9 @@ native PbSetAngle(Handle:pb, const String:field[], const Float:angle[3], index=P
|
||||||
* @param field Field name.
|
* @param field Field name.
|
||||||
* @param vec Vector value to set.
|
* @param vec Vector value to set.
|
||||||
* @param index Index into repeated field.
|
* @param index Index into repeated field.
|
||||||
* @noreturn
|
|
||||||
* @error Invalid or incorrect Handle, non-existent field, or incorrect field type.
|
* @error Invalid or incorrect Handle, non-existent field, or incorrect field type.
|
||||||
*/
|
*/
|
||||||
native PbSetVector(Handle:pb, const String:field[], const Float:vec[3], index=PB_FIELD_NOT_REPEATED);
|
native void PbSetVector(Handle pb, const char[] field, const float vec[3], int index = PB_FIELD_NOT_REPEATED);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets an XY vector on a protobuf message.
|
* Sets an XY vector on a protobuf message.
|
||||||
|
@ -232,10 +446,9 @@ native PbSetVector(Handle:pb, const String:field[], const Float:vec[3], index=PB
|
||||||
* @param field Field name.
|
* @param field Field name.
|
||||||
* @param vec Vector value to set.
|
* @param vec Vector value to set.
|
||||||
* @param index Index into repeated field.
|
* @param index Index into repeated field.
|
||||||
* @noreturn
|
|
||||||
* @error Invalid or incorrect Handle, non-existent field, or incorrect field type.
|
* @error Invalid or incorrect Handle, non-existent field, or incorrect field type.
|
||||||
*/
|
*/
|
||||||
native PbSetVector2D(Handle:pb, const String:field[], const Float:vec[2], index=PB_FIELD_NOT_REPEATED);
|
native void PbSetVector2D(Handle pb, const char[] field, const float vec[2], int index = PB_FIELD_NOT_REPEATED);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add an int32, uint32, sint32, fixed32, sfixed32, or enum value to a protobuf message repeated field.
|
* Add an int32, uint32, sint32, fixed32, sfixed32, or enum value to a protobuf message repeated field.
|
||||||
|
@ -243,10 +456,9 @@ native PbSetVector2D(Handle:pb, const String:field[], const Float:vec[2], index=
|
||||||
* @param pb protobuf handle.
|
* @param pb protobuf handle.
|
||||||
* @param field Field name.
|
* @param field Field name.
|
||||||
* @param value Integer value to add.
|
* @param value Integer value to add.
|
||||||
* @noreturn
|
|
||||||
* @error Invalid or incorrect Handle, non-existent field, or incorrect field type.
|
* @error Invalid or incorrect Handle, non-existent field, or incorrect field type.
|
||||||
*/
|
*/
|
||||||
native PbAddInt(Handle:pb, const String:field[], value);
|
native void PbAddInt(Handle pb, const char[] field, int value);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add a float or double to a protobuf message repeated field.
|
* Add a float or double to a protobuf message repeated field.
|
||||||
|
@ -254,10 +466,9 @@ native PbAddInt(Handle:pb, const String:field[], value);
|
||||||
* @param pb protobuf handle.
|
* @param pb protobuf handle.
|
||||||
* @param field Field name.
|
* @param field Field name.
|
||||||
* @param value Float value to add.
|
* @param value Float value to add.
|
||||||
* @noreturn
|
|
||||||
* @error Invalid or incorrect Handle, non-existent field, or incorrect field type.
|
* @error Invalid or incorrect Handle, non-existent field, or incorrect field type.
|
||||||
*/
|
*/
|
||||||
native PbAddFloat(Handle:pb, const String:field[], Float:value);
|
native void PbAddFloat(Handle pb, const char[] field, float value);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add a bool to a protobuf message repeated field.
|
* Add a bool to a protobuf message repeated field.
|
||||||
|
@ -265,10 +476,9 @@ native PbAddFloat(Handle:pb, const String:field[], Float:value);
|
||||||
* @param pb protobuf handle.
|
* @param pb protobuf handle.
|
||||||
* @param field Field name.
|
* @param field Field name.
|
||||||
* @param value Boolean value to add.
|
* @param value Boolean value to add.
|
||||||
* @noreturn
|
|
||||||
* @error Invalid or incorrect Handle, non-existent field, or incorrect field type.
|
* @error Invalid or incorrect Handle, non-existent field, or incorrect field type.
|
||||||
*/
|
*/
|
||||||
native PbAddBool(Handle:pb, const String:field[], bool:value);
|
native void PbAddBool(Handle pb, const char[] field, bool value);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add a string to a protobuf message repeated field.
|
* Add a string to a protobuf message repeated field.
|
||||||
|
@ -276,10 +486,9 @@ native PbAddBool(Handle:pb, const String:field[], bool:value);
|
||||||
* @param pb protobuf handle.
|
* @param pb protobuf handle.
|
||||||
* @param field Field name.
|
* @param field Field name.
|
||||||
* @param value String value to add.
|
* @param value String value to add.
|
||||||
* @noreturn
|
|
||||||
* @error Invalid or incorrect Handle, non-existent field, or incorrect field type.
|
* @error Invalid or incorrect Handle, non-existent field, or incorrect field type.
|
||||||
*/
|
*/
|
||||||
native PbAddString(Handle:pb, const String:field[], const String:value[]);
|
native void PbAddString(Handle pb, const char[] field, const char[] value);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add an RGBA color to a protobuf message repeated field.
|
* Add an RGBA color to a protobuf message repeated field.
|
||||||
|
@ -287,10 +496,9 @@ native PbAddString(Handle:pb, const String:field[], const String:value[]);
|
||||||
* @param pb protobuf handle.
|
* @param pb protobuf handle.
|
||||||
* @param field Field name.
|
* @param field Field name.
|
||||||
* @param color Color value to add.
|
* @param color Color value to add.
|
||||||
* @noreturn
|
|
||||||
* @error Invalid or incorrect Handle, non-existent field, or incorrect field type.
|
* @error Invalid or incorrect Handle, non-existent field, or incorrect field type.
|
||||||
*/
|
*/
|
||||||
native PbAddColor(Handle:pb, const String:field[], const color[4]);
|
native void PbAddColor(Handle pb, const char[] field, const int color[4]);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add an XYZ angle to a protobuf message repeated field.
|
* Add an XYZ angle to a protobuf message repeated field.
|
||||||
|
@ -298,10 +506,9 @@ native PbAddColor(Handle:pb, const String:field[], const color[4]);
|
||||||
* @param pb protobuf handle.
|
* @param pb protobuf handle.
|
||||||
* @param field Field name.
|
* @param field Field name.
|
||||||
* @param angle Angle value to add.
|
* @param angle Angle value to add.
|
||||||
* @noreturn
|
|
||||||
* @error Invalid or incorrect Handle, non-existent field, or incorrect field type.
|
* @error Invalid or incorrect Handle, non-existent field, or incorrect field type.
|
||||||
*/
|
*/
|
||||||
native PbAddAngle(Handle:pb, const String:field[], const Float:angle[3]);
|
native void PbAddAngle(Handle pb, const char[] field, const float angle[3]);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add an XYZ vector to a protobuf message repeated field.
|
* Add an XYZ vector to a protobuf message repeated field.
|
||||||
|
@ -309,10 +516,9 @@ native PbAddAngle(Handle:pb, const String:field[], const Float:angle[3]);
|
||||||
* @param pb protobuf handle.
|
* @param pb protobuf handle.
|
||||||
* @param field Field name.
|
* @param field Field name.
|
||||||
* @param vec Vector value to add.
|
* @param vec Vector value to add.
|
||||||
* @noreturn
|
|
||||||
* @error Invalid or incorrect Handle, non-existent field, or incorrect field type.
|
* @error Invalid or incorrect Handle, non-existent field, or incorrect field type.
|
||||||
*/
|
*/
|
||||||
native PbAddVector(Handle:pb, const String:field[], const Float:vec[3]);
|
native void PbAddVector(Handle pb, const char[] field, const float vec[3]);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add an XY vector to a protobuf message repeated field.
|
* Add an XY vector to a protobuf message repeated field.
|
||||||
|
@ -320,10 +526,9 @@ native PbAddVector(Handle:pb, const String:field[], const Float:vec[3]);
|
||||||
* @param pb protobuf handle.
|
* @param pb protobuf handle.
|
||||||
* @param field Field name.
|
* @param field Field name.
|
||||||
* @param vec Vector value to add.
|
* @param vec Vector value to add.
|
||||||
* @noreturn
|
|
||||||
* @error Invalid or incorrect Handle, non-existent field, or incorrect field type.
|
* @error Invalid or incorrect Handle, non-existent field, or incorrect field type.
|
||||||
*/
|
*/
|
||||||
native PbAddVector2D(Handle:pb, const String:field[], const Float:vec[2]);
|
native void PbAddVector2D(Handle pb, const char[] field, const float vec[2]);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Removes a value by index from a protobuf message repeated field.
|
* Removes a value by index from a protobuf message repeated field.
|
||||||
|
@ -331,10 +536,9 @@ native PbAddVector2D(Handle:pb, const String:field[], const Float:vec[2]);
|
||||||
* @param pb protobuf handle.
|
* @param pb protobuf handle.
|
||||||
* @param field Field name.
|
* @param field Field name.
|
||||||
* @param index Index into repeated field.
|
* @param index Index into repeated field.
|
||||||
* @noreturn
|
|
||||||
* @error Invalid or incorrect Handle, non-existent field, or incorrect field type.
|
* @error Invalid or incorrect Handle, non-existent field, or incorrect field type.
|
||||||
*/
|
*/
|
||||||
native PbRemoveRepeatedFieldValue(Handle:pb, const String:field[], index);
|
native void PbRemoveRepeatedFieldValue(Handle pb, const char[] field, int index);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieve a handle to an embedded protobuf message in a protobuf message.
|
* Retrieve a handle to an embedded protobuf message in a protobuf message.
|
||||||
|
@ -344,7 +548,7 @@ native PbRemoveRepeatedFieldValue(Handle:pb, const String:field[], index);
|
||||||
* @return protobuf handle to embedded message.
|
* @return protobuf handle to embedded message.
|
||||||
* @error Invalid or incorrect Handle, non-existent field, or incorrect field type.
|
* @error Invalid or incorrect Handle, non-existent field, or incorrect field type.
|
||||||
*/
|
*/
|
||||||
native Handle:PbReadMessage(Handle:pb, const String:field[]);
|
native Handle PbReadMessage(Handle pb, const char[] field);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieve a handle to an embedded protobuf message in a protobuf message repeated field.
|
* Retrieve a handle to an embedded protobuf message in a protobuf message repeated field.
|
||||||
|
@ -355,7 +559,7 @@ native Handle:PbReadMessage(Handle:pb, const String:field[]);
|
||||||
* @return protobuf handle to embedded message.
|
* @return protobuf handle to embedded message.
|
||||||
* @error Invalid or incorrect Handle, non-existent field, or incorrect field type.
|
* @error Invalid or incorrect Handle, non-existent field, or incorrect field type.
|
||||||
*/
|
*/
|
||||||
native Handle:PbReadRepeatedMessage(Handle:pb, const String:field[], index);
|
native Handle PbReadRepeatedMessage(Handle pb, const char[] field, int index);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds an embedded protobuf message to a protobuf message repeated field.
|
* Adds an embedded protobuf message to a protobuf message repeated field.
|
||||||
|
@ -365,4 +569,4 @@ native Handle:PbReadRepeatedMessage(Handle:pb, const String:field[], index);
|
||||||
* @return protobuf handle to added, embedded message.
|
* @return protobuf handle to added, embedded message.
|
||||||
* @error Invalid or incorrect Handle, non-existent field, or incorrect field type.
|
* @error Invalid or incorrect Handle, non-existent field, or incorrect field type.
|
||||||
*/
|
*/
|
||||||
native Handle:PbAddMessage(Handle:pb, const String:field[]);
|
native Handle PbAddMessage(Handle pb, const char[] field);
|
||||||
|
|
29
env/include/regex.inc
vendored
29
env/include/regex.inc
vendored
|
@ -104,7 +104,7 @@ enum RegexError
|
||||||
* @param errcode Regex type error code encountered, if applicable.
|
* @param errcode Regex type error code encountered, if applicable.
|
||||||
* @return Valid regex handle on success, INVALID_HANDLE on failure.
|
* @return Valid regex handle on success, INVALID_HANDLE on failure.
|
||||||
*/
|
*/
|
||||||
native Handle:CompileRegex(const String:pattern[], flags = 0, String:error[]="", maxLen = 0, &RegexError:errcode = REGEX_ERROR_NONE);
|
native Regex CompileRegex(const char[] pattern, int flags = 0, char[] error="", int maxLen = 0, RegexError &errcode = REGEX_ERROR_NONE);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Matches a string against a pre-compiled regular expression pattern.
|
* Matches a string against a pre-compiled regular expression pattern.
|
||||||
|
@ -117,7 +117,7 @@ native Handle:CompileRegex(const String:pattern[], flags = 0, String:error[]="",
|
||||||
* @note Use the regex handle passed to this function to extract
|
* @note Use the regex handle passed to this function to extract
|
||||||
* matches with GetRegexSubString().
|
* matches with GetRegexSubString().
|
||||||
*/
|
*/
|
||||||
native MatchRegex(Handle:regex, const String:str[], &RegexError:ret = REGEX_ERROR_NONE);
|
native int MatchRegex(Handle regex, const char[] str, RegexError &ret = REGEX_ERROR_NONE);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a matched substring from a regex handle.
|
* Returns a matched substring from a regex handle.
|
||||||
|
@ -130,7 +130,14 @@ native MatchRegex(Handle:regex, const String:str[], &RegexError:ret = REGEX_ERRO
|
||||||
* @param maxlen The maximum string length of the buffer.
|
* @param maxlen The maximum string length of the buffer.
|
||||||
* @return True if a substring was found, False on fail/error
|
* @return True if a substring was found, False on fail/error
|
||||||
*/
|
*/
|
||||||
native bool:GetRegexSubString(Handle:regex, str_id, String:buffer[], maxlen);
|
native bool GetRegexSubString(Handle regex, int str_id, char[] buffer, int maxlen);
|
||||||
|
|
||||||
|
methodmap Regex < Handle
|
||||||
|
{
|
||||||
|
public Regex() = CompileRegex;
|
||||||
|
public Match() = MatchRegex;
|
||||||
|
public GetSubString() = GetRegexSubString;
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Matches a string against a regular expression pattern.
|
* Matches a string against a regular expression pattern.
|
||||||
|
@ -146,19 +153,15 @@ native bool:GetRegexSubString(Handle:regex, str_id, String:buffer[], maxlen);
|
||||||
* @param maxLen Maximum length of the error buffer.
|
* @param maxLen Maximum length of the error buffer.
|
||||||
* @return Number of substrings found or -1 on failure.
|
* @return Number of substrings found or -1 on failure.
|
||||||
*/
|
*/
|
||||||
stock SimpleRegexMatch(const String:str[], const String:pattern[], flags = 0, String:error[]="", maxLen = 0)
|
stock int SimpleRegexMatch(const char[] str, const char[] pattern, int flags = 0, char[] error="", int maxLen = 0)
|
||||||
{
|
{
|
||||||
new Handle:regex = CompileRegex(pattern, flags, error, maxLen);
|
Regex regex = new Regex(pattern, flags, error, maxLen);
|
||||||
|
if (!regex)
|
||||||
if (regex == INVALID_HANDLE)
|
|
||||||
{
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
|
||||||
|
|
||||||
new substrings = MatchRegex(regex, str);
|
|
||||||
|
|
||||||
CloseHandle(regex);
|
|
||||||
|
|
||||||
|
int substrings = regex.Match(str);
|
||||||
|
delete regex;
|
||||||
|
|
||||||
return substrings;
|
return substrings;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
345
env/include/sdkhooks-2.2.inc
vendored
345
env/include/sdkhooks-2.2.inc
vendored
|
@ -1,345 +0,0 @@
|
||||||
#if defined _sdkhooks_included
|
|
||||||
#endinput
|
|
||||||
#endif
|
|
||||||
#define _sdkhooks_included
|
|
||||||
|
|
||||||
// this is obviously _not_ a robust check, but it will solve most conflict and is clean
|
|
||||||
#if !defined DMG_GENERIC
|
|
||||||
#define DMG_GENERIC 0 // generic damage was done
|
|
||||||
#define DMG_CRUSH (1 << 0) // crushed by falling or moving object.
|
|
||||||
// NOTE: It's assumed crush damage is occurring as a result of physics collision, so no extra physics force is generated by crush damage.
|
|
||||||
// DON'T use DMG_CRUSH when damaging entities unless it's the result of a physics collision. You probably want DMG_CLUB instead.
|
|
||||||
#define DMG_BULLET (1 << 1) // shot
|
|
||||||
#define DMG_SLASH (1 << 2) // cut, clawed, stabbed
|
|
||||||
#define DMG_BURN (1 << 3) // heat burned
|
|
||||||
#define DMG_VEHICLE (1 << 4) // hit by a vehicle
|
|
||||||
#define DMG_FALL (1 << 5) // fell too far
|
|
||||||
#define DMG_BLAST (1 << 6) // explosive blast damage
|
|
||||||
#define DMG_CLUB (1 << 7) // crowbar, punch, headbutt
|
|
||||||
#define DMG_SHOCK (1 << 8) // electric shock
|
|
||||||
#define DMG_SONIC (1 << 9) // sound pulse shockwave
|
|
||||||
#define DMG_ENERGYBEAM (1 << 10) // laser or other high energy beam
|
|
||||||
#define DMG_PREVENT_PHYSICS_FORCE (1 << 11) // Prevent a physics force
|
|
||||||
#define DMG_NEVERGIB (1 << 12) // with this bit OR'd in, no damage type will be able to gib victims upon death
|
|
||||||
#define DMG_ALWAYSGIB (1 << 13) // with this bit OR'd in, any damage type can be made to gib victims upon death.
|
|
||||||
#define DMG_DROWN (1 << 14) // Drowning
|
|
||||||
#define DMG_PARALYZE (1 << 15) // slows affected creature down
|
|
||||||
#define DMG_NERVEGAS (1 << 16) // nerve toxins, very bad
|
|
||||||
#define DMG_POISON (1 << 17) // blood poisoning - heals over time like drowning damage
|
|
||||||
#define DMG_RADIATION (1 << 18) // radiation exposure
|
|
||||||
#define DMG_DROWNRECOVER (1 << 19) // drowning recovery
|
|
||||||
#define DMG_ACID (1 << 20) // toxic chemicals or acid burns
|
|
||||||
#define DMG_SLOWBURN (1 << 21) // in an oven
|
|
||||||
#define DMG_REMOVENORAGDOLL (1 << 22) // with this bit OR'd in, no ragdoll will be created, and the target will be quietly removed.
|
|
||||||
// use this to kill an entity that you've already got a server-side ragdoll for
|
|
||||||
#define DMG_PHYSGUN (1 << 23) // Hit by manipulator. Usually doesn't do any damage.
|
|
||||||
#define DMG_PLASMA (1 << 24) // Shot by Cremator
|
|
||||||
#define DMG_AIRBOAT (1 << 25) // Hit by the airboat's gun
|
|
||||||
#define DMG_DISSOLVE (1 << 26) // Dissolving!
|
|
||||||
#define DMG_BLAST_SURFACE (1 << 27) // A blast on the surface of water that cannot harm things underwater
|
|
||||||
#define DMG_DIRECT (1 << 28)
|
|
||||||
#define DMG_BUCKSHOT (1 << 29) // not quite a bullet. Little, rounder, different.
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if !defined DMG_CRIT
|
|
||||||
// TF2 crits and minicrits
|
|
||||||
#define DMG_CRIT DMG_ACID
|
|
||||||
#endif
|
|
||||||
|
|
||||||
enum SDKHookType
|
|
||||||
{
|
|
||||||
SDKHook_EndTouch,
|
|
||||||
SDKHook_FireBulletsPost,
|
|
||||||
SDKHook_OnTakeDamage,
|
|
||||||
SDKHook_OnTakeDamagePost,
|
|
||||||
SDKHook_PreThink,
|
|
||||||
SDKHook_PostThink,
|
|
||||||
SDKHook_SetTransmit,
|
|
||||||
SDKHook_Spawn,
|
|
||||||
SDKHook_StartTouch,
|
|
||||||
SDKHook_Think,
|
|
||||||
SDKHook_Touch,
|
|
||||||
SDKHook_TraceAttack,
|
|
||||||
SDKHook_TraceAttackPost,
|
|
||||||
SDKHook_WeaponCanSwitchTo,
|
|
||||||
SDKHook_WeaponCanUse,
|
|
||||||
SDKHook_WeaponDrop,
|
|
||||||
SDKHook_WeaponEquip,
|
|
||||||
SDKHook_WeaponSwitch,
|
|
||||||
SDKHook_ShouldCollide,
|
|
||||||
SDKHook_PreThinkPost,
|
|
||||||
SDKHook_PostThinkPost,
|
|
||||||
SDKHook_ThinkPost,
|
|
||||||
SDKHook_EndTouchPost,
|
|
||||||
SDKHook_GroundEntChangedPost,
|
|
||||||
SDKHook_SpawnPost,
|
|
||||||
SDKHook_StartTouchPost,
|
|
||||||
SDKHook_TouchPost,
|
|
||||||
SDKHook_VPhysicsUpdate,
|
|
||||||
SDKHook_VPhysicsUpdatePost,
|
|
||||||
SDKHook_WeaponCanSwitchToPost,
|
|
||||||
SDKHook_WeaponCanUsePost,
|
|
||||||
SDKHook_WeaponDropPost,
|
|
||||||
SDKHook_WeaponEquipPost,
|
|
||||||
SDKHook_WeaponSwitchPost,
|
|
||||||
SDKHook_Use,
|
|
||||||
SDKHook_UsePost
|
|
||||||
};
|
|
||||||
|
|
||||||
/*
|
|
||||||
Alphabetized for easy readability
|
|
||||||
|
|
||||||
SDKHook_EndTouch,
|
|
||||||
SDKHook_EndTouchPost,
|
|
||||||
|
|
||||||
SDKHook_FireBulletsPost,
|
|
||||||
|
|
||||||
SDKHook_GroundEntChangedPost,
|
|
||||||
|
|
||||||
SDKHook_OnTakeDamage,
|
|
||||||
SDKHook_OnTakeDamagePost,
|
|
||||||
|
|
||||||
SDKHook_PreThink,
|
|
||||||
SDKHook_PreThinkPost,
|
|
||||||
|
|
||||||
SDKHook_PostThink,
|
|
||||||
SDKHook_PostThinkPost,
|
|
||||||
|
|
||||||
SDKHook_SetTransmit,
|
|
||||||
|
|
||||||
SDKHook_ShouldCollide,
|
|
||||||
|
|
||||||
SDKHook_Spawn,
|
|
||||||
SDKHook_SpawnPost,
|
|
||||||
|
|
||||||
SDKHook_StartTouch,
|
|
||||||
SDKHook_StartTouchPost,
|
|
||||||
|
|
||||||
SDKHook_Think,
|
|
||||||
SDKHook_ThinkPost,
|
|
||||||
|
|
||||||
SDKHook_Touch,
|
|
||||||
SDKHook_TouchPost,
|
|
||||||
|
|
||||||
SDKHook_TraceAttack,
|
|
||||||
SDKHook_TraceAttackPost,
|
|
||||||
|
|
||||||
SDKHook_Use,
|
|
||||||
SDKHook_UsePost,
|
|
||||||
|
|
||||||
SDKHook_VPhysicsUpdate,
|
|
||||||
SDKHook_VPhysicsUpdatePost,
|
|
||||||
|
|
||||||
SDKHook_WeaponCanSwitchTo,
|
|
||||||
SDKHook_WeaponCanSwitchToPost,
|
|
||||||
|
|
||||||
SDKHook_WeaponCanUse,
|
|
||||||
SDKHook_WeaponCanUsePost,
|
|
||||||
|
|
||||||
SDKHook_WeaponDrop,
|
|
||||||
SDKHook_WeaponDropPost,
|
|
||||||
|
|
||||||
SDKHook_WeaponEquip,
|
|
||||||
SDKHook_WeaponEquipPost,
|
|
||||||
|
|
||||||
SDKHook_WeaponSwitch,
|
|
||||||
SDKHook_WeaponSwitchPost
|
|
||||||
*/
|
|
||||||
|
|
||||||
enum UseType
|
|
||||||
{
|
|
||||||
Use_Off,
|
|
||||||
Use_On,
|
|
||||||
Use_Set,
|
|
||||||
Use_Toggle
|
|
||||||
};
|
|
||||||
|
|
||||||
funcenum SDKHookCB
|
|
||||||
{
|
|
||||||
// PreThink/Post
|
|
||||||
// PostThink/Post
|
|
||||||
public(client),
|
|
||||||
|
|
||||||
// GroundEntChanged
|
|
||||||
// Spawn/Post
|
|
||||||
// Think/Post
|
|
||||||
// VPhysicsUpdate/Post
|
|
||||||
public(entity),
|
|
||||||
|
|
||||||
// EndTouch
|
|
||||||
// StartTouch
|
|
||||||
// Touch
|
|
||||||
Action:public(entity, other),
|
|
||||||
|
|
||||||
// EndTouchPost
|
|
||||||
// StartTouchPost
|
|
||||||
// TouchPost
|
|
||||||
public(entity, other),
|
|
||||||
|
|
||||||
// SetTransmit
|
|
||||||
Action:public(entity, client),
|
|
||||||
|
|
||||||
// WeaponCanSwitchTo
|
|
||||||
// WeaponCanUse
|
|
||||||
// WeaponDrop
|
|
||||||
// WeaponEquip
|
|
||||||
// WeaponSwitch
|
|
||||||
Action:public(client, weapon),
|
|
||||||
|
|
||||||
// WeaponCanSwitchToPost
|
|
||||||
// WeaponCanUsePost
|
|
||||||
// WeaponDropPost
|
|
||||||
// WeaponEquipPost
|
|
||||||
// WeaponSwitchPost
|
|
||||||
public(client, weapon),
|
|
||||||
|
|
||||||
// OnTakeDamage
|
|
||||||
// Note: Force application is dependent on game and damage type(s)
|
|
||||||
Action:public(victim, &attacker, &inflictor, &Float:damage, &damagetype),
|
|
||||||
Action:public(victim, &attacker, &inflictor, &Float:damage, &damagetype, &weapon, Float:damageForce[3], Float:damagePosition[3]),
|
|
||||||
|
|
||||||
// OnTakeDamagePost
|
|
||||||
public(victim, attacker, inflictor, Float:damage, damagetype),
|
|
||||||
public(victim, attacker, inflictor, Float:damage, damagetype, weapon, const Float:damageForce[3], const Float:damagePosition[3]),
|
|
||||||
|
|
||||||
// FireBulletsPost
|
|
||||||
public(client, shots, const String:weaponname[]),
|
|
||||||
|
|
||||||
// TraceAttack
|
|
||||||
Action:public(victim, &attacker, &inflictor, &Float:damage, &damagetype, &ammotype, hitbox, hitgroup),
|
|
||||||
|
|
||||||
// TraceAttackPost
|
|
||||||
public(victim, attacker, inflictor, Float:damage, damagetype, ammotype, hitbox, hitgroup),
|
|
||||||
|
|
||||||
// ShouldCollide
|
|
||||||
bool:public(entity, collisiongroup, contentsmask, bool:originalResult),
|
|
||||||
|
|
||||||
// Use
|
|
||||||
Action:public(entity, activator, caller, UseType:type, Float:value),
|
|
||||||
|
|
||||||
// UsePost
|
|
||||||
public(entity, activator, caller, UseType:type, Float:value)
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief When an entity is created
|
|
||||||
*
|
|
||||||
* @param entity Entity index
|
|
||||||
* @param classname Class name
|
|
||||||
* @noreturn
|
|
||||||
*/
|
|
||||||
forward OnEntityCreated(entity, const String:classname[]);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief When an entity is destroyed
|
|
||||||
*
|
|
||||||
* @param entity Entity index
|
|
||||||
* @noreturn
|
|
||||||
*/
|
|
||||||
forward OnEntityDestroyed(entity);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief When the game description is retrieved
|
|
||||||
*
|
|
||||||
* @param gameDesc Game description
|
|
||||||
* @noreturn
|
|
||||||
*/
|
|
||||||
forward Action:OnGetGameDescription(String:gameDesc[64]);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief When the level is initialized
|
|
||||||
*
|
|
||||||
* @param mapName Name of the map
|
|
||||||
* @param mapEntities Entities of the map
|
|
||||||
* @noreturn
|
|
||||||
*/
|
|
||||||
forward Action:OnLevelInit(const String:mapName[], String:mapEntities[2097152]);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Hooks an entity
|
|
||||||
*
|
|
||||||
* @param entity Entity index
|
|
||||||
* @param type Type of function to hook
|
|
||||||
* @param callback Function to call when hook is called
|
|
||||||
* @noreturn
|
|
||||||
*/
|
|
||||||
native SDKHook(entity, SDKHookType:type, SDKHookCB:callback);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Hooks an entity
|
|
||||||
*
|
|
||||||
* @param entity Entity index
|
|
||||||
* @param type Type of function to hook
|
|
||||||
* @param callback Function to call when hook is called
|
|
||||||
* @return bool Hook Successful
|
|
||||||
*/
|
|
||||||
native bool:SDKHookEx(entity, SDKHookType:type, SDKHookCB:callback);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Unhooks an entity
|
|
||||||
*
|
|
||||||
* @param entity Entity index
|
|
||||||
* @param type Type of function to unhook
|
|
||||||
* @param callback Callback function to unhook
|
|
||||||
* @noreturn
|
|
||||||
*/
|
|
||||||
native SDKUnhook(entity, SDKHookType:type, SDKHookCB:callback);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Applies damage to an entity
|
|
||||||
*
|
|
||||||
* @note Force application is dependent on game and damage type(s)
|
|
||||||
*
|
|
||||||
* @param entity Entity index taking damage
|
|
||||||
* @param inflictor Inflictor entity index
|
|
||||||
* @param attacker Attacker entity index
|
|
||||||
* @param damage Amount of damage
|
|
||||||
* @param damageType Bitfield of damage types
|
|
||||||
* @param weapon Weapon index (orangebox and later) or -1 for unspecified
|
|
||||||
* @param damageForce Velocity of damage force
|
|
||||||
* @param damagePosition Origin of damage
|
|
||||||
* @noreturn
|
|
||||||
*/
|
|
||||||
native SDKHooks_TakeDamage(entity, inflictor, attacker, Float:damage, damageType=DMG_GENERIC, weapon=-1, const Float:damageForce[3]=NULL_VECTOR, const Float:damagePosition[3]=NULL_VECTOR);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Forces a client to drop the specified weapon
|
|
||||||
*
|
|
||||||
* @param client Client index.
|
|
||||||
* @param weapon Weapon entity index.
|
|
||||||
* @param vecTarget Location to toss weapon to, or NULL_VECTOR for default.
|
|
||||||
* @param vecVelocity Velocity at which to toss weapon, or NULL_VECTOR for default.
|
|
||||||
* @noreturn
|
|
||||||
* @error Invalid client or weapon entity, weapon not owned by client.
|
|
||||||
*/
|
|
||||||
native SDKHooks_DropWeapon(client, weapon, const Float:vecTarget[3]=NULL_VECTOR, const Float:vecVelocity[3]=NULL_VECTOR);
|
|
||||||
|
|
||||||
/** Do Not Edit Below This Line **/
|
|
||||||
|
|
||||||
public Extension:__ext_sdkhooks =
|
|
||||||
{
|
|
||||||
name = "sdkhooks",
|
|
||||||
file = "sdkhooks.ext",
|
|
||||||
#if defined AUTOLOAD_EXTENSIONS
|
|
||||||
autoload = 1,
|
|
||||||
#else
|
|
||||||
autoload = 0,
|
|
||||||
#endif
|
|
||||||
#if defined REQUIRE_EXTENSIONS
|
|
||||||
required = 1,
|
|
||||||
#else
|
|
||||||
required = 0,
|
|
||||||
#endif
|
|
||||||
};
|
|
||||||
|
|
||||||
#if !defined REQUIRE_EXTENSIONS
|
|
||||||
public __ext_sdkhooks_SetNTVOptional()
|
|
||||||
{
|
|
||||||
MarkNativeAsOptional("SDKHook");
|
|
||||||
MarkNativeAsOptional("SDKHookEx");
|
|
||||||
MarkNativeAsOptional("SDKUnhook");
|
|
||||||
MarkNativeAsOptional("SDKHooks_TakeDamage");
|
|
||||||
MarkNativeAsOptional("SDKHooks_DropWeapon");
|
|
||||||
}
|
|
||||||
#endif
|
|
63
env/include/sdkhooks.inc
vendored
63
env/include/sdkhooks.inc
vendored
|
@ -117,10 +117,17 @@ enum SDKHookType
|
||||||
SDKHook_Reload,
|
SDKHook_Reload,
|
||||||
SDKHook_ReloadPost,
|
SDKHook_ReloadPost,
|
||||||
SDKHook_GetMaxHealth, /**< ep2v and later */
|
SDKHook_GetMaxHealth, /**< ep2v and later */
|
||||||
|
SDKHook_Blocked,
|
||||||
|
SDKHook_BlockedPost,
|
||||||
|
SDKHook_OnTakeDamageAlive,
|
||||||
|
SDKHook_OnTakeDamageAlivePost,
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Alphabetized for easy readability
|
Alphabetized for easy readability
|
||||||
|
|
||||||
|
SDKHook_Blocked,
|
||||||
|
SDKHook_BlockedPost,
|
||||||
|
|
||||||
SDKHook_EndTouch,
|
SDKHook_EndTouch,
|
||||||
SDKHook_EndTouchPost,
|
SDKHook_EndTouchPost,
|
||||||
|
@ -134,6 +141,9 @@ enum SDKHookType
|
||||||
SDKHook_OnTakeDamage,
|
SDKHook_OnTakeDamage,
|
||||||
SDKHook_OnTakeDamagePost,
|
SDKHook_OnTakeDamagePost,
|
||||||
|
|
||||||
|
SDKHook_OnTakeDamageAlive,
|
||||||
|
SDKHook_OnTakeDamageAlivePost,
|
||||||
|
|
||||||
SDKHook_PreThink,
|
SDKHook_PreThink,
|
||||||
SDKHook_PreThinkPost,
|
SDKHook_PreThinkPost,
|
||||||
|
|
||||||
|
@ -192,90 +202,95 @@ enum UseType
|
||||||
Use_Toggle
|
Use_Toggle
|
||||||
};
|
};
|
||||||
|
|
||||||
funcenum SDKHookCB
|
typeset SDKHookCB
|
||||||
{
|
{
|
||||||
// PreThink/Post
|
// PreThink/Post
|
||||||
// PostThink/Post
|
// PostThink/Post
|
||||||
public(client),
|
function void (int client);
|
||||||
|
|
||||||
// Spawn
|
// Spawn
|
||||||
Action:public(entity),
|
function Action (int entity);
|
||||||
|
|
||||||
// GroundEntChanged
|
// GroundEntChanged
|
||||||
// SpawnPost
|
// SpawnPost
|
||||||
// Think/Post
|
// Think/Post
|
||||||
// VPhysicsUpdate/Post
|
// VPhysicsUpdate/Post
|
||||||
public(entity),
|
function void (int entity);
|
||||||
|
|
||||||
// EndTouch
|
// EndTouch
|
||||||
// StartTouch
|
// StartTouch
|
||||||
// Touch
|
// Touch
|
||||||
Action:public(entity, other),
|
// Blocked
|
||||||
|
function Action (int entity, int other);
|
||||||
|
|
||||||
// EndTouchPost
|
// EndTouchPost
|
||||||
// StartTouchPost
|
// StartTouchPost
|
||||||
// TouchPost
|
// TouchPost
|
||||||
public(entity, other),
|
function void (int entity, int other);
|
||||||
|
|
||||||
// SetTransmit
|
// SetTransmit
|
||||||
Action:public(entity, client),
|
function Action (int entity, int client);
|
||||||
|
|
||||||
// WeaponCanSwitchTo
|
// WeaponCanSwitchTo
|
||||||
// WeaponCanUse
|
// WeaponCanUse
|
||||||
// WeaponDrop
|
// WeaponDrop
|
||||||
// WeaponEquip
|
// WeaponEquip
|
||||||
// WeaponSwitch
|
// WeaponSwitch
|
||||||
Action:public(client, weapon),
|
function Action (int client, int weapon);
|
||||||
|
|
||||||
// WeaponCanSwitchToPost
|
// WeaponCanSwitchToPost
|
||||||
// WeaponCanUsePost
|
// WeaponCanUsePost
|
||||||
// WeaponDropPost
|
// WeaponDropPost
|
||||||
// WeaponEquipPost
|
// WeaponEquipPost
|
||||||
// WeaponSwitchPost
|
// WeaponSwitchPost
|
||||||
public(client, weapon),
|
function void (int client, int weapon);
|
||||||
|
|
||||||
// GetMaxHealth (ep2v and later)
|
// GetMaxHealth (ep2v and later)
|
||||||
Action:public(entity, &maxhealth),
|
function Action (int entity, int &maxhealth);
|
||||||
|
|
||||||
// OnTakeDamage
|
// OnTakeDamage
|
||||||
|
// OnTakeDamageAlive
|
||||||
// Note: The weapon parameter is not used by all games and damage sources.
|
// Note: The weapon parameter is not used by all games and damage sources.
|
||||||
// Note: Force application is dependent on game and damage type(s)
|
// Note: Force application is dependent on game and damage type(s)
|
||||||
// SDKHooks 1.0+
|
// SDKHooks 1.0+
|
||||||
Action:public(victim, &attacker, &inflictor, &Float:damage, &damagetype),
|
function Action (int victim, int &attacker, int &inflictor, float &damage, int &damagetype);
|
||||||
// SDKHooks 2.0+
|
// SDKHooks 2.0+
|
||||||
Action:public(victim, &attacker, &inflictor, &Float:damage, &damagetype, &weapon, Float:damageForce[3], Float:damagePosition[3]),
|
function Action (int victim, int &attacker, int &inflictor, float &damage, int &damagetype, int &weapon, float damageForce[3], float damagePosition[3]);
|
||||||
// SDKHooks 2.1+ (can check for support at runtime using GetFeatureStatus on SDKHook_DmgCustomInOTD capability.
|
// SDKHooks 2.1+ (can check for support at runtime using GetFeatureStatus on SDKHook_DmgCustomInOTD capability.
|
||||||
// DON'T attempt to access 'damagecustom' var if feature status != available
|
// DON'T attempt to access 'damagecustom' var if feature status != available
|
||||||
Action:public(victim, &attacker, &inflictor, &Float:damage, &damagetype, &weapon,
|
function Action (int victim, int &attacker, int &inflictor, float &damage, int &damagetype, int &weapon,
|
||||||
Float:damageForce[3], Float:damagePosition[3], damagecustom),
|
float damageForce[3], float damagePosition[3], int damagecustom);
|
||||||
|
|
||||||
// OnTakeDamagePost
|
// OnTakeDamagePost
|
||||||
public(victim, attacker, inflictor, Float:damage, damagetype),
|
// OnTakeDamageAlivePost
|
||||||
public(victim, attacker, inflictor, Float:damage, damagetype, weapon, const Float:damageForce[3], const Float:damagePosition[3]),
|
function void (int victim, int attacker, int inflictor, float damage, int damagetype);
|
||||||
|
function void (int victim, int attacker, int inflictor, float damage, int damagetype, int weapon, const float damageForce[3], const float damagePosition[3]);
|
||||||
|
function void (int victim, int attacker, int inflictor, float damage, int damagetype, int weapon,
|
||||||
|
const float damageForce[3], const float damagePosition[3], int damagecustom);
|
||||||
|
|
||||||
// FireBulletsPost
|
// FireBulletsPost
|
||||||
public(client, shots, const String:weaponname[]),
|
function void (int client, int shots, const char[] weaponname);
|
||||||
|
|
||||||
// TraceAttack
|
// TraceAttack
|
||||||
Action:public(victim, &attacker, &inflictor, &Float:damage, &damagetype, &ammotype, hitbox, hitgroup),
|
function Action (int victim, int &attacker, int &inflictor, float &damage, int &damagetype, int &ammotype, int hitbox, int hitgroup);
|
||||||
|
|
||||||
// TraceAttackPost
|
// TraceAttackPost
|
||||||
public(victim, attacker, inflictor, Float:damage, damagetype, ammotype, hitbox, hitgroup),
|
function void (int victim, int attacker, int inflictor, float damage, int damagetype, int ammotype, int hitbox, int hitgroup);
|
||||||
|
|
||||||
// ShouldCollide
|
// ShouldCollide
|
||||||
bool:public(entity, collisiongroup, contentsmask, bool:originalResult),
|
function bool (int entity, int collisiongroup, int contentsmask, bool originalResult);
|
||||||
|
|
||||||
// Use
|
// Use
|
||||||
Action:public(entity, activator, caller, UseType:type, Float:value),
|
function Action (int entity, int activator, int caller, UseType type, float value);
|
||||||
|
|
||||||
// UsePost
|
// UsePost
|
||||||
public(entity, activator, caller, UseType:type, Float:value),
|
function void (int entity, int activator, int caller, UseType type, float value);
|
||||||
|
|
||||||
// Reload
|
// Reload
|
||||||
Action:public(weapon),
|
function Action (int weapon);
|
||||||
|
|
||||||
// Reload post
|
// Reload post
|
||||||
public(weapon, bool:bSuccessful)
|
function void (int weapon, bool bSuccessful);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
3
env/include/sdktools_entoutput.inc
vendored
3
env/include/sdktools_entoutput.inc
vendored
|
@ -42,8 +42,9 @@
|
||||||
* @param caller Entity index of the caller.
|
* @param caller Entity index of the caller.
|
||||||
* @param activator Entity index of the activator.
|
* @param activator Entity index of the activator.
|
||||||
* @param delay Delay in seconds? before the event gets fired.
|
* @param delay Delay in seconds? before the event gets fired.
|
||||||
|
* @noreturn
|
||||||
*/
|
*/
|
||||||
functag public EntityOutput(const String:output[], caller, activator, Float:delay);
|
typedef EntityOutput = function void (const char[] output, int caller, int activator, float delay);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add an entity output hook on a entity classname
|
* Add an entity output hook on a entity classname
|
||||||
|
|
4
env/include/sdktools_functions.inc
vendored
4
env/include/sdktools_functions.inc
vendored
|
@ -298,7 +298,7 @@ native bool:GetPlayerJingleFile(client, String:hex[], maxlength);
|
||||||
* @param out Buffer to store the output traffic velocity.
|
* @param out Buffer to store the output traffic velocity.
|
||||||
* @noreturn
|
* @noreturn
|
||||||
*/
|
*/
|
||||||
native GetServerNetStats(&Float:in, &Float:out);
|
native GetServerNetStats(&Float:inAmount, &Float:outAmout);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Equip's a player's weapon.
|
* Equip's a player's weapon.
|
||||||
|
@ -343,4 +343,4 @@ native SetClientInfo(client, const String:key[], const String:value[]);
|
||||||
*
|
*
|
||||||
* @return Amount of ammo actually given.
|
* @return Amount of ammo actually given.
|
||||||
*/
|
*/
|
||||||
native GivePlayerAmmo(client, amount, ammotype, bool:suppressSound=false);
|
native GivePlayerAmmo(client, amount, ammotype, bool:suppressSound=false);
|
||||||
|
|
249
env/include/sdktools_sound.inc
vendored
249
env/include/sdktools_sound.inc
vendored
|
@ -283,7 +283,16 @@ native Float:GetDistGainFromSoundLevel(soundlevel, Float:distance);
|
||||||
* @return Plugin_Continue to allow the sound to be played, Plugin_Stop to block it,
|
* @return Plugin_Continue to allow the sound to be played, Plugin_Stop to block it,
|
||||||
* Plugin_Changed when any parameter has been modified.
|
* Plugin_Changed when any parameter has been modified.
|
||||||
*/
|
*/
|
||||||
functag public Action:AmbientSHook(String:sample[PLATFORM_MAX_PATH], &entity, &Float:volume, &level, &pitch, Float:pos[3], &flags, &Float:delay);
|
typedef AmbientSHook = function Action (
|
||||||
|
char sample[PLATFORM_MAX_PATH],
|
||||||
|
int &entity,
|
||||||
|
float &volume,
|
||||||
|
int &level,
|
||||||
|
int &pitch,
|
||||||
|
float pos[3],
|
||||||
|
int &flags,
|
||||||
|
float &delay
|
||||||
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when a sound is going to be emitted to one or more clients.
|
* Called when a sound is going to be emitted to one or more clients.
|
||||||
|
@ -301,7 +310,17 @@ functag public Action:AmbientSHook(String:sample[PLATFORM_MAX_PATH], &entity, &F
|
||||||
* @return Plugin_Continue to allow the sound to be played, Plugin_Stop to block it,
|
* @return Plugin_Continue to allow the sound to be played, Plugin_Stop to block it,
|
||||||
* Plugin_Changed when any parameter has been modified.
|
* Plugin_Changed when any parameter has been modified.
|
||||||
*/
|
*/
|
||||||
functag public Action:NormalSHook(clients[64], &numClients, String:sample[PLATFORM_MAX_PATH], &entity, &channel, &Float:volume, &level, &pitch, &flags);
|
typedef NormalSHook = function Action (
|
||||||
|
int clients[64],
|
||||||
|
int &numClients,
|
||||||
|
char sample[PLATFORM_MAX_PATH],
|
||||||
|
int &entity,
|
||||||
|
int &channel,
|
||||||
|
float &volume,
|
||||||
|
int &level,
|
||||||
|
int &pitch,
|
||||||
|
int &flags
|
||||||
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Hooks all played ambient sounds.
|
* Hooks all played ambient sounds.
|
||||||
|
@ -448,3 +467,229 @@ stock ATTN_TO_SNDLEVEL(Float:attn)
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieves the parameters for a game sound.
|
||||||
|
*
|
||||||
|
* Game sounds are found in a game's scripts/game_sound.txt or other files
|
||||||
|
* referenced from it
|
||||||
|
*
|
||||||
|
* Note that if a game sound has a rndwave section, one of them will be returned
|
||||||
|
* at random.
|
||||||
|
*
|
||||||
|
* @param gameSound Name of game sound.
|
||||||
|
* @param channel Channel to emit with.
|
||||||
|
* @param level Sound level.
|
||||||
|
* @param volume Sound volume.
|
||||||
|
* @param pitch Sound pitch.
|
||||||
|
* @param sample Sound file name relative to the "sounds" folder.
|
||||||
|
* @param maxlength Maximum length of sample string buffer.
|
||||||
|
* @param entity Entity the sound is being emitted from.
|
||||||
|
* @return True if the sound was successfully retrieved, false if it
|
||||||
|
* was not found
|
||||||
|
*/
|
||||||
|
native bool:GetGameSoundParams(const String:gameSound[],
|
||||||
|
&channel,
|
||||||
|
&soundLevel,
|
||||||
|
&Float:volume,
|
||||||
|
&pitch,
|
||||||
|
String:sample[],
|
||||||
|
maxlength,
|
||||||
|
entity=SOUND_FROM_PLAYER);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Emits a game sound to a list of clients.
|
||||||
|
*
|
||||||
|
* Game sounds are found in a game's scripts/game_sound.txt or other files
|
||||||
|
* referenced from it
|
||||||
|
*
|
||||||
|
* Note that if a game sound has a rndwave section, one of them will be returned
|
||||||
|
* at random.
|
||||||
|
*
|
||||||
|
* @param clients Array of client indexes.
|
||||||
|
* @param numClients Number of clients in the array.
|
||||||
|
* @param gameSound Name of game sound.
|
||||||
|
* @param entity Entity to emit from.
|
||||||
|
* @param flags Sound flags.
|
||||||
|
* @param speakerentity Unknown.
|
||||||
|
* @param origin Sound origin.
|
||||||
|
* @param dir Sound direction.
|
||||||
|
* @param updatePos Unknown (updates positions?)
|
||||||
|
* @param soundtime Alternate time to play sound for.
|
||||||
|
* @return True if the sound was played successfully, false if it failed
|
||||||
|
* @error Invalid client index.
|
||||||
|
*/
|
||||||
|
stock bool:EmitGameSound(const clients[],
|
||||||
|
numClients,
|
||||||
|
const String:gameSound[],
|
||||||
|
entity = SOUND_FROM_PLAYER,
|
||||||
|
flags = SND_NOFLAGS,
|
||||||
|
speakerentity = -1,
|
||||||
|
const Float:origin[3] = NULL_VECTOR,
|
||||||
|
const Float:dir[3] = NULL_VECTOR,
|
||||||
|
bool:updatePos = true,
|
||||||
|
Float:soundtime = 0.0)
|
||||||
|
{
|
||||||
|
new channel;
|
||||||
|
new level;
|
||||||
|
new Float:volume;
|
||||||
|
new pitch;
|
||||||
|
new String:sample[PLATFORM_MAX_PATH];
|
||||||
|
|
||||||
|
if (GetGameSoundParams(gameSound, channel, level, volume, pitch, sample, sizeof(sample), entity))
|
||||||
|
{
|
||||||
|
EmitSound(clients, numClients, sample, entity, channel, level, flags, volume, pitch, speakerentity, origin, dir, updatePos, soundtime);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Emits an ambient game sound.
|
||||||
|
*
|
||||||
|
* Game sounds are found in a game's scripts/game_sound.txt or other files
|
||||||
|
* referenced from it
|
||||||
|
*
|
||||||
|
* Note that if a game sound has a rndwave section, one of them will be returned
|
||||||
|
* at random.
|
||||||
|
*
|
||||||
|
* @param gameSound Name of game sound.
|
||||||
|
* @param pos Origin of sound.
|
||||||
|
* @param entity Entity index to associate sound with.
|
||||||
|
* @param flags Sound flags.
|
||||||
|
* @param delay Play delay.
|
||||||
|
* @noreturn
|
||||||
|
*/
|
||||||
|
stock bool:EmitAmbientGameSound(const String:gameSound[],
|
||||||
|
const Float:pos[3],
|
||||||
|
entity = SOUND_FROM_WORLD,
|
||||||
|
flags = SND_NOFLAGS,
|
||||||
|
Float:delay = 0.0)
|
||||||
|
{
|
||||||
|
new channel; // This is never actually used for Ambients, but it's a mandatory field to GetGameSoundParams
|
||||||
|
new level;
|
||||||
|
new Float:volume;
|
||||||
|
new pitch;
|
||||||
|
new String:sample[PLATFORM_MAX_PATH];
|
||||||
|
|
||||||
|
if (GetGameSoundParams(gameSound, channel, level, volume, pitch, sample, sizeof(sample), entity))
|
||||||
|
{
|
||||||
|
EmitAmbientSound(sample, pos, entity, level, flags, volume, pitch, delay);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Wrapper to emit a game sound to one client.
|
||||||
|
*
|
||||||
|
* Game sounds are found in a game's scripts/game_sound.txt or other files
|
||||||
|
* referenced from it
|
||||||
|
*
|
||||||
|
* Note that if a game sound has a rndwave section, one of them will be returned
|
||||||
|
* at random.
|
||||||
|
*
|
||||||
|
* @param client Client index.
|
||||||
|
* @param gameSound Name of game sound.
|
||||||
|
* @param entity Entity to emit from.
|
||||||
|
* @param flags Sound flags.
|
||||||
|
* @param speakerentity Unknown.
|
||||||
|
* @param origin Sound origin.
|
||||||
|
* @param dir Sound direction.
|
||||||
|
* @param updatePos Unknown (updates positions?)
|
||||||
|
* @param soundtime Alternate time to play sound for.
|
||||||
|
* @noreturn
|
||||||
|
* @error Invalid client index.
|
||||||
|
*/
|
||||||
|
stock bool:EmitGameSoundToClient(client,
|
||||||
|
const String:gameSound[],
|
||||||
|
entity = SOUND_FROM_PLAYER,
|
||||||
|
flags = SND_NOFLAGS,
|
||||||
|
speakerentity = -1,
|
||||||
|
const Float:origin[3] = NULL_VECTOR,
|
||||||
|
const Float:dir[3] = NULL_VECTOR,
|
||||||
|
bool:updatePos = true,
|
||||||
|
Float:soundtime = 0.0)
|
||||||
|
{
|
||||||
|
new clients[1];
|
||||||
|
clients[0] = client;
|
||||||
|
/* Save some work for SDKTools and remove SOUND_FROM_PLAYER references */
|
||||||
|
entity = (entity == SOUND_FROM_PLAYER) ? client : entity;
|
||||||
|
return EmitGameSound(clients, 1, gameSound, entity, flags,
|
||||||
|
speakerentity, origin, dir, updatePos, soundtime);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Wrapper to emit game sound to all clients.
|
||||||
|
*
|
||||||
|
* Game sounds are found in a game's scripts/game_sound.txt or other files
|
||||||
|
* referenced from it
|
||||||
|
*
|
||||||
|
* Note that if a game sound has a rndwave section, one of them will be returned
|
||||||
|
* at random.
|
||||||
|
*
|
||||||
|
* @param gameSound Name of game sound.
|
||||||
|
* @param entity Entity to emit from.
|
||||||
|
* @param flags Sound flags.
|
||||||
|
* @param speakerentity Unknown.
|
||||||
|
* @param origin Sound origin.
|
||||||
|
* @param dir Sound direction.
|
||||||
|
* @param updatePos Unknown (updates positions?)
|
||||||
|
* @param soundtime Alternate time to play sound for.
|
||||||
|
* @noreturn
|
||||||
|
* @error Invalid client index.
|
||||||
|
*/
|
||||||
|
stock bool:EmitGameSoundToAll(const String:gameSound[],
|
||||||
|
entity = SOUND_FROM_PLAYER,
|
||||||
|
flags = SND_NOFLAGS,
|
||||||
|
speakerentity = -1,
|
||||||
|
const Float:origin[3] = NULL_VECTOR,
|
||||||
|
const Float:dir[3] = NULL_VECTOR,
|
||||||
|
bool:updatePos = true,
|
||||||
|
Float:soundtime = 0.0)
|
||||||
|
{
|
||||||
|
new clients[MaxClients];
|
||||||
|
new total = 0;
|
||||||
|
|
||||||
|
for (new i=1; i<=MaxClients; i++)
|
||||||
|
{
|
||||||
|
if (IsClientInGame(i))
|
||||||
|
{
|
||||||
|
clients[total++] = i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!total)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return EmitGameSound(clients, total, gameSound, entity, flags,
|
||||||
|
speakerentity, origin, dir, updatePos, soundtime);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Precache a game sound.
|
||||||
|
*
|
||||||
|
* Most games will precache all game sounds on map start, but this is not guaranteed...
|
||||||
|
* Team Fortress 2 is known to not pre-cache MvM game mode sounds on non-MvM maps.
|
||||||
|
*
|
||||||
|
* Due to the above, this native should be called before any calls to GetGameSoundParams,
|
||||||
|
* EmitGameSound*, or EmitAmbientGameSound.
|
||||||
|
*
|
||||||
|
* It should be safe to pass already precached game sounds to this function.
|
||||||
|
*
|
||||||
|
* Note: It precaches all files for a game sound.
|
||||||
|
*
|
||||||
|
* @param soundname Game sound to precache
|
||||||
|
*
|
||||||
|
* @return True if the game sound was found, false if sound did not exist
|
||||||
|
* or had no files
|
||||||
|
*/
|
||||||
|
native bool:PrecacheScriptSound(const String:soundname[]);
|
||||||
|
|
4
env/include/sdktools_tempents.inc
vendored
4
env/include/sdktools_tempents.inc
vendored
|
@ -44,7 +44,7 @@
|
||||||
* @param delay Delay in seconds to send the TE.
|
* @param delay Delay in seconds to send the TE.
|
||||||
* @return Plugin_Continue to allow the transmission of the TE, Plugin_Stop to block it.
|
* @return Plugin_Continue to allow the transmission of the TE, Plugin_Stop to block it.
|
||||||
*/
|
*/
|
||||||
functag public Action:TEHook(const String:te_name[], const Players[], numClients, Float:delay);
|
typedef TEHook = function Action (const char[] te_name, const int[] Players, int numClients, float delay);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Hooks a temp entity.
|
* Hooks a temp entity.
|
||||||
|
@ -171,7 +171,7 @@ native TE_WriteFloatArray(const String:prop[], const Float:array[], arraySize);
|
||||||
* @noreturn
|
* @noreturn
|
||||||
* @error Invalid client index or client not in game.
|
* @error Invalid client index or client not in game.
|
||||||
*/
|
*/
|
||||||
native TE_Send(clients[], numClients, Float:delay=0.0);
|
native TE_Send(const clients[], numClients, Float:delay=0.0);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets an encoded entity index in the current temp entity.
|
* Sets an encoded entity index in the current temp entity.
|
||||||
|
|
8
env/include/sdktools_trace.inc
vendored
8
env/include/sdktools_trace.inc
vendored
|
@ -110,7 +110,7 @@ enum RayType
|
||||||
RayType_Infinite /**< The trace ray will go from the start position to infinity using a direction vector. */
|
RayType_Infinite /**< The trace ray will go from the start position to infinity using a direction vector. */
|
||||||
};
|
};
|
||||||
|
|
||||||
funcenum TraceEntityFilter
|
typeset TraceEntityFilter
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Called on entity filtering.
|
* Called on entity filtering.
|
||||||
|
@ -119,7 +119,7 @@ funcenum TraceEntityFilter
|
||||||
* @param contentsMask Contents Mask.
|
* @param contentsMask Contents Mask.
|
||||||
* @return True to allow the current entity to be hit, otherwise false.
|
* @return True to allow the current entity to be hit, otherwise false.
|
||||||
*/
|
*/
|
||||||
bool:public(entity, contentsMask),
|
function bool (int entity, int contentsMask);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called on entity filtering.
|
* Called on entity filtering.
|
||||||
|
@ -129,7 +129,7 @@ funcenum TraceEntityFilter
|
||||||
* @param data Data value, if used.
|
* @param data Data value, if used.
|
||||||
* @return True to allow the current entity to be hit, otherwise false.
|
* @return True to allow the current entity to be hit, otherwise false.
|
||||||
*/
|
*/
|
||||||
bool:public(entity, contentsMask, any:data),
|
function bool (int entity, int contentsMask, any data);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -371,4 +371,4 @@ native TR_GetPlaneNormal(Handle:hndl, Float:normal[3]);
|
||||||
* @param pos Vector buffer to store data in.
|
* @param pos Vector buffer to store data in.
|
||||||
* @return True if outside world, otherwise false.
|
* @return True if outside world, otherwise false.
|
||||||
*/
|
*/
|
||||||
native TR_PointOutsideWorld(Float:pos[3]);
|
native TR_PointOutsideWorld(Float:pos[3]);
|
||||||
|
|
12
env/include/sorting.inc
vendored
12
env/include/sorting.inc
vendored
|
@ -98,7 +98,7 @@ native SortStrings(String:array[][], array_size, SortOrder:order = Sort_Ascendin
|
||||||
* 0 if first is equal to second
|
* 0 if first is equal to second
|
||||||
* 1 if first should go after second
|
* 1 if first should go after second
|
||||||
*/
|
*/
|
||||||
functag public SortFunc1D(elem1, elem2, const array[], Handle:hndl);
|
typedef SortFunc1D = function int (int elem1, int elem2, const int[] array, Handle hndl);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sorts a custom 1D array. You must pass in a comparison function.
|
* Sorts a custom 1D array. You must pass in a comparison function.
|
||||||
|
@ -123,10 +123,10 @@ native SortCustom1D(array[], array_size, SortFunc1D:sortfunc, Handle:hndl=INVALI
|
||||||
* 0 if first is equal to second
|
* 0 if first is equal to second
|
||||||
* 1 if first should go after second
|
* 1 if first should go after second
|
||||||
*/
|
*/
|
||||||
funcenum SortFunc2D
|
typeset SortFunc2D
|
||||||
{
|
{
|
||||||
public(elem1[], elem2[], const array[][], Handle:hndl),
|
function int (int[] elem1, int[] elem2, const int[][] array, Handle hndl);
|
||||||
public(String:elem1[], String:elem2[], const String:array[][], Handle:hndl),
|
function int (char[] elem1, char[] elem2, const char[][] array, Handle hndl);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -163,7 +163,7 @@ native SortADTArray(Handle:array, SortOrder:order, SortType:type);
|
||||||
* 0 if first is equal to second
|
* 0 if first is equal to second
|
||||||
* 1 if first should go after second
|
* 1 if first should go after second
|
||||||
*/
|
*/
|
||||||
functag public SortFuncADTArray(index1, index2, Handle:array, Handle:hndl);
|
typedef SortFuncADTArray = function int (int index1, int index2, Handle array, Handle hndl);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Custom sorts an ADT Array. You must pass in a comparison function.
|
* Custom sorts an ADT Array. You must pass in a comparison function.
|
||||||
|
@ -173,4 +173,4 @@ functag public SortFuncADTArray(index1, index2, Handle:array, Handle:hndl);
|
||||||
* @param hndl Optional Handle to pass through the comparison calls.
|
* @param hndl Optional Handle to pass through the comparison calls.
|
||||||
* @noreturn
|
* @noreturn
|
||||||
*/
|
*/
|
||||||
native SortADTArrayCustom(Handle:array, SortFuncADTArray:sortfunc, Handle:hndl=INVALID_HANDLE);
|
native SortADTArrayCustom(Handle:array, SortFuncADTArray:sortfunc, Handle:hndl=INVALID_HANDLE);
|
||||||
|
|
50
env/include/sourcemod.inc
vendored
50
env/include/sourcemod.inc
vendored
|
@ -40,11 +40,11 @@
|
||||||
*/
|
*/
|
||||||
struct Plugin
|
struct Plugin
|
||||||
{
|
{
|
||||||
const String:name[], /**< Plugin Name */
|
public const char[] name; /**< Plugin Name */
|
||||||
const String:description[], /**< Plugin Description */
|
public const char[] description; /**< Plugin Description */
|
||||||
const String:author[], /**< Plugin Author */
|
public const char[] author; /**< Plugin Author */
|
||||||
const String:version[], /**< Plugin Version */
|
public const char[] version; /**< Plugin Version */
|
||||||
const String:url[], /**< Plugin URL */
|
public const char[] url; /**< Plugin URL */
|
||||||
};
|
};
|
||||||
|
|
||||||
#include <core>
|
#include <core>
|
||||||
|
@ -64,6 +64,7 @@ struct Plugin
|
||||||
#include <textparse>
|
#include <textparse>
|
||||||
#include <clients>
|
#include <clients>
|
||||||
#include <console>
|
#include <console>
|
||||||
|
#include <convars>
|
||||||
#include <events>
|
#include <events>
|
||||||
#include <bitbuffer>
|
#include <bitbuffer>
|
||||||
#include <protobuf>
|
#include <protobuf>
|
||||||
|
@ -74,6 +75,7 @@ struct Plugin
|
||||||
#include <banning>
|
#include <banning>
|
||||||
#include <commandfilters>
|
#include <commandfilters>
|
||||||
#include <nextmap>
|
#include <nextmap>
|
||||||
|
#include <commandline>
|
||||||
|
|
||||||
enum APLRes
|
enum APLRes
|
||||||
{
|
{
|
||||||
|
@ -82,18 +84,6 @@ enum APLRes
|
||||||
APLRes_SilentFailure /**< Plugin shouldn't load but do so silently */
|
APLRes_SilentFailure /**< Plugin shouldn't load but do so silently */
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* Declare this as a struct in your plugin to expose its information.
|
|
||||||
* Example:
|
|
||||||
*
|
|
||||||
* public Plugin:myinfo =
|
|
||||||
* {
|
|
||||||
* name = "My Plugin",
|
|
||||||
* //etc
|
|
||||||
* };
|
|
||||||
*/
|
|
||||||
public Plugin:myinfo;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when the plugin is fully initialized and all known external references
|
* Called when the plugin is fully initialized and all known external references
|
||||||
* are resolved. This is only called once in the lifetime of the plugin, and is
|
* are resolved. This is only called once in the lifetime of the plugin, and is
|
||||||
|
@ -108,7 +98,7 @@ public Plugin:myinfo;
|
||||||
*
|
*
|
||||||
* @noreturn
|
* @noreturn
|
||||||
*/
|
*/
|
||||||
forward OnPluginStart();
|
forward void OnPluginStart();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @deprecated Use AskPluginLoad2() instead.
|
* @deprecated Use AskPluginLoad2() instead.
|
||||||
|
@ -144,7 +134,7 @@ forward APLRes:AskPluginLoad2(Handle:myself, bool:late, String:error[], err_max)
|
||||||
*
|
*
|
||||||
* @noreturn
|
* @noreturn
|
||||||
*/
|
*/
|
||||||
forward OnPluginEnd();
|
forward void OnPluginEnd();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when the plugin's pause status is changing.
|
* Called when the plugin's pause status is changing.
|
||||||
|
@ -152,14 +142,14 @@ forward OnPluginEnd();
|
||||||
* @param pause True if the plugin is being paused, false otherwise.
|
* @param pause True if the plugin is being paused, false otherwise.
|
||||||
* @noreturn
|
* @noreturn
|
||||||
*/
|
*/
|
||||||
forward OnPluginPauseChange(bool:pause);
|
forward void OnPluginPauseChange(bool:pause);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called before every server frame. Note that you should avoid
|
* Called before every server frame. Note that you should avoid
|
||||||
* doing expensive computations here, and you should declare large
|
* doing expensive computations here, and you should declare large
|
||||||
* local arrays using 'decl' instead of 'new'.
|
* local arrays using 'decl' instead of 'new'.
|
||||||
*/
|
*/
|
||||||
forward OnGameFrame();
|
forward void OnGameFrame();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when the map is loaded.
|
* Called when the map is loaded.
|
||||||
|
@ -167,12 +157,12 @@ forward OnGameFrame();
|
||||||
* @note This used to be OnServerLoad(), which is now deprecated.
|
* @note This used to be OnServerLoad(), which is now deprecated.
|
||||||
* Plugins still using the old forward will work.
|
* Plugins still using the old forward will work.
|
||||||
*/
|
*/
|
||||||
forward OnMapStart();
|
forward void OnMapStart();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called right before a map ends.
|
* Called right before a map ends.
|
||||||
*/
|
*/
|
||||||
forward OnMapEnd();
|
forward void OnMapEnd();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when the map has loaded, servercfgfile (server.cfg) has been
|
* Called when the map has loaded, servercfgfile (server.cfg) has been
|
||||||
|
@ -184,7 +174,7 @@ forward OnMapEnd();
|
||||||
*
|
*
|
||||||
* @noreturn
|
* @noreturn
|
||||||
*/
|
*/
|
||||||
forward OnConfigsExecuted();
|
forward void OnConfigsExecuted();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is called once, right after OnMapStart() but any time before
|
* This is called once, right after OnMapStart() but any time before
|
||||||
|
@ -201,20 +191,20 @@ forward OnConfigsExecuted();
|
||||||
*
|
*
|
||||||
* @noreturn
|
* @noreturn
|
||||||
*/
|
*/
|
||||||
forward OnAutoConfigsBuffered();
|
forward void OnAutoConfigsBuffered();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @deprecated Use OnConfigsExecuted() instead.
|
* @deprecated Use OnConfigsExecuted() instead.
|
||||||
*/
|
*/
|
||||||
#pragma deprecated Use OnConfigsExecuted() instead
|
#pragma deprecated Use OnConfigsExecuted() instead
|
||||||
forward OnServerCfg();
|
forward void OnServerCfg();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called after all plugins have been loaded. This is called once for
|
* Called after all plugins have been loaded. This is called once for
|
||||||
* every plugin. If a plugin late loads, it will be called immediately
|
* every plugin. If a plugin late loads, it will be called immediately
|
||||||
* after OnPluginStart().
|
* after OnPluginStart().
|
||||||
*/
|
*/
|
||||||
forward OnAllPluginsLoaded();
|
forward void OnAllPluginsLoaded();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the calling plugin's Handle.
|
* Returns the calling plugin's Handle.
|
||||||
|
@ -461,7 +451,7 @@ native GetExtensionFileStatus(const String:name[], String:error[]="", maxlength=
|
||||||
*
|
*
|
||||||
* @param name Library name.
|
* @param name Library name.
|
||||||
*/
|
*/
|
||||||
forward OnLibraryAdded(const String:name[]);
|
forward void OnLibraryAdded(const String:name[]);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called right before a library is removed that the current plugin references
|
* Called right before a library is removed that the current plugin references
|
||||||
|
@ -470,7 +460,7 @@ forward OnLibraryAdded(const String:name[]);
|
||||||
*
|
*
|
||||||
* @param name Library name.
|
* @param name Library name.
|
||||||
*/
|
*/
|
||||||
forward OnLibraryRemoved(const String:name[]);
|
forward void OnLibraryRemoved(const String:name[]);
|
||||||
|
|
||||||
#define MAPLIST_FLAG_MAPSFOLDER (1<<0) /**< On failure, use all maps in the maps folder. */
|
#define MAPLIST_FLAG_MAPSFOLDER (1<<0) /**< On failure, use all maps in the maps folder. */
|
||||||
#define MAPLIST_FLAG_CLEARARRAY (1<<1) /**< If an input array is specified, clear it before adding. */
|
#define MAPLIST_FLAG_CLEARARRAY (1<<1) /**< If an input array is specified, clear it before adding. */
|
||||||
|
@ -564,7 +554,7 @@ forward bool:OnClientFloodCheck(client);
|
||||||
* @param blocked True if client flooded last "say", false otherwise.
|
* @param blocked True if client flooded last "say", false otherwise.
|
||||||
* @noreturn
|
* @noreturn
|
||||||
*/
|
*/
|
||||||
forward OnClientFloodResult(client, bool:blocked);
|
forward void OnClientFloodResult(client, bool:blocked);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Feature types.
|
* Feature types.
|
||||||
|
|
23
env/include/string.inc
vendored
23
env/include/string.inc
vendored
|
@ -433,30 +433,19 @@ stock CharToLower(chr)
|
||||||
* @return The index of the first occurrence of the character
|
* @return The index of the first occurrence of the character
|
||||||
* in the string, or -1 if the character was not found.
|
* in the string, or -1 if the character was not found.
|
||||||
*/
|
*/
|
||||||
stock FindCharInString(const String:str[], c, bool:reverse = false)
|
stock int FindCharInString(const char[] str, char c, bool reverse = false)
|
||||||
{
|
{
|
||||||
new i, len
|
int len = strlen(str);
|
||||||
|
|
||||||
len = strlen(str);
|
|
||||||
|
|
||||||
if (!reverse)
|
if (!reverse) {
|
||||||
{
|
for (int i = 0; i < len; i++) {
|
||||||
for (i = 0; i < len; i++)
|
|
||||||
{
|
|
||||||
if (str[i] == c)
|
if (str[i] == c)
|
||||||
{
|
|
||||||
return i;
|
return i;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else
|
for (int i = len - 1; i >= 0; i--) {
|
||||||
{
|
|
||||||
for (i = len - 1; i >= 0; i--)
|
|
||||||
{
|
|
||||||
if (str[i] == c)
|
if (str[i] == c)
|
||||||
{
|
|
||||||
return i;
|
return i;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
197
env/include/textparse.inc
vendored
197
env/include/textparse.inc
vendored
|
@ -1,7 +1,7 @@
|
||||||
/**
|
/**
|
||||||
* vim: set ts=4 :
|
* vim: set ts=4 sw=4 tw=99 noet :
|
||||||
* =============================================================================
|
* =============================================================================
|
||||||
* SourceMod (C)2004-2008 AlliedModders LLC. All rights reserved.
|
* SourceMod (C)2004-2014 AlliedModders LLC. All rights reserved.
|
||||||
* =============================================================================
|
* =============================================================================
|
||||||
*
|
*
|
||||||
* This file is part of the SourceMod/SourcePawn SDK.
|
* This file is part of the SourceMod/SourcePawn SDK.
|
||||||
|
@ -29,7 +29,7 @@
|
||||||
*
|
*
|
||||||
* Version: $Id$
|
* Version: $Id$
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#if defined _textparse_included
|
#if defined _textparse_included
|
||||||
#endinput
|
#endinput
|
||||||
#endif
|
#endif
|
||||||
|
@ -45,7 +45,7 @@
|
||||||
/**
|
/**
|
||||||
* Parse result directive.
|
* Parse result directive.
|
||||||
*/
|
*/
|
||||||
enum SMCResult
|
enum SMCResult:
|
||||||
{
|
{
|
||||||
SMCParse_Continue, /**< Continue parsing */
|
SMCParse_Continue, /**< Continue parsing */
|
||||||
SMCParse_Halt, /**< Stop parsing here */
|
SMCParse_Halt, /**< Stop parsing here */
|
||||||
|
@ -55,7 +55,7 @@ enum SMCResult
|
||||||
/**
|
/**
|
||||||
* Parse error codes.
|
* Parse error codes.
|
||||||
*/
|
*/
|
||||||
enum SMCError
|
enum SMCError:
|
||||||
{
|
{
|
||||||
SMCError_Okay = 0, /**< No error */
|
SMCError_Okay = 0, /**< No error */
|
||||||
SMCError_StreamOpen, /**< Stream failed to open */
|
SMCError_StreamOpen, /**< Stream failed to open */
|
||||||
|
@ -71,12 +71,117 @@ enum SMCError
|
||||||
SMCError_InvalidProperty1, /**< A property was declared outside of any section */
|
SMCError_InvalidProperty1, /**< A property was declared outside of any section */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Called when parsing is started.
|
||||||
|
//
|
||||||
|
// @param smc The SMC Parse Handle.
|
||||||
|
typedef SMC_ParseStart = function void (SMCParser smc);
|
||||||
|
|
||||||
|
// Called when the parser is entering a new section or sub-section.
|
||||||
|
//
|
||||||
|
// Note: Enclosing quotes are always stripped.
|
||||||
|
//
|
||||||
|
// @param smc The SMC Parser.
|
||||||
|
// @param name String containing section name.
|
||||||
|
// @param opt_quotes True if the section name was quote-enclosed in the file.
|
||||||
|
// @return An SMCResult action to take.
|
||||||
|
typedef SMC_NewSection = function SMCResult (SMCParser smc, const char[] name, bool opt_quotes);
|
||||||
|
|
||||||
|
// Called when the parser finds a new key/value pair.
|
||||||
|
//
|
||||||
|
// Note: Enclosing quotes are always stripped.
|
||||||
|
//
|
||||||
|
// @param smc The SMCParser.
|
||||||
|
// @param key String containing key name.
|
||||||
|
// @param value String containing value name.
|
||||||
|
// @param key_quotes Whether or not the key was enclosed in quotes.
|
||||||
|
// @param value_quotes Whether or not the value was enclosed in quotes.
|
||||||
|
// @return An SMCResult action to take.
|
||||||
|
typedef SMC_KeyValue = function SMCResult (SMCParser smc, const char[] key, const char[] value, bool key_quotes, bool value_quotes);
|
||||||
|
|
||||||
|
// Called when the parser finds the end of the current section.
|
||||||
|
//
|
||||||
|
// @param smc The SMCParser.
|
||||||
|
// @return An SMCResult action to take.
|
||||||
|
typedef SMC_EndSection = function SMCResult (SMCParser smc);
|
||||||
|
|
||||||
|
// Called when parsing is halted.
|
||||||
|
//
|
||||||
|
// @param smc The SMCParser.
|
||||||
|
// @param halted True if abnormally halted, false otherwise.
|
||||||
|
// @param failed True if parsing failed, false otherwise.
|
||||||
|
// @noreturn
|
||||||
|
typedef SMC_ParseEnd = function void (SMCParser smc, bool halted, bool failed);
|
||||||
|
|
||||||
|
// Callback for whenever a new line of text is about to be parsed.
|
||||||
|
//
|
||||||
|
// @param smc The SMCParser.
|
||||||
|
// @param line A string containing the raw line from the file.
|
||||||
|
// @param lineno The line number it occurs on.
|
||||||
|
// @return An SMCResult action to take.
|
||||||
|
typedef SMC_RawLine = function SMCResult (SMCParser smc, const char[] line, int lineno);
|
||||||
|
|
||||||
|
// An SMCParser is a callback-driven parser for SourceMod configuration files.
|
||||||
|
// SMC files are similar to Valve KeyValues format, with two key differences:
|
||||||
|
// (1) SMC cannot handle single-item entries (that is, a key with no value).
|
||||||
|
// (2) SMC files can have multi-line comment blocks, whereas KeyValues cannot.
|
||||||
|
methodmap SMCParser < Handle
|
||||||
|
{
|
||||||
|
// Create a new SMC file format parser.
|
||||||
|
public native SMCParser();
|
||||||
|
|
||||||
|
// Parses an SMC file.
|
||||||
|
//
|
||||||
|
// @param file A string containing the file path.
|
||||||
|
// @param line An optional variable to store the last line number read.
|
||||||
|
// @param col An optional variable to store the last column number read.
|
||||||
|
// @return An SMCParseError result.
|
||||||
|
public native SMCError ParseFile(const char[] file, int &line = 0, int &col = 0);
|
||||||
|
|
||||||
|
// Sets the callback for receiving SMC_ParseStart events.
|
||||||
|
property SMC_ParseStart OnStart {
|
||||||
|
public native set(SMC_ParseStart func);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Sets the callback for receiving SMC_ParseEnd events.
|
||||||
|
property SMC_ParseEnd OnEnd {
|
||||||
|
public native set(SMC_ParseEnd func);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Sets the callback for receiving SMC_NewSection events.
|
||||||
|
property SMC_NewSection OnEnterSection {
|
||||||
|
public native set(SMC_NewSection func);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Sets the callback for receiving SMC_EndSection events.
|
||||||
|
property SMC_EndSection OnLeaveSection {
|
||||||
|
public native set(SMC_EndSection func);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Sets the callback for receiving SMC_KeyValue events.
|
||||||
|
property SMC_KeyValue OnKeyValue {
|
||||||
|
public native set(SMC_KeyValue func);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Sets the callback for receiving SMC_RawLine events.
|
||||||
|
property SMC_RawLine OnRawLine {
|
||||||
|
public native set(SMC_RawLine func);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Gets an error string for an SMCError code.
|
||||||
|
//
|
||||||
|
// @param error The SMCParseError code.
|
||||||
|
// @param buffer A string buffer for the error (contents undefined on failure).
|
||||||
|
// @param buf_max The maximum size of the buffer.
|
||||||
|
// @return The number of characters written to buffer.
|
||||||
|
public native void GetErrorString(SMCError error, char[] buffer, int buf_max);
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new SMC file format parser. This is used to set parse hooks.
|
* Creates a new SMC file format parser. This is used to set parse hooks.
|
||||||
*
|
*
|
||||||
* @return A new Handle to an SMC Parse structure.
|
* @return A new Handle to an SMC Parse structure.
|
||||||
*/
|
*/
|
||||||
native Handle:SMC_CreateParser();
|
native SMCParser SMC_CreateParser();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parses an SMC file.
|
* Parses an SMC file.
|
||||||
|
@ -86,9 +191,9 @@ native Handle:SMC_CreateParser();
|
||||||
* @param line An optional by reference cell to store the last line number read.
|
* @param line An optional by reference cell to store the last line number read.
|
||||||
* @param col An optional by reference cell to store the last column number read.
|
* @param col An optional by reference cell to store the last column number read.
|
||||||
* @return An SMCParseError result.
|
* @return An SMCParseError result.
|
||||||
* @error Invalid or corrupt Handle.
|
* @error Invalid or corrupt Handle.
|
||||||
*/
|
*/
|
||||||
native SMCError:SMC_ParseFile(Handle:smc, const String:file[], &line=0, &col=0);
|
native SMCError SMC_ParseFile(Handle smc, const char[] file, int &line=0, int &col=0);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets an error string for an SMCError code.
|
* Gets an error string for an SMCError code.
|
||||||
|
@ -100,15 +205,7 @@ native SMCError:SMC_ParseFile(Handle:smc, const String:file[], &line=0, &col=0);
|
||||||
* @param buf_max The maximum size of the buffer.
|
* @param buf_max The maximum size of the buffer.
|
||||||
* @return True on success, false otherwise.
|
* @return True on success, false otherwise.
|
||||||
*/
|
*/
|
||||||
native bool:SMC_GetErrorString(SMCError:error, String:buffer[], buf_max);
|
native bool SMC_GetErrorString(SMCError error, char[] buffer, int buf_max);
|
||||||
|
|
||||||
/**
|
|
||||||
* Called when parsing is started.
|
|
||||||
*
|
|
||||||
* @param smc The SMC Parse Handle.
|
|
||||||
* @noreturn
|
|
||||||
*/
|
|
||||||
functag public SMC_ParseStart(Handle:smc);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the SMC_ParseStart function of a parse Handle.
|
* Sets the SMC_ParseStart function of a parse Handle.
|
||||||
|
@ -116,19 +213,9 @@ functag public SMC_ParseStart(Handle:smc);
|
||||||
* @param smc Handle to an SMC Parse.
|
* @param smc Handle to an SMC Parse.
|
||||||
* @param func SMC_ParseStart function.
|
* @param func SMC_ParseStart function.
|
||||||
* @noreturn
|
* @noreturn
|
||||||
* @error Invalid or corrupt Handle.
|
* @error Invalid or corrupt Handle.
|
||||||
*/
|
*/
|
||||||
native SMC_SetParseStart(Handle:smc, SMC_ParseStart:func);
|
native SMC_SetParseStart(Handle smc, SMC_ParseStart func);
|
||||||
|
|
||||||
/**
|
|
||||||
* Called when parsing is halted.
|
|
||||||
*
|
|
||||||
* @param smc The SMC Parse Handle.
|
|
||||||
* @param halted True if abnormally halted, false otherwise.
|
|
||||||
* @param failed True if parsing failed, false otherwise.
|
|
||||||
* @noreturn
|
|
||||||
*/
|
|
||||||
functag public SMC_ParseEnd(Handle:smc, bool:halted, bool:failed);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the SMC_ParseEnd of a parse handle.
|
* Sets the SMC_ParseEnd of a parse handle.
|
||||||
|
@ -136,41 +223,9 @@ functag public SMC_ParseEnd(Handle:smc, bool:halted, bool:failed);
|
||||||
* @param smc Handle to an SMC Parse.
|
* @param smc Handle to an SMC Parse.
|
||||||
* @param func SMC_ParseEnd function.
|
* @param func SMC_ParseEnd function.
|
||||||
* @noreturn
|
* @noreturn
|
||||||
* @error Invalid or corrupt Handle.
|
* @error Invalid or corrupt Handle.
|
||||||
*/
|
*/
|
||||||
native SMC_SetParseEnd(Handle:smc, SMC_ParseEnd:func);
|
native SMC_SetParseEnd(Handle smc, SMC_ParseEnd func);
|
||||||
|
|
||||||
/**
|
|
||||||
* Called when the parser is entering a new section or sub-section.
|
|
||||||
* @note Enclosing quotes are always stripped.
|
|
||||||
*
|
|
||||||
* @param smc The SMC Parse Handle.
|
|
||||||
* @param name String containing section name.
|
|
||||||
* @param opt_quotes True if the section name was quote-enclosed in the file.
|
|
||||||
* @return An SMCResult action to take.
|
|
||||||
*/
|
|
||||||
functag public SMCResult:SMC_NewSection(Handle:smc, const String:name[], bool:opt_quotes);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Called when the parser finds a new key/value pair.
|
|
||||||
* @note Enclosing quotes are always stripped.
|
|
||||||
*
|
|
||||||
* @param smc The SMC Parse Handle.
|
|
||||||
* @param key String containing key name.
|
|
||||||
* @param value String containing value name.
|
|
||||||
* @param key_quotes Whether or not the key was enclosed in quotes.
|
|
||||||
* @param value_quotes Whether or not the value was enclosed in quotes.
|
|
||||||
* @return An SMCResult action to take.
|
|
||||||
*/
|
|
||||||
functag public SMCResult:SMC_KeyValue(Handle:smc, const String:key[], const String:value[], bool:key_quotes, bool:value_quotes);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Called when the parser finds the end of the current section.
|
|
||||||
*
|
|
||||||
* @param smc The SMC Parse Handle.
|
|
||||||
* @return An SMCResult action to take.
|
|
||||||
*/
|
|
||||||
functag public SMCResult:SMC_EndSection(Handle:smc);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the three main reader functions.
|
* Sets the three main reader functions.
|
||||||
|
@ -179,25 +234,13 @@ functag public SMCResult:SMC_EndSection(Handle:smc);
|
||||||
* @param ns An SMC_NewSection function pointer.
|
* @param ns An SMC_NewSection function pointer.
|
||||||
* @param kv An SMC_KeyValue function pointer.
|
* @param kv An SMC_KeyValue function pointer.
|
||||||
* @param es An SMC_EndSection function pointer.
|
* @param es An SMC_EndSection function pointer.
|
||||||
* @noreturn
|
|
||||||
*/
|
*/
|
||||||
native SMC_SetReaders(Handle:smc, SMC_NewSection:ns, SMC_KeyValue:kv, SMC_EndSection:es);
|
native void SMC_SetReaders(Handle smc, SMC_NewSection ns, SMC_KeyValue kv, SMC_EndSection es);
|
||||||
|
|
||||||
/**
|
|
||||||
* Called whenever a raw line is read.
|
|
||||||
*
|
|
||||||
* @param smc The SMC Parse Handle.
|
|
||||||
* @param line A string containing the raw line from the file.
|
|
||||||
* @param lineno The line number it occurs on.
|
|
||||||
* @return An SMCResult action to take.
|
|
||||||
*/
|
|
||||||
functag public SMCResult:SMC_RawLine(Handle:smc, const String:line[], lineno);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets a raw line reader on an SMC parser Handle.
|
* Sets a raw line reader on an SMC parser Handle.
|
||||||
*
|
*
|
||||||
* @param smc Handle to an SMC Parse.
|
* @param smc Handle to an SMC Parse.
|
||||||
* @param func SMC_RawLine function.
|
* @param func SMC_RawLine function.
|
||||||
* @noreturn
|
|
||||||
*/
|
*/
|
||||||
native SMC_SetRawLine(Handle:smc, SMC_RawLine:func);
|
native void SMC_SetRawLine(Handle smc, SMC_RawLine func);
|
||||||
|
|
60
env/include/tf2.inc
vendored
60
env/include/tf2.inc
vendored
|
@ -107,7 +107,7 @@ enum TFCond
|
||||||
TFCond_RegenBuffed,
|
TFCond_RegenBuffed,
|
||||||
TFCond_MarkedForDeath,
|
TFCond_MarkedForDeath,
|
||||||
TFCond_NoHealingDamageBuff,
|
TFCond_NoHealingDamageBuff,
|
||||||
TFCond_SpeedBuffAlly, //32
|
TFCond_SpeedBuffAlly, // 32
|
||||||
TFCond_HalloweenCritCandy,
|
TFCond_HalloweenCritCandy,
|
||||||
TFCond_CritCanteen,
|
TFCond_CritCanteen,
|
||||||
TFCond_CritDemoCharge,
|
TFCond_CritDemoCharge,
|
||||||
|
@ -153,23 +153,47 @@ enum TFCond
|
||||||
TFCond_HalloweenTiny,
|
TFCond_HalloweenTiny,
|
||||||
TFCond_HalloweenInHell,
|
TFCond_HalloweenInHell,
|
||||||
TFCond_HalloweenGhostMode,
|
TFCond_HalloweenGhostMode,
|
||||||
|
|
||||||
|
TFCond_DodgeChance = 79,
|
||||||
|
TFCond_Parachute,
|
||||||
|
TFCond_BlastJumping,
|
||||||
|
TFCond_HalloweenKart,
|
||||||
|
TFCond_HalloweenKartDash,
|
||||||
|
TFCond_BalloonHead,
|
||||||
|
TFCond_MeleeOnly,
|
||||||
|
TFCond_SwimmingCurse,
|
||||||
|
TFCond_HalloweenKartNoTurn,
|
||||||
|
TFCond_HalloweenKartCage,
|
||||||
|
TFCond_HasRune,
|
||||||
|
TFCond_RuneStrength,
|
||||||
|
TFCond_RuneHaste,
|
||||||
|
TFCond_RuneRegen,
|
||||||
|
TFCond_RuneResist,
|
||||||
|
TFCond_RuneVampire,
|
||||||
|
TFCond_RuneWarlock,
|
||||||
|
TFCond_RunePrecision, // 96
|
||||||
|
TFCond_RuneAgility,
|
||||||
};
|
};
|
||||||
|
|
||||||
const Float:TFCondDuration_Infinite = -1.0;
|
const Float:TFCondDuration_Infinite = -1.0;
|
||||||
|
|
||||||
enum TFHoliday
|
enum TFHoliday
|
||||||
{
|
{
|
||||||
TFHoliday_Birthday = 1,
|
TFHoliday_Invalid = -1
|
||||||
TFHoliday_Halloween,
|
|
||||||
TFHoliday_Christmas,
|
|
||||||
TFHoliday_ValentinesDay,
|
|
||||||
TFHoliday_MeetThePyro,
|
|
||||||
TFHoliday_FullMoon,
|
|
||||||
TFHoliday_HalloweenOrFullMoon,
|
|
||||||
TFHoliday_HalloweenOrFullMoonOrValentines,
|
|
||||||
TFHoliday_AprilFools,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
public const TFHoliday:TFHoliday_Birthday;
|
||||||
|
public const TFHoliday:TFHoliday_Halloween;
|
||||||
|
public const TFHoliday:TFHoliday_Christmas;
|
||||||
|
public const TFHoliday:TFHoliday_EndOfTheLine;
|
||||||
|
public const TFHoliday:TFHoliday_ValentinesDay;
|
||||||
|
public const TFHoliday:TFHoliday_MeetThePyro;
|
||||||
|
public const TFHoliday:TFHoliday_SpyVsEngyWar;
|
||||||
|
public const TFHoliday:TFHoliday_FullMoon;
|
||||||
|
public const TFHoliday:TFHoliday_HalloweenOrFullMoon;
|
||||||
|
public const TFHoliday:TFHoliday_HalloweenOrFullMoonOrValentines;
|
||||||
|
public const TFHoliday:TFHoliday_AprilFools;
|
||||||
|
|
||||||
enum TFObjectType
|
enum TFObjectType
|
||||||
{
|
{
|
||||||
TFObject_CartDispenser = 0,
|
TFObject_CartDispenser = 0,
|
||||||
|
@ -254,12 +278,12 @@ native TF2_SetPlayerPowerPlay(client, bool:enabled);
|
||||||
*
|
*
|
||||||
* @param client Player's index.
|
* @param client Player's index.
|
||||||
* @param team Team to disguise the player as (only TFTeam_Red and TFTeam_Blue have an effect)
|
* @param team Team to disguise the player as (only TFTeam_Red and TFTeam_Blue have an effect)
|
||||||
* @param class TFClassType class to disguise the player as
|
* @param classType TFClassType class to disguise the player as
|
||||||
* @param target Specific target player to disguise as (0 for any)
|
* @param target Specific target player to disguise as (0 for any)
|
||||||
* @noreturn
|
* @noreturn
|
||||||
* @error Invalid client index, client not in game, or no mod support.
|
* @error Invalid client index, client not in game, or no mod support.
|
||||||
*/
|
*/
|
||||||
native TF2_DisguisePlayer(client, TFTeam:team, TFClassType:class, target=0);
|
native TF2_DisguisePlayer(client, TFTeam:team, TFClassType:classType, target=0);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Removes the current disguise from a client. Only has an effect on spies.
|
* Removes the current disguise from a client. Only has an effect on spies.
|
||||||
|
@ -359,6 +383,17 @@ native bool:TF2_IsHolidayActive(TFHoliday:holiday);
|
||||||
*/
|
*/
|
||||||
native bool:TF2_IsPlayerInDuel(client);
|
native bool:TF2_IsPlayerInDuel(client);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Removes an econ wearable (hat, misc, etc) from a player.
|
||||||
|
* This also deletes the wearable entity.
|
||||||
|
*
|
||||||
|
* @param client Client index.
|
||||||
|
* @param wearable Index of the wearable entity.
|
||||||
|
* @noreturn
|
||||||
|
* @error Invalid client index, client not in game, invalid wearable entity, or no mod support.
|
||||||
|
*/
|
||||||
|
native TF2_RemoveWearable(client, wearable);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called after a condition is added to a player
|
* Called after a condition is added to a player
|
||||||
*
|
*
|
||||||
|
@ -436,5 +471,6 @@ public __ext_tf2_SetNTVOptional()
|
||||||
MarkNativeAsOptional("TF2_GetClass");
|
MarkNativeAsOptional("TF2_GetClass");
|
||||||
MarkNativeAsOptional("TF2_IsPlayerInDuel");
|
MarkNativeAsOptional("TF2_IsPlayerInDuel");
|
||||||
MarkNativeAsOptional("TF2_IsHolidayActive");
|
MarkNativeAsOptional("TF2_IsHolidayActive");
|
||||||
|
MarkNativeAsOptional("TF2_RemoveWearable");
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
61
env/include/tf2_stocks.inc
vendored
61
env/include/tf2_stocks.inc
vendored
|
@ -249,6 +249,7 @@ enum {
|
||||||
TF_WEAPON_SPELLBOOK,
|
TF_WEAPON_SPELLBOOK,
|
||||||
TF_WEAPON_SPELLBOOK_PROJECTILE,
|
TF_WEAPON_SPELLBOOK_PROJECTILE,
|
||||||
TF_WEAPON_SNIPERRIFLE_CLASSIC,
|
TF_WEAPON_SNIPERRIFLE_CLASSIC,
|
||||||
|
TF_WEAPON_PARACHUTE,
|
||||||
};
|
};
|
||||||
|
|
||||||
// TF2 Weapon Loadout Slots
|
// TF2 Weapon Loadout Slots
|
||||||
|
@ -318,7 +319,19 @@ static const String:TFResourceNames[TFResourceType][] =
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get's a Clients current class.
|
* Gets a client's current team.
|
||||||
|
*
|
||||||
|
* @param client Client index.
|
||||||
|
* @return Current TFTeam of client.
|
||||||
|
* @error Invalid client index.
|
||||||
|
*/
|
||||||
|
stock TFTeam:TF2_GetClientTeam(client)
|
||||||
|
{
|
||||||
|
return TFTeam:GetClientTeam(client);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets a client's current class.
|
||||||
*
|
*
|
||||||
* @param client Player's index.
|
* @param client Player's index.
|
||||||
* @return Current TFClassType of player.
|
* @return Current TFClassType of player.
|
||||||
|
@ -330,24 +343,24 @@ stock TFClassType:TF2_GetPlayerClass(client)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set's a Clients class.
|
* Sets a client's class.
|
||||||
*
|
*
|
||||||
* Note: If setting player class in a player spawn hook weapons should be set to false.
|
* Note: If setting player class in a player spawn hook weapons should be set to false.
|
||||||
*
|
*
|
||||||
* @param client Player's index.
|
* @param client Player's index.
|
||||||
* @param class TFClassType class symbol.
|
* @param classType TFClassType class symbol.
|
||||||
* @param weapons This paramater is ignored.
|
* @param weapons This parameter is ignored.
|
||||||
* @param persistent If true changes the players desired class so the change stays after death.
|
* @param persistent If true, changes the player's desired class so the change stays after death.
|
||||||
* @noreturn
|
* @noreturn
|
||||||
* @error Invalid client index.
|
* @error Invalid client index.
|
||||||
*/
|
*/
|
||||||
stock TF2_SetPlayerClass(client, TFClassType:class, bool:weapons=true, bool:persistent=true)
|
stock TF2_SetPlayerClass(client, TFClassType:classType, bool:weapons=true, bool:persistent=true)
|
||||||
{
|
{
|
||||||
SetEntProp(client, Prop_Send, "m_iClass", _:class);
|
SetEntProp(client, Prop_Send, "m_iClass", _:classType);
|
||||||
|
|
||||||
if (persistent)
|
if (persistent)
|
||||||
{
|
{
|
||||||
SetEntProp(client, Prop_Send, "m_iDesiredPlayerClass", _:class);
|
SetEntProp(client, Prop_Send, "m_iDesiredPlayerClass", _:classType);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -368,12 +381,12 @@ stock TF2_GetPlayerResourceData(client, TFResourceType:type)
|
||||||
}
|
}
|
||||||
|
|
||||||
new offset = FindSendPropInfo("CTFPlayerResource", TFResourceNames[type]);
|
new offset = FindSendPropInfo("CTFPlayerResource", TFResourceNames[type]);
|
||||||
|
|
||||||
if (offset < 1)
|
if (offset < 1)
|
||||||
{
|
{
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
new entity = TF2_GetResourceEntity();
|
new entity = TF2_GetResourceEntity();
|
||||||
|
|
||||||
if (entity == -1)
|
if (entity == -1)
|
||||||
|
@ -404,12 +417,12 @@ stock bool:TF2_SetPlayerResourceData(client, TFResourceType:type, any:value)
|
||||||
}
|
}
|
||||||
|
|
||||||
new offset = FindSendPropInfo("CTFPlayerResource", TFResourceNames[type]);
|
new offset = FindSendPropInfo("CTFPlayerResource", TFResourceNames[type]);
|
||||||
|
|
||||||
if (offset < 1)
|
if (offset < 1)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
new entity = TF2_GetResourceEntity();
|
new entity = TF2_GetResourceEntity();
|
||||||
|
|
||||||
if (entity == -1)
|
if (entity == -1)
|
||||||
|
@ -435,6 +448,20 @@ stock TF2_RemoveWeaponSlot(client, slot)
|
||||||
new weaponIndex;
|
new weaponIndex;
|
||||||
while ((weaponIndex = GetPlayerWeaponSlot(client, slot)) != -1)
|
while ((weaponIndex = GetPlayerWeaponSlot(client, slot)) != -1)
|
||||||
{
|
{
|
||||||
|
// bug #6206
|
||||||
|
// papering over a valve bug where a weapon's extra wearables aren't properly removed from the weapon's owner
|
||||||
|
new extraWearable = GetEntPropEnt(weaponIndex, Prop_Send, "m_hExtraWearable");
|
||||||
|
if (extraWearable != -1)
|
||||||
|
{
|
||||||
|
TF2_RemoveWearable(client, extraWearable);
|
||||||
|
}
|
||||||
|
|
||||||
|
extraWearable = GetEntPropEnt(weaponIndex, Prop_Send, "m_hExtraWearableViewModel");
|
||||||
|
if (extraWearable != -1)
|
||||||
|
{
|
||||||
|
TF2_RemoveWearable(client, extraWearable);
|
||||||
|
}
|
||||||
|
|
||||||
RemovePlayerItem(client, weaponIndex);
|
RemovePlayerItem(client, weaponIndex);
|
||||||
AcceptEntityInput(weaponIndex, "Kill");
|
AcceptEntityInput(weaponIndex, "Kill");
|
||||||
}
|
}
|
||||||
|
@ -497,7 +524,7 @@ stock bool:TF2_IsPlayerInCondition(client, TFCond:cond)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else if (_:cond < 96)
|
||||||
{
|
{
|
||||||
new bit = (1 << (_:cond - 64));
|
new bit = (1 << (_:cond - 64));
|
||||||
if ((GetEntProp(client, Prop_Send, "m_nPlayerCondEx2") & bit) == bit)
|
if ((GetEntProp(client, Prop_Send, "m_nPlayerCondEx2") & bit) == bit)
|
||||||
|
@ -505,6 +532,14 @@ stock bool:TF2_IsPlayerInCondition(client, TFCond:cond)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
new bit = (1 << (_:cond - 96));
|
||||||
|
if ((GetEntProp(client, Prop_Send, "m_nPlayerCondEx3") & bit) == bit)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
10
env/include/timers.inc
vendored
10
env/include/timers.inc
vendored
|
@ -45,7 +45,7 @@
|
||||||
/**
|
/**
|
||||||
* Any of the following prototypes will work for a timed function.
|
* Any of the following prototypes will work for a timed function.
|
||||||
*/
|
*/
|
||||||
funcenum Timer
|
typeset Timer
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Called when the timer interval has elapsed.
|
* Called when the timer interval has elapsed.
|
||||||
|
@ -55,7 +55,7 @@ funcenum Timer
|
||||||
* @return Plugin_Stop to stop a repeating timer, any other value for
|
* @return Plugin_Stop to stop a repeating timer, any other value for
|
||||||
* default behavior.
|
* default behavior.
|
||||||
*/
|
*/
|
||||||
Action:public(Handle:timer, Handle:hndl),
|
function Action(Handle timer, Handle hndl);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when the timer interval has elapsed.
|
* Called when the timer interval has elapsed.
|
||||||
|
@ -65,7 +65,7 @@ funcenum Timer
|
||||||
* @return Plugin_Stop to stop a repeating timer, any other value for
|
* @return Plugin_Stop to stop a repeating timer, any other value for
|
||||||
* default behavior.
|
* default behavior.
|
||||||
*/
|
*/
|
||||||
Action:public(Handle:timer, any:data),
|
function Action(Handle timer, any data);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when the timer interval has elapsed.
|
* Called when the timer interval has elapsed.
|
||||||
|
@ -74,7 +74,7 @@ funcenum Timer
|
||||||
* @return Plugin_Stop to stop a repeating timer, any other value for
|
* @return Plugin_Stop to stop a repeating timer, any other value for
|
||||||
* default behavior.
|
* default behavior.
|
||||||
*/
|
*/
|
||||||
Action:public(Handle:timer),
|
function Action(Handle timer);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -177,7 +177,7 @@ native Float:GetTickInterval();
|
||||||
* the map yet), then this will be called once the server begins ticking, even
|
* the map yet), then this will be called once the server begins ticking, even
|
||||||
* if there is no time limit set.
|
* if there is no time limit set.
|
||||||
*/
|
*/
|
||||||
forward OnMapTimeLeftChanged();
|
forward void OnMapTimeLeftChanged();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns whether or not the server is processing frames or not.
|
* Returns whether or not the server is processing frames or not.
|
||||||
|
|
225
env/include/topmenus.inc
vendored
225
env/include/topmenus.inc
vendored
|
@ -1,5 +1,5 @@
|
||||||
/**
|
/**
|
||||||
* vim: set ts=4 :
|
* vim: set ts=4 sw=4 tw=99 noet:
|
||||||
* =============================================================================
|
* =============================================================================
|
||||||
* SourceMod (C)2004-2008 AlliedModders LLC. All rights reserved.
|
* SourceMod (C)2004-2008 AlliedModders LLC. All rights reserved.
|
||||||
* =============================================================================
|
* =============================================================================
|
||||||
|
@ -38,25 +38,25 @@
|
||||||
#include <menus>
|
#include <menus>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Actions a top menu will take on an object.
|
* Actions a top menu will take on an topobj.
|
||||||
*/
|
*/
|
||||||
enum TopMenuAction
|
enum TopMenuAction:
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* An option is being drawn for a menu (or for sorting purposes).
|
* An option is being drawn for a menu (or for sorting purposes).
|
||||||
*
|
*
|
||||||
* INPUT : TopMenu Handle, object ID, client index.
|
* INPUT : TopMenu Handle, topobj ID, client index.
|
||||||
* OUTPUT: Buffer for rendering, maxlength of buffer.
|
* OUTPUT: Buffer for rendering, maxlength of buffer.
|
||||||
*/
|
*/
|
||||||
TopMenuAction_DisplayOption = 0,
|
TopMenuAction_DisplayOption = 0,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The title of a menu is being drawn for a given object.
|
* The title of a menu is being drawn for a given topobj.
|
||||||
*
|
*
|
||||||
* Note: The Object ID will be INVALID_TOPMENUOBJECT if drawing the
|
* Note: The Object ID will be INVALID_TOPMENUOBJECT if drawing the
|
||||||
* root title. Otherwise, the Object ID is a category.
|
* root title. Otherwise, the Object ID is a category.
|
||||||
*
|
*
|
||||||
* INPUT : TopMenu Handle, object ID, client index.
|
* INPUT : TopMenu Handle, topobj ID, client index.
|
||||||
* OUTPUT: Buffer for rendering, maxlength of buffer.
|
* OUTPUT: Buffer for rendering, maxlength of buffer.
|
||||||
*/
|
*/
|
||||||
TopMenuAction_DisplayTitle = 1,
|
TopMenuAction_DisplayTitle = 1,
|
||||||
|
@ -66,14 +66,14 @@ enum TopMenuAction
|
||||||
*
|
*
|
||||||
* The Object ID will always be an item (not a category).
|
* The Object ID will always be an item (not a category).
|
||||||
*
|
*
|
||||||
* INPUT : TopMenu Handle, object ID, client index.
|
* INPUT : TopMenu Handle, topobj ID, client index.
|
||||||
*/
|
*/
|
||||||
TopMenuAction_SelectOption = 2,
|
TopMenuAction_SelectOption = 2,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A menu option is being drawn and its flags can be overridden.
|
* A menu option is being drawn and its flags can be overridden.
|
||||||
*
|
*
|
||||||
* INPUT : TopMenu Handle, object ID, client index.
|
* INPUT : TopMenu Handle, topobj ID, client index.
|
||||||
* OUTPUT: The first byte of the 'buffer' string should be set
|
* OUTPUT: The first byte of the 'buffer' string should be set
|
||||||
* to the desired flags. By default, it will contain
|
* to the desired flags. By default, it will contain
|
||||||
* ITEMDRAW_DEFAULT.
|
* ITEMDRAW_DEFAULT.
|
||||||
|
@ -81,18 +81,18 @@ enum TopMenuAction
|
||||||
TopMenuAction_DrawOption = 3,
|
TopMenuAction_DrawOption = 3,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when an object is being removed from the menu.
|
* Called when an topobj is being removed from the menu.
|
||||||
* This can be used to clean up data stored in the info string.
|
* This can be used to clean up data stored in the info string.
|
||||||
*
|
*
|
||||||
* INPUT : TopMenu Handle, object ID.
|
* INPUT : TopMenu Handle, topobj ID.
|
||||||
*/
|
*/
|
||||||
TopMenuAction_RemoveObject = 4,
|
TopMenuAction_RemoveObject = 4,
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Top menu object types.
|
* Top menu topobj types.
|
||||||
*/
|
*/
|
||||||
enum TopMenuObjectType
|
enum TopMenuObjectType:
|
||||||
{
|
{
|
||||||
TopMenuObject_Category = 0, /**< Category (sub-menu branching from root) */
|
TopMenuObject_Category = 0, /**< Category (sub-menu branching from root) */
|
||||||
TopMenuObject_Item = 1 /**< Item on a sub-menu */
|
TopMenuObject_Item = 1 /**< Item on a sub-menu */
|
||||||
|
@ -101,7 +101,7 @@ enum TopMenuObjectType
|
||||||
/**
|
/**
|
||||||
* Top menu starting positions for display.
|
* Top menu starting positions for display.
|
||||||
*/
|
*/
|
||||||
enum TopMenuPosition
|
enum TopMenuPosition:
|
||||||
{
|
{
|
||||||
TopMenuPosition_Start = 0, /**< Start/root of the menu */
|
TopMenuPosition_Start = 0, /**< Start/root of the menu */
|
||||||
TopMenuPosition_LastRoot = 1, /**< Last position in the root menu */
|
TopMenuPosition_LastRoot = 1, /**< Last position in the root menu */
|
||||||
|
@ -109,9 +109,9 @@ enum TopMenuPosition
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Top menu object tag for type checking.
|
* Top menu topobj tag for type checking.
|
||||||
*/
|
*/
|
||||||
enum TopMenuObject
|
enum TopMenuObject:
|
||||||
{
|
{
|
||||||
INVALID_TOPMENUOBJECT = 0,
|
INVALID_TOPMENUOBJECT = 0,
|
||||||
};
|
};
|
||||||
|
@ -121,18 +121,138 @@ enum TopMenuObject
|
||||||
*
|
*
|
||||||
* @param topmenu Handle to the TopMenu.
|
* @param topmenu Handle to the TopMenu.
|
||||||
* @param action TopMenuAction being performed.
|
* @param action TopMenuAction being performed.
|
||||||
* @param object_id The object ID (if used).
|
* @param topobj_id The topobj ID (if used).
|
||||||
* @param param Extra parameter (if used).
|
* @param param Extra parameter (if used).
|
||||||
* @param buffer Output buffer (if used).
|
* @param buffer Output buffer (if used).
|
||||||
* @param maxlength Output buffer (if used).
|
* @param maxlength Output buffer (if used).
|
||||||
* @noreturn
|
* @noreturn
|
||||||
*/
|
*/
|
||||||
functag public TopMenuHandler(Handle:topmenu,
|
typedef TopMenuHandler = function void (
|
||||||
TopMenuAction:action,
|
Handle topmenu,
|
||||||
TopMenuObject:object_id,
|
TopMenuAction action,
|
||||||
param,
|
TopMenuObject topobj_id,
|
||||||
String:buffer[],
|
int param,
|
||||||
maxlength);
|
char[] buffer,
|
||||||
|
int maxlength
|
||||||
|
);
|
||||||
|
|
||||||
|
// TopMenu objects are used for constructing multi-layer menus. Currently, they
|
||||||
|
// support at most two levels. The first level of items are called "categories".
|
||||||
|
methodmap TopMenu < Handle
|
||||||
|
{
|
||||||
|
// Creates a new TopMenu.
|
||||||
|
//
|
||||||
|
// @param handler Handler to use for drawing the root title.
|
||||||
|
// @return A new TopMenu.
|
||||||
|
public native TopMenu(TopMenuHandler handler);
|
||||||
|
|
||||||
|
// Returns a TopMenu handle from a generic handle. If the given handle is
|
||||||
|
// a TopMenu, the handle is simply casted back. Otherwise, an error is
|
||||||
|
// raised.
|
||||||
|
public static native TopMenu FromHandle(Handle handle);
|
||||||
|
|
||||||
|
// Re-sorts the items in a TopMenu via a configuration file.
|
||||||
|
//
|
||||||
|
// The format of the configuration file should be a Valve Key-Values
|
||||||
|
// formatted file that SourceMod can parse. There should be one root
|
||||||
|
// section, and one sub-section for each category. Each sub-section's
|
||||||
|
// name should match the category name.
|
||||||
|
//
|
||||||
|
// Each sub-section may only contain key/value pairs in the form of:
|
||||||
|
// key: "item"
|
||||||
|
// value: Name of the item as passed to AddToTopMenu().
|
||||||
|
//
|
||||||
|
// The TopMenu will draw items in the order declared in the configuration
|
||||||
|
// file. If items do not appear in the configuration file, they are sorted
|
||||||
|
// per-player based on how the handler function renders for that player.
|
||||||
|
// These items appear after the configuration sorted items.
|
||||||
|
//
|
||||||
|
// @param topmenu TopMenu Handle.
|
||||||
|
// @param file File path.
|
||||||
|
// @param error Error buffer.
|
||||||
|
// @param maxlength Maximum size of the error buffer. Error buffer
|
||||||
|
// will be filled with a zero-terminated string if
|
||||||
|
// false is returned.
|
||||||
|
// @return True on success, false on failure.
|
||||||
|
public native bool LoadConfig(const char[] file, char[] error, int maxlength);
|
||||||
|
|
||||||
|
// Adds a category to a TopMenu.
|
||||||
|
//
|
||||||
|
// @param name Object name (MUST be unique).
|
||||||
|
// @param handler Handler for topobj.
|
||||||
|
// @param cmdname Command name (for access overrides).
|
||||||
|
// @param flags Default access flags.
|
||||||
|
// @param info_string Arbitrary storage (max 255 bytes).
|
||||||
|
// @return A new TopMenuObject ID, or INVALID_TOPMENUOBJECT on failure.
|
||||||
|
public native TopMenuObject AddCategory(const char[] name, TopMenuHandler handler,
|
||||||
|
const char[] cmdname = "", int flags = 0,
|
||||||
|
const char[] info_string = "");
|
||||||
|
|
||||||
|
// Adds an item to a TopMenu category.
|
||||||
|
//
|
||||||
|
// @param name Object name (MUST be unique).
|
||||||
|
// @param handler Handler for topobj.
|
||||||
|
// @param category The object of the parent category for the item.
|
||||||
|
// @param cmdname Command name (for access overrides).
|
||||||
|
// @param flags Default access flags.
|
||||||
|
// @param info_string Arbitrary storage (max 255 bytes).
|
||||||
|
// @return A new TopMenuObject ID, or INVALID_TOPMENUOBJECT on failure.
|
||||||
|
public native TopMenuObject AddItem(const char[] name, TopMenuHandler handler,
|
||||||
|
TopMenuObject parent, const char[] cmdname = "",
|
||||||
|
int flags = 0, const char[] info_string = "");
|
||||||
|
|
||||||
|
// Retrieves the info string of a top menu item.
|
||||||
|
//
|
||||||
|
// @param parent TopMenuObject ID.
|
||||||
|
// @param buffer Buffer to store info string.
|
||||||
|
// @param maxlength Maximum size of info string.
|
||||||
|
// @return Number of bytes written, not including the null terminator.
|
||||||
|
public native int GetInfoString(TopMenuObject parent, char[] buffer, int maxlength);
|
||||||
|
|
||||||
|
// Retrieves the name string of a top menu item.
|
||||||
|
//
|
||||||
|
// @param topobj TopMenuObject ID.
|
||||||
|
// @param buffer Buffer to store info string.
|
||||||
|
// @param maxlength Maximum size of info string.
|
||||||
|
// @return Number of bytes written, not including the null terminator.
|
||||||
|
public native int GetObjName(TopMenuObject topobj, char[] buffer, int maxlength);
|
||||||
|
|
||||||
|
// Removes an topobj from a TopMenu.
|
||||||
|
//
|
||||||
|
// Plugins' topobjs are automatically removed all TopMenus when the given
|
||||||
|
// plugin unloads or pauses. In the case of unpausing, all items are restored.
|
||||||
|
//
|
||||||
|
// @param topobj TopMenuObject ID.
|
||||||
|
public native void Remove(TopMenuObject topobj);
|
||||||
|
|
||||||
|
// Displays a TopMenu to a client.
|
||||||
|
//
|
||||||
|
// @param client Client index.
|
||||||
|
// @param position Position to display from.
|
||||||
|
// @return True on success, false on failure.
|
||||||
|
public native bool Display(int client, TopMenuPosition position);
|
||||||
|
|
||||||
|
// Displays a TopMenu category to a client.
|
||||||
|
//
|
||||||
|
// @param category Category topobj id.
|
||||||
|
// @param client Client index.
|
||||||
|
// @return True on success, false on failure.
|
||||||
|
public native bool DisplayCategory(TopMenuObject category, int client);
|
||||||
|
|
||||||
|
// Finds a category's topobj ID in a TopMenu.
|
||||||
|
//
|
||||||
|
// @param name Object's unique name.
|
||||||
|
// @return TopMenuObject ID on success, or
|
||||||
|
// INVALID_TOPMENUOBJECT on failure.
|
||||||
|
public native TopMenuObject FindCategory(const char[] name);
|
||||||
|
|
||||||
|
// Set the menu title caching behaviour of the TopMenu. By default titles
|
||||||
|
// are cached to reduce overhead. If you need dynamic menu titles which
|
||||||
|
// change each time the menu is displayed to a user, set this to false.
|
||||||
|
property bool CacheTitles {
|
||||||
|
public native set(bool value);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a TopMenu.
|
* Creates a TopMenu.
|
||||||
|
@ -140,7 +260,7 @@ functag public TopMenuHandler(Handle:topmenu,
|
||||||
* @param handler Handler to use for drawing the root title.
|
* @param handler Handler to use for drawing the root title.
|
||||||
* @return A new TopMenu Handle, or INVALID_HANDLE on failure.
|
* @return A new TopMenu Handle, or INVALID_HANDLE on failure.
|
||||||
*/
|
*/
|
||||||
native Handle:CreateTopMenu(TopMenuHandler:handler);
|
native TopMenu CreateTopMenu(TopMenuHandler handler);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Re-sorts the items in a TopMenu via a configuration file.
|
* Re-sorts the items in a TopMenu via a configuration file.
|
||||||
|
@ -169,16 +289,16 @@ native Handle:CreateTopMenu(TopMenuHandler:handler);
|
||||||
* @return True on success, false on failure.
|
* @return True on success, false on failure.
|
||||||
* @error Invalid TopMenu Handle.
|
* @error Invalid TopMenu Handle.
|
||||||
*/
|
*/
|
||||||
native bool:LoadTopMenuConfig(Handle:topmenu, const String:file[], String:error[], maxlength);
|
native bool LoadTopMenuConfig(Handle topmenu, const char[] file, char[] error, int maxlength);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds an object to a TopMenu.
|
* Adds an topobj to a TopMenu.
|
||||||
*
|
*
|
||||||
* @param topmenu TopMenu Handle.
|
* @param topmenu TopMenu Handle.
|
||||||
* @param name Object name (MUST be unique).
|
* @param name Object name (MUST be unique).
|
||||||
* @param type Object type.
|
* @param type Object type.
|
||||||
* @param handler Handler for object.
|
* @param handler Handler for topobj.
|
||||||
* @param parent Parent object ID, or INVALID_TOPMENUOBJECT for none.
|
* @param parent Parent topobj ID, or INVALID_TOPMENUOBJECT for none.
|
||||||
* Items must have a category parent.
|
* Items must have a category parent.
|
||||||
* Categories must not have a parent.
|
* Categories must not have a parent.
|
||||||
* @param cmdname Command name (for access overrides).
|
* @param cmdname Command name (for access overrides).
|
||||||
|
@ -188,14 +308,14 @@ native bool:LoadTopMenuConfig(Handle:topmenu, const String:file[], String:error[
|
||||||
* failure.
|
* failure.
|
||||||
* @error Invalid TopMenu Handle.
|
* @error Invalid TopMenu Handle.
|
||||||
*/
|
*/
|
||||||
native TopMenuObject:AddToTopMenu(Handle:topmenu,
|
native TopMenuObject AddToTopMenu(Handle topmenu,
|
||||||
const String:name[],
|
const char[] name,
|
||||||
TopMenuObjectType:type,
|
TopMenuObjectType type,
|
||||||
TopMenuHandler:handler,
|
TopMenuHandler handler,
|
||||||
TopMenuObject:parent,
|
TopMenuObject parent,
|
||||||
const String:cmdname[]="",
|
const char[] cmdname="",
|
||||||
flags=0,
|
int flags=0,
|
||||||
const String:info_string[]="");
|
const char[] info_string="");
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieves the info string of a top menu item.
|
* Retrieves the info string of a top menu item.
|
||||||
|
@ -208,33 +328,33 @@ native TopMenuObject:AddToTopMenu(Handle:topmenu,
|
||||||
* null terminator.
|
* null terminator.
|
||||||
* @error Invalid TopMenu Handle or TopMenuObject ID.
|
* @error Invalid TopMenu Handle or TopMenuObject ID.
|
||||||
*/
|
*/
|
||||||
native GetTopMenuInfoString(Handle:topmenu, TopMenuObject:parent, String:buffer[], maxlength);
|
native int GetTopMenuInfoString(Handle topmenu, TopMenuObject parent, char[] buffer, int maxlength);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieves the name string of a top menu item.
|
* Retrieves the name string of a top menu item.
|
||||||
*
|
*
|
||||||
* @param topmenu TopMenu Handle.
|
* @param topmenu TopMenu Handle.
|
||||||
* @param object TopMenuObject ID.
|
* @param topobj TopMenuObject ID.
|
||||||
* @param buffer Buffer to store info string.
|
* @param buffer Buffer to store info string.
|
||||||
* @param maxlength Maximum size of info string.
|
* @param maxlength Maximum size of info string.
|
||||||
* @return Number of bytes written, not including the
|
* @return Number of bytes written, not including the
|
||||||
* null terminator.
|
* null terminator.
|
||||||
* @error Invalid TopMenu Handle or TopMenuObject ID.
|
* @error Invalid TopMenu Handle or TopMenuObject ID.
|
||||||
*/
|
*/
|
||||||
native GetTopMenuObjName(Handle:topmenu, TopMenuObject:object, String:buffer[], maxlength);
|
native int GetTopMenuObjName(Handle topmenu, TopMenuObject topobj, char[] buffer, int maxlength);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Removes an object from a TopMenu.
|
* Removes an topobj from a TopMenu.
|
||||||
*
|
*
|
||||||
* Plugins' objects are automatically removed all TopMenus when the given
|
* Plugins' topobjs are automatically removed all TopMenus when the given
|
||||||
* plugin unloads or pauses. In the case of unpausing, all items are restored.
|
* plugin unloads or pauses. In the case of unpausing, all items are restored.
|
||||||
*
|
*
|
||||||
* @param topmenu TopMenu Handle.
|
* @param topmenu TopMenu Handle.
|
||||||
* @param object TopMenuObject ID.
|
* @param topobj TopMenuObject ID.
|
||||||
* @noreturn
|
* @noreturn
|
||||||
* @error Invalid TopMenu Handle.
|
* @error Invalid TopMenu Handle.
|
||||||
*/
|
*/
|
||||||
native RemoveFromTopMenu(Handle:topmenu, TopMenuObject:object);
|
native void RemoveFromTopMenu(Handle topmenu, TopMenuObject topobj);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Displays a TopMenu to a client.
|
* Displays a TopMenu to a client.
|
||||||
|
@ -245,21 +365,21 @@ native RemoveFromTopMenu(Handle:topmenu, TopMenuObject:object);
|
||||||
* @return True on success, false on failure.
|
* @return True on success, false on failure.
|
||||||
* @error Invalid TopMenu Handle or client not in game.
|
* @error Invalid TopMenu Handle or client not in game.
|
||||||
*/
|
*/
|
||||||
native bool:DisplayTopMenu(Handle:topmenu, client, TopMenuPosition:position);
|
native bool DisplayTopMenu(Handle topmenu, int client, TopMenuPosition position);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Displays a TopMenu category to a client.
|
* Displays a TopMenu category to a client.
|
||||||
*
|
*
|
||||||
* @param topmenu TopMenu Handle.
|
* @param topmenu TopMenu Handle.
|
||||||
* @param category Category object id.
|
* @param category Category topobj id.
|
||||||
* @param client Client index.
|
* @param client Client index.
|
||||||
* @return True on success, false on failure.
|
* @return True on success, false on failure.
|
||||||
* @error Invalid TopMenu Handle or client not in game.
|
* @error Invalid TopMenu Handle or client not in game.
|
||||||
*/
|
*/
|
||||||
native bool:DisplayTopMenuCategory(Handle:topmenu, TopMenuObject:category, client);
|
native bool DisplayTopMenuCategory(Handle topmenu, TopMenuObject category, int client);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Finds a category's object ID in a TopMenu.
|
* Finds a category's topobj ID in a TopMenu.
|
||||||
*
|
*
|
||||||
* @param topmenu TopMenu Handle.
|
* @param topmenu TopMenu Handle.
|
||||||
* @param name Object's unique name.
|
* @param name Object's unique name.
|
||||||
|
@ -267,18 +387,21 @@ native bool:DisplayTopMenuCategory(Handle:topmenu, TopMenuObject:category, clien
|
||||||
* INVALID_TOPMENUOBJECT on failure.
|
* INVALID_TOPMENUOBJECT on failure.
|
||||||
* @error Invalid TopMenu Handle.
|
* @error Invalid TopMenu Handle.
|
||||||
*/
|
*/
|
||||||
native TopMenuObject:FindTopMenuCategory(Handle:topmenu, const String:name[]);
|
native TopMenuObject FindTopMenuCategory(Handle topmenu, const char[] name);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Change the menu title caching behaviour of the TopMenu. By default the titles are cached to reduce overhead.
|
* Change the menu title caching behaviour of the TopMenu. By default the
|
||||||
* If you need dynamic menu titles, which can change everytime the menu is displayed to a user, set this to false.
|
* titles are cached to reduce overhead. If you need dynamic menu titles, which
|
||||||
|
* can change everytime the menu is displayed to a user, set this to false.
|
||||||
*
|
*
|
||||||
* @param topmenu TopMenu Handle.
|
* @param topmenu TopMenu Handle.
|
||||||
* @param cache_titles Cache the menu titles and don't call the handler with TopMenuAction_DisplayTitle everytime the menu is drawn?
|
* @param cache_titles Cache the menu titles and don't call the handler with
|
||||||
|
* TopMenuAction_DisplayTitle everytime the menu is drawn?
|
||||||
* @noreturn
|
* @noreturn
|
||||||
* @error Invalid TopMenu Handle
|
* @error Invalid TopMenu Handle
|
||||||
*/
|
*/
|
||||||
native SetTopMenuTitleCaching(Handle:topmenu, bool:cache_titles);
|
native void SetTopMenuTitleCaching(Handle topmenu, bool cache_titles);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Do not edit below this line!
|
* Do not edit below this line!
|
||||||
|
|
74
env/include/usermessages.inc
vendored
74
env/include/usermessages.inc
vendored
|
@ -70,6 +70,29 @@ enum UserMessageType
|
||||||
*/
|
*/
|
||||||
native UserMessageType:GetUserMessageType();
|
native UserMessageType:GetUserMessageType();
|
||||||
|
|
||||||
|
stock Protobuf UserMessageToProtobuf(Handle msg)
|
||||||
|
{
|
||||||
|
if (GetUserMessageType() != UM_Protobuf)
|
||||||
|
return null;
|
||||||
|
return Protobuf:msg;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Make sure to only call this on writable buffers (eg from StartMessage).
|
||||||
|
stock BfWrite UserMessageToBfWrite(Handle msg)
|
||||||
|
{
|
||||||
|
if (GetUserMessageType() == UM_Protobuf)
|
||||||
|
return null;
|
||||||
|
return BfWrite:msg;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Make sure to only call this on readable buffers (eg from a message hook).
|
||||||
|
stock BfWrite UserMessageToBfRead(Handle msg)
|
||||||
|
{
|
||||||
|
if (GetUserMessageType() == UM_Protobuf)
|
||||||
|
return null;
|
||||||
|
return BfRead:msg;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the ID of a given message, or -1 on failure.
|
* Returns the ID of a given message, or -1 on failure.
|
||||||
*
|
*
|
||||||
|
@ -128,27 +151,48 @@ native Handle:StartMessageEx(UserMsg:msg, clients[], numClients, flags=0);
|
||||||
native EndMessage();
|
native EndMessage();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when a message is hooked
|
* Hook function types for user messages.
|
||||||
*
|
*/
|
||||||
* @param msg_id Message index.
|
typeset MsgHook
|
||||||
* @param msg Handle to the input bit buffer or protobuf.
|
{
|
||||||
* @param players Array containing player indexes.
|
/**
|
||||||
* @param playersNum Number of players in the array.
|
* Called when a bit buffer based usermessage is hooked
|
||||||
* @param reliable True if message is reliable, false otherwise.
|
*
|
||||||
* @param init True if message is an initmsg, false otherwise.
|
* @param msg_id Message index.
|
||||||
* @return Ignored for normal hooks. For intercept hooks, Plugin_Handled
|
* @param msg Handle to the input bit buffer.
|
||||||
* blocks the message from being sent, and Plugin_Continue
|
* @param players Array containing player indexes.
|
||||||
* resumes normal functionality.
|
* @param playersNum Number of players in the array.
|
||||||
*/
|
* @param reliable True if message is reliable, false otherwise.
|
||||||
functag public Action:MsgHook(UserMsg:msg_id, Handle:msg, const players[], playersNum, bool:reliable, bool:init);
|
* @param init True if message is an initmsg, false otherwise.
|
||||||
|
* @return Ignored for normal hooks. For intercept hooks, Plugin_Handled
|
||||||
|
* blocks the message from being sent, and Plugin_Continue
|
||||||
|
* resumes normal functionality.
|
||||||
|
*/
|
||||||
|
function Action (UserMsg msg_id, BfRead msg, const int[] players, int playersNum, bool reliable, bool init);
|
||||||
|
/**
|
||||||
|
* Called when a protobuf based usermessage is hooked
|
||||||
|
*
|
||||||
|
* @param msg_id Message index.
|
||||||
|
* @param msg Handle to the input protobuf.
|
||||||
|
* @param players Array containing player indexes.
|
||||||
|
* @param playersNum Number of players in the array.
|
||||||
|
* @param reliable True if message is reliable, false otherwise.
|
||||||
|
* @param init True if message is an initmsg, false otherwise.
|
||||||
|
* @return Ignored for normal hooks. For intercept hooks, Plugin_Handled
|
||||||
|
* blocks the message from being sent, and Plugin_Continue
|
||||||
|
* resumes normal functionality.
|
||||||
|
*/
|
||||||
|
function Action (UserMsg msg_id, Protobuf msg, const int[] players, int playersNum, bool reliable, bool init);
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when a message hook has completed.
|
* Called when a message hook has completed.
|
||||||
*
|
*
|
||||||
* @param msg_id Message index.
|
* @param msg_id Message index.
|
||||||
* @param sent True if message was sent, false if blocked.
|
* @param sent True if message was sent, false if blocked.
|
||||||
|
* @noreturn
|
||||||
*/
|
*/
|
||||||
functag public MsgPostHook(UserMsg:msg_id, bool:sent);
|
typedef MsgPostHook = function void (UserMsg msg_id, bool sent);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Hooks a user message.
|
* Hooks a user message.
|
||||||
|
@ -162,7 +206,7 @@ functag public MsgPostHook(UserMsg:msg_id, bool:sent);
|
||||||
* @noreturn
|
* @noreturn
|
||||||
* @error Invalid message index.
|
* @error Invalid message index.
|
||||||
*/
|
*/
|
||||||
native HookUserMessage(UserMsg:msg_id, MsgHook:hook, bool:intercept=false, MsgPostHook:post=MsgPostHook:-1);
|
native HookUserMessage(UserMsg:msg_id, MsgHook:hook, bool:intercept=false, MsgPostHook:post=INVALID_FUNCTION);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Removes one usermessage hook.
|
* Removes one usermessage hook.
|
||||||
|
|
4
env/include/version.inc
vendored
4
env/include/version.inc
vendored
|
@ -42,8 +42,8 @@
|
||||||
#define SOURCEMOD_V_REV 0
|
#define SOURCEMOD_V_REV 0
|
||||||
#define SOURCEMOD_V_CSET "0"
|
#define SOURCEMOD_V_CSET "0"
|
||||||
#define SOURCEMOD_V_MAJOR 1 /**< SourceMod Major version */
|
#define SOURCEMOD_V_MAJOR 1 /**< SourceMod Major version */
|
||||||
#define SOURCEMOD_V_MINOR 6 /**< SourceMod Minor version */
|
#define SOURCEMOD_V_MINOR 7 /**< SourceMod Minor version */
|
||||||
#define SOURCEMOD_V_RELEASE 0 /**< SourceMod Release version */
|
#define SOURCEMOD_V_RELEASE 0 /**< SourceMod Release version */
|
||||||
|
|
||||||
#define SOURCEMOD_VERSION "1.6.0-manual" /**< SourceMod version string (major.minor.release-tag) */
|
#define SOURCEMOD_VERSION "1.7.0-manual" /**< SourceMod version string (major.minor.release-tag) */
|
||||||
#endif
|
#endif
|
||||||
|
|
8
env/include/version_auto.inc
vendored
8
env/include/version_auto.inc
vendored
|
@ -5,11 +5,11 @@
|
||||||
#define _auto_version_included
|
#define _auto_version_included
|
||||||
|
|
||||||
#define SOURCEMOD_V_TAG ""
|
#define SOURCEMOD_V_TAG ""
|
||||||
#define SOURCEMOD_V_CSET "95ab81f"
|
#define SOURCEMOD_V_CSET "fd0aaf9"
|
||||||
#define SOURCEMOD_V_MAJOR 1
|
#define SOURCEMOD_V_MAJOR 1
|
||||||
#define SOURCEMOD_V_MINOR 6
|
#define SOURCEMOD_V_MINOR 7
|
||||||
#define SOURCEMOD_V_RELEASE 0
|
#define SOURCEMOD_V_RELEASE 0
|
||||||
#define SOURCEMOD_V_REV 4525
|
#define SOURCEMOD_V_REV 5150
|
||||||
|
|
||||||
#define SOURCEMOD_VERSION "1.6.0"
|
#define SOURCEMOD_VERSION "1.7.0"
|
||||||
|
|
BIN
env/linux/bin/spcomp-1.7.0
vendored
Executable file
BIN
env/linux/bin/spcomp-1.7.0
vendored
Executable file
Binary file not shown.
BIN
env/win32/bin/spcomp-1.7.0.exe
vendored
Normal file
BIN
env/win32/bin/spcomp-1.7.0.exe
vendored
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user