273 changes: 238 additions & 35 deletions plugins/include/fun.inc
Original file line number Diff line number Diff line change
Expand Up @@ -21,81 +21,284 @@
#pragma loadlib fun
#endif

/* Returns 1 if receiver hears sender via voice communication. */
/**
* Tells whether receiver hears sender via voice communication.
*
* @param receiver Receiver
* @param sender Sender
*
* @return 1 if receiver hears the sender, 0 otherwise.
* @error If receiver or sender are not connected or not
* within the range of 1 to MaxClients.
*/
native get_client_listen(receiver, sender);

/* Sets who can listen who. Function returns 0
* if for some reasons this setting can't be done. */
/**
* Sets who can listen who.
*
* @param receiver Receiver
* @param sender Sender
* @param listen 1 if receiver should be able to hear sender, 0 if not
*
* @return 0 if the setting can't be done for some reason.
* @error If receiver or sender are not connected or not
* within the range of 1 to MaxClients.
*/
native set_client_listen(receiver, sender, listen);

/* Sets player godmode. If you want to disable godmode set only first parameter. */
/**
* Sets player's godmode
*
* @param index Client index
* @param godmode 1 to enable godmode, 0 to disable
*
* @noreturn
* @error If player is not connected or not within the range
* of 1 to MaxClients.
*/
native set_user_godmode(index, godmode = 0);

/* Returns 1 if godmode is set. */
/**
* Tells whether a player has godmode on
*
* @param index Client index
*
* @return 1 if player has godmode on, 0 if not
* @error If player is not connected or not within the range
* of 1 to MaxClients.
*/
native get_user_godmode(index);

/* Sets player armor. */
/**
* Sets player's armor amount
*
* @param index Client index
* @param armor The armor amount to set
*
* @noreturn
* @error If player is not connected or not within the range
* of 1 to MaxClients.
*/
native set_user_armor(index, armor);

/* Sets player health. */
/**
* Sets player's health amount
*
* @param index Client index
* @param health The health amount to set
*
* @noreturn
* @error If player is not connected or not within the range
* of 1 to MaxClients.
*/
native set_user_health(index, health);

/* Move player to origin. */
/**
* Moves a player to the given origin
*
* @param index Client index
* @param origin Origin to move a player to
*
* @noreturn
* @error If player is not connected or not within the range
* of 1 to MaxClients.
*/
native set_user_origin(index, const origin[3]);

/* Sets player rendering mode. */
/**
* Sets player's rendering mode
*
* @note A really useful render modes reference:
* https://sites.google.com/site/svenmanor/rendermodes
*
* @param index Client index
* @param fx Rendering effects. One of kRenderFx* constants.
* @param r The amount of red color (0 to 255)
* @param g The amount of green color (0 to 255)
* @param b The amount of blue color (0 to 255)
* @param render Render mode. One of kRender* constants.
* @param amount Render amount (0 to 255)
*
* @noreturn
* @error If player is not connected or not within the range
* of 1 to MaxClients.
*/
native set_user_rendering(index, fx = kRenderFxNone, r = 0, g = 0, b = 0, render = kRenderNormal, amount = 0);

/* Gives item to player, name of item can start
* with weapon_, ammo_ and item_. This event
* is announced with proper message to all players. */
/**
* Gives an item to a player.
*
* @param index Client index
* @param item Classname of the item to give. Should start with either
* "weapon_", "ammo_", "item_" or "tf_weapon_".
*
* @noreturn
* @error If player is not connected or not within the range
* of 1 to MaxClients or item creation fails.
*/
native give_item(index, const item[]);

/* Sets hit zones for player.
* Parts of body are as bits:
* 1 - generic
* 2 - head
* 4 - chest
* 8 - stomach
* 16 - left arm
* 32 - right arm
* 64 - left leg
* 128 - right leg */
/**
* Sets (adds, removes) hit zones for a player.
*
* @note This actually set rules of how any player can hit any other. Example:
* set_user_hitzones(id, target, 2);
* makes @id be able to hit @target only in the head.
*
* @param index Client index
* @param target The target player
* @param body A bitsum of the body parts that can/can't be shot.
* 1 generic
* 2 - head
* 4 - chest
* 8 - stomach
* 16 - left arm
* 32 - right arm
* 64 - left leg
* 128 - right leg
*
* @noreturn
* @error If player is not connected or not within the range
* of 1 to MaxClients.
*/
native set_user_hitzones(index = 0, target = 0, body = 255);

/* Get user hitzones. */
/**
* Gets the set of hit zone "rules" between @index and @target players.
*
* @note For the body part bitsum take a look at the set_user_hitzones() native.
*
* @param index Client index
* @param target The target player
*
* @return The bitsum of @target's body parts @index is able to hit
* @error If player is not connected or not within the range
* of 1 to MaxClients.
*/
native get_user_hitzones(index, target);

/* Sets users max. speed. */
/**
* Sets player's maximum movement speed
*
* @param index Client index
* @param speed The maximum speed player will be able to run at
*
* @noreturn
* @error If player is not connected or not within the range
* of 1 to MaxClients.
*/
native set_user_maxspeed(index, Float:speed = -1.0);

/* Returns users max. speed. */
/**
* Gets player's maximum movement speed
*
* @param index Client index
*
* @return Player's maximum movement speed
* @error If player is not connected or not within the range
* of 1 to MaxClients.
*/
native Float:get_user_maxspeed(index);

/* Sets users gravity. */
/**
* Sets player's gravity
*
* @param index Client index
* @param gravity Gravity value to set, 1.0 being normal gravity (800)
*
* @noreturn
* @error If player is not connected or not within the range
* of 1 to MaxClients.
*/
native set_user_gravity(index, Float:gravity = 1.0);

/* Returns users gravity. */
/**
* Gets player's gravity
*
* @param index Client index
*
* @return Player's gravity value, 1.0 being normal gravity (800)
* @error If player is not connected or not within the range
* of 1 to MaxClients.
*/
native Float:get_user_gravity(index);

/* Spawns entity. */
/**
* Spawns an entity
*
* @param index Entity index
*
* @noreturn
* @error If player is not connected or not within the range
* of 1 to MaxClients.
*/
native spawn(index);

/* Sets player noclip. If you want to disable noclip set only first parameter. */
/**
* Sets player's noclip
*
* @param index Client index
* @param noclip 1 to enable noclip, 0 to disable
*
* @noreturn
* @error If player is not connected or not within the range
* of 1 to MaxClients.
*/
native set_user_noclip(index, noclip = 0);

/* Returns 1 if noclip is set. */
/**
* Gets player's noclip
*
* @param index Client index
*
* @return 1 if noclip is enabled, 0 if disabled
* @error If player is not connected or not within the range
* of 1 to MaxClients.
*/
native get_user_noclip(index);

/* Returns 1 if player has silent footsteps, 0 if footsteps are set to normal */
/**
* Tells whether a player has silent footsteps
*
* @param index Client index
*
* @return 1 if silent footsteps are enabled, 0 if not
* @error If player is not connected or not within the range
* of 1 to MaxClients.
*/
native get_user_footsteps(index);

/* Gives player silent footsteps.
* if set = 0 it will return footsteps to normal */
/**
* Sets player's silent footsteps
*
* @param index Client index
* @param set 1 if player should have silent footsteps, 0 otherwise
*
* @noreturn
* @error If player is not connected or not within the range
* of 1 to MaxClients.
*/
native set_user_footsteps(id, set = 1);

/* Strips all weapons from user. */
/**
* Strips all weapons from a player, including their knife.
*
* @param index Client index
*
* @noreturn
* @error If player is not connected or not within the range
* of 1 to MaxClients.
*/
native strip_user_weapons(index);

/* Sets player frags. */
/**
* Sets player's frags amount
*
* @param index Client index
* @param frags The amount of frags to set
*
* @noreturn
* @error If player is not connected or not within the range
* of 1 to MaxClients.
*/
native set_user_frags(index, frags);
122 changes: 105 additions & 17 deletions plugins/include/nvault.inc
Original file line number Diff line number Diff line change
Expand Up @@ -21,43 +21,131 @@
#pragma loadlib nvault
#endif

/* All timestamps are in UNIX epoch form. */
/**
* @global All timestamps are in UNIX epoch form.
*/

/* Opens a vault by name (such as "myvault")
* Returns a vault id, INVALID_HANDLE otherwise (-1)
/**
* Opens a vault by name. Creates a vault if it doesn't exist yet.
*
* @param name Name of the vault. The vault will be created in
* ${amxx_datadir}/vault directory.
*
* @return The vault handle to be used in other natives.
* INVALID_HANDLE (-1) if not successfully opened.
*/
native nvault_open(const name[]);

/* Gets a vault value by returning an int
* setting a byref float or setting a string + maxlength
/**
* Retrieves a value from the given key
*
* @note An example of retrieving a string:
* nvault_get(vaultHandle, "myKey", myString, charsmax(myString));
*
* @param vault A vault handle returned from nvault_open()
* @param key A key to get the value from
* @param ... If three argument are given, gets a float value and
* puts it in the third argument by reference.
* If four arguments are given, gets a string from the
* vault and copies it to the third argument, up to
* 4th argument characters.
*
* @noreturn
* @error On invalid vault handle.
*/
native nvault_get(vault, const key[], any:...);

/* Looks up a vault value for full information
* Returns 0 if the entry is not found
/**
* Retrieves full information about a vault entry
*
* @param vault A vault handle returned from nvault_open()
* @param key A key to get information from
* @param value A string where the value should be stored
* @param maxlen Maximum length of the @value string
* @param timestamp The timestamp of the entry
*
* @return 1 if an entry was found, 0 otherwise.
* @error On invalid vault handle.
*/
native nvault_lookup(vault, const key[], value[], maxlen, &timestamp);

/* Sets a vault value (with current timestamp) */
/**
* Sets value of a vault entry and updates the timestamp.
*
* @note A new entry is created if one with the given key doesn't exist.
*
* @param vault A vault handle returned from nvault_open()
* @param key A key to set the value for
* @param value A value to set
*
* @noreturn
* @error On invalid vault handle.
*/
native nvault_set(vault, const key[], const value[]);

/* Sets a permanent vault value (no timestamp) */
/**
* Sets value of a vault entry and makes it permanent (non-erasable with nvault_prune()).
*
* @note A new entry is created if one with the given key doesn't exist.
* @note Permanent entries have no timestamp.
*
* @param vault A vault handle returned from nvault_open()
* @param key A key to set the permanent value for
* @param value A permanent value to set
*
* @noreturn
* @error On invalid vault handle.
*/
native nvault_pset(vault, const key[], const value[]);

/* Prunes the vault for entries that are within the given timestamps.
* This will not erase values set with pset
/**
* Prunes the vault for entries that are within the given timestamps.
*
* @note This will not erase values set with nvault_pset().
* @note An example of pruning all entries that are older than 24 hours:
* nvault_prune(vaultHandle, 0, get_systime() - (60 * 60 * 24));
*
* @param vault A vault handle returned from nvault_open()
* @param start The timestamp to start erasing from
* @param end The timestamp to erase to
*
* @noreturn
* @error On invalid vault handle.
*/
native nvault_prune(vault, start, end);

/* Closes a vault */
/**
* Closes a vault.
*
* @param vault A vault handle returned from nvault_open()
*
* @noreturn
* @error On invalid vault handle.
*/
native nvault_close(vault);

/* Removes a key from the vault */
/**
* Removes an entry from the vault by its key.
*
* @param vault A vault handle returned from nvault_open()
* @param key The key to remove from the vault
*
* @noreturn
* @error On invalid vault handle.
*/
native nvault_remove(vault, const key[]);

/* "Touches" a key to update its timestamp value.
* If stamp is -1 (default), it will use the current time.
* Like the unix command "touch," it will create an empty key
* if the value does not exist.
/**
* "Touches" an entry in the vault, updating its timestamp.
*
* @note If timestamp is equal to -1, it will use the current time.
* @note An empty entry is created if one with the given key doesn't exist.
*
* @param vault A vault handle returned from nvault_open()
* @param key The key to search for
* @param timestamp Update an entry's timestamp to this one. Default is -1.
*
* @noreturn
* @error On invalid vault handle.
*/
native nvault_touch(vault, const key[], timestamp=-1);
4 changes: 4 additions & 0 deletions plugins/include/sockets.inc
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,10 @@ native socket_close(_socket);
*
* @note The amount of bytes than you end up receiving can be less than the one you expected.
*
* @note This function will completely block the server until some data arrives
* to the given socket. Use this only if you are sure there is some data
* to be retrieved. You can do that by polling with socket_is_readable().
*
* @param _socket Socket descriptor
* @param _data Array to save the data
* @param _length Length of the array
Expand Down
404 changes: 287 additions & 117 deletions plugins/include/sqlx.inc

Large diffs are not rendered by default.

88 changes: 77 additions & 11 deletions plugins/include/vector.inc
Original file line number Diff line number Diff line change
Expand Up @@ -16,34 +16,93 @@
#endif
#define _corevector_included

/* Used for angle_vector() */
/**
* Used for angle_vector()
*/
#define ANGLEVECTOR_FORWARD 1
#define ANGLEVECTOR_RIGHT 2
#define ANGLEVECTOR_UP 3

/* Returns distance between two vectors. */
/**
* Calculates the distance between two input vectors.
*
* @param origin1 The first vector
* @param origin2 The second vector
*
* @return The distance between two input vectors
*/
native get_distance(const origin1[3], const origin2[3]);

/* Gets distance between two origins (float). */
/**
* Calculates the distance between two input float vectors.
*
* @param origin1 The first vector
* @param origin2 The second vector
*
* @return The distance between two input vectors
*/
native Float:get_distance_f(const Float:Origin1[3], const Float:Origin2[3]);

/* Gives you a velocity in the direction a player is looking, iVelocity is the multiplier. */
/**
* Calculates velocity in the direction player is looking.
*
* @param iIndex Client index
* @param iVelocity Multiply vRetValue length by this much
* @param vRetValue Store the calculated velocity in this vector.
*
* @noreturn
* @error If client is not connected or client index is not
* within the range of 1 to MaxClients.
*/
native velocity_by_aim(iIndex, iVelocity, Float:vRetValue[3]);

/* Changes a vector into an angle vector. */
/**
* Changes a vector into an angle vector.
*
* @param fVector Input vector
* @param vReturn Output angle vector
*
* @noreturn
*/
native vector_to_angle(const Float:fVector[3], Float:vReturn[3]);

/* Changes an angle vector into a vector. */
/**
* Changes an angle vector into a vector.
*
* @param vector Input angle vector
* @param FRU One of the ANGLEVECTOR_* constants
* @param ret Output vector
*
* @noreturn
*/
native angle_vector(const Float:vector[3], FRU, Float:ret[3]);

/* Gets the length of a vector (float[3]). */
/**
* Calculates the length of a vector.
*
* @param vVector Input vector
*
* @return Length of the input vector
*/
native Float:vector_length(const Float:vVector[3]);

/* Gets the distance between 2 vectors (float[3]). */
/**
* Calculates the distance between two vectors.
*
* @param vVector The first vector
* @param vVector2 The second vector
*
* @return Distance between two input vectors
*/
native Float:vector_distance(const Float:vVector[3], const Float:vVector2[3]);

/* Changes an integer vec to a floating vec
* This is not a for loop because that's slower
/**
* Converts an integer vector to a floating point vector.
*
* @param IVec Input integer vector
* @param FVec Output float vector
*
* @noreturn
*/
stock IVecFVec(const IVec[3], Float:FVec[3])
{
Expand All @@ -54,7 +113,14 @@ stock IVecFVec(const IVec[3], Float:FVec[3])
return 1;
}

/* Changes a float vec to an integer vec */
/**
* Converts a floating point vector into an integer vector.
*
* @param FVec Input float vector
* @param IVec Output integer vector
*
* @noreturn
*/
stock FVecIVec(const Float:FVec[3], IVec[3])
{
IVec[0] = floatround(FVec[0]);
Expand Down
687 changes: 537 additions & 150 deletions plugins/include/xs.inc

Large diffs are not rendered by default.