Skip to content

Commit

Permalink
Move some defines to more appropriate files:
Browse files Browse the repository at this point in the history
*a_samp* and *a_players* share standard `playerid` callbacks.  *a_samp* has the basic ones, *a_players* has the ones that respond to functions within it, and those that are for actions between two players.  a_vehicles and a_objects have fairly obvious sets of callbacks.
  • Loading branch information
Y_Less committed Mar 6, 2022
1 parent 2295182 commit b0f9fe7
Show file tree
Hide file tree
Showing 8 changed files with 910 additions and 859 deletions.
81 changes: 81 additions & 0 deletions a_actor.inc
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,34 @@
#pragma tabsize 4
#define SAMP_CONST_CORRECT

// --------------------------------------------------
// Defines
// --------------------------------------------------

// Limits
/**
* <library>a_actor</library>
*/
#if defined MAX_ACTORS
const __MAX_ACTORS = MAX_ACTORS;
#define __MAX_ACTORS
#else
const MAX_ACTORS = 1000;
#define MAX_ACTORS 1000
#endif

// Invalids
/**
* <library>a_actor</library>
*/
const INVALID_ACTOR_ID = 0xFFFF;
#define INVALID_ACTOR_ID 0xFFFF

// Checks
#if MAX_ACTORS < 1 || MAX_ACTORS > 1000
#error MAX_ACTORS must be >= 1 and <= 1000
#endif

/**
* <library>a_actor</library>
* <summary>Create a static 'actor' in the world. These 'actors' are like NPCs, however they have limited
Expand Down Expand Up @@ -293,3 +321,56 @@ native bool:IsActorInvulnerable(actorid);
*/
native bool:IsValidActor(actorid);

/**
* <summary>This callback is called when a player gives damage to an actor.</summary>
* <param name="playerid">The ID of the player that gave damage</param>
* <param name="damaged_actorid">The ID of the actor that received damage</param>
* <param name="amount">The amount of health/armour damaged_actorid has lost</param>
* <param name="weaponid">The reason that caused the damage</param>
* <param name="bodypart">The body part that was hit</param>
* <seealso name="CreateActor" />
* <seealso name="SetActorInvulnerable" />
* <seealso name="SetActorHealth" />
* <seealso name="GetActorHealth" />
* <seealso name="IsActorInvulnerable" />
* <seealso name="IsValidActor" />
* <seealso name="OnActorStreamOut" />
* <seealso name="OnPlayerStreamIn" />
* <remarks>This callback was added in <b>SA-MP 0.3.7</b> and will not work in earlier versions!</remarks>
* <remarks>This function does not get called if the actor is set invulnerable (WHICH IS BY DEFAULT).
* See <a href="#SetActorInvulnerable">SetActorInvulnerable</a>.</remarks>
* <returns>
* <b><c>1</c></b> - Callback will not be called in other filterscripts.<br />
* <b><c>0</c></b> - Allows this callback to be called in other filterscripts.<br />
* It is always called first in filterscripts so returning <b><c>1</c></b> there blocks other filterscripts
* from seeing it.
* </returns>
*/
forward OnPlayerGiveDamageActor(playerid, damaged_actorid, Float:amount, weaponid, bodypart);

/**
* <summary>This callback is called when an actor is streamed in by a player's client.</summary>
* <param name="actorid">The ID of the actor that has been streamed in for the player</param>
* <param name="forplayerid">The ID of the player that streamed the actor in</param>
* <seealso name="OnActorStreamOut" />
* <seealso name="OnPlayerStreamIn" />
* <remarks>This function was added in <b>SA-MP 0.3.7</b> and will not work in earlier versions!</remarks>
* <remarks>This callback can also be called by NPC.</remarks>
* <remarks>It is always called first in filterscripts.</remarks>
* <returns>This callback does not handle returns.</returns>
*/
forward OnActorStreamIn(actorid, forplayerid);

/**
* <summary>This callback is called when an actor is streamed out by a player's client.</summary>
* <param name="actorid">The ID of the actor that has been streamed out for the player</param>
* <param name="forplayerid">The ID of the player that streamed the actor out</param>
* <seealso name="OnActorStreamIn" />
* <seealso name="OnPlayerStreamOut" />
* <remarks>This function was added in <b>SA-MP 0.3.7</b> and will not work in earlier versions!</remarks>
* <remarks>This callback can also be called by NPC.</remarks>
* <remarks>It is always called first in filterscripts.</remarks>
* <returns>This callback does not handle returns.</returns>
*/
forward OnActorStreamOut(actorid, forplayerid);

9 changes: 9 additions & 0 deletions a_http.inc
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,15 @@
// Defines
// --------------------------------------------------

// Limits

// Invalids

// Checks

// Enums
///

/**
* <library>a_http</library>
* <summary>HTTP request types</summary>
Expand Down
61 changes: 32 additions & 29 deletions a_npc.inc
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,38 @@ const Text3D:INVALID_3DTEXT_ID = Text3D:0xFFFF;
const PlayerText3D:INVALID_PLAYER_3DTEXT_ID = PlayerText3D:0xFFFF;
#define INVALID_PLAYER_3DTEXT_ID (PlayerText3D:0xFFFF)

// Checks
#if MAX_PLAYER_NAME < 1 || MAX_PLAYER_NAME > 24
#error MAX_PLAYER_NAME must be >= 1 and <= 24
#endif

#if MAX_PLAYERS < 1 || MAX_PLAYERS > 1000
#error MAX_PLAYERS must be >= 1 and <= 1000
#endif

#if MAX_VEHICLES < 1 || MAX_VEHICLES > 2000
#error MAX_VEHICLES must be >= 1 and <= 2000
#endif

#if MAX_OBJECTS < 1 || MAX_OBJECTS > 2000
#error MAX_OBJECTS must be >= 1 and <= 2000
#endif

#if MAX_GANG_ZONES < 1 || MAX_GANG_ZONES > 1024
#error MAX_GANG_ZONES must be >= 1 and <= 1024
#endif

#if MAX_TEXT_DRAWS < Text:1 || MAX_TEXT_DRAWS > Text:2048
#error MAX_TEXT_DRAWS must be >= 1 and <= 2048
#endif

#if MAX_MENUS < Menu:1 || MAX_MENUS > Menu:128
#error MAX_MENUS must be >= 1 and <= 128
#endif

// Enums
///

/**
* <library>a_npc</library>
* <summary>States</summary>
Expand Down Expand Up @@ -460,35 +492,6 @@ enum PLAYER_RECORDING_TYPE:__PLAYER_RECORDING_TYPE
}
static stock PLAYER_RECORDING_TYPE:_@PLAYER_RECORDING_TYPE() { return __PLAYER_RECORDING_TYPE; }

// Checks
#if MAX_PLAYER_NAME < 1 || MAX_PLAYER_NAME > 24
#error MAX_PLAYER_NAME must be >= 1 and <= 24
#endif

#if MAX_PLAYERS < 1 || MAX_PLAYERS > 1000
#error MAX_PLAYERS must be >= 1 and <= 1000
#endif

#if MAX_VEHICLES < 1 || MAX_VEHICLES > 2000
#error MAX_VEHICLES must be >= 1 and <= 2000
#endif

#if MAX_OBJECTS < 1 || MAX_OBJECTS > 2000
#error MAX_OBJECTS must be >= 1 and <= 2000
#endif

#if MAX_GANG_ZONES < 1 || MAX_GANG_ZONES > 1024
#error MAX_GANG_ZONES must be >= 1 and <= 1024
#endif

#if MAX_TEXT_DRAWS < Text:1 || MAX_TEXT_DRAWS > Text:2048
#error MAX_TEXT_DRAWS must be >= 1 and <= 2048
#endif

#if MAX_MENUS < Menu:1 || MAX_MENUS > Menu:128
#error MAX_MENUS must be >= 1 and <= 128
#endif

#include <core>
#include <float>
#include <string>
Expand Down
163 changes: 163 additions & 0 deletions a_objects.inc
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,46 @@
// Defines
// --------------------------------------------------

// Limits
/**
* <library>a_objects</library>
*/
#if defined MAX_OBJECTS
const __MAX_OBJECTS = MAX_OBJECTS;
#define __MAX_OBJECTS
#else
const MAX_OBJECTS = 2000;
#define MAX_OBJECTS 2000
#endif

// Invalids
/**
* <library>a_objects</library>
*/
const INVALID_OBJECT_ID = 0xFFFF;
#define INVALID_OBJECT_ID 0xFFFF

// Checks
#if MAX_OBJECTS < 1 || MAX_OBJECTS > 2000
#error MAX_OBJECTS must be >= 1 and <= 2000
#endif

// Enums
///

/**
* <library>a_objects</library>
*/
#define SELECT_OBJECT: __TAG(SELECT_OBJECT):
enum SELECT_OBJECT:__SELECT_OBJECT
{
SELECT_OBJECT_GLOBAL_OBJECT = 1,
SELECT_OBJECT_PLAYER_OBJECT
}
static stock SELECT_OBJECT:_@SELECT_OBJECT() { return __SELECT_OBJECT; }

///

/**
* <library>a_objects</library>
*/
Expand Down Expand Up @@ -832,3 +872,126 @@ native SetPlayerObjectMaterialText(playerid, objectid, const text[], materialInd
*/
native SetObjectsDefaultCameraCol(bool:disable);

/**
* <summary>This callback is called when a player selects an object after <a href="#SelectObject">SelectObject</a>
* has been used.</summary>
* <param name="playerid">The ID of the player that selected an object</param>
* <param name="type">The type of selection</param>
* <param name="objectid">The ID of the selected object</param>
* <param name="modelid">The model ID of the selected object</param>
* <param name="fX">The X position of the selected object</param>
* <param name="fY">The Y position of the selected object</param>
* <param name="fZ">The Z position of the selected object</param>
* <seealso name="SelectObject" />
* <remarks>This function was added in <b>SA-MP 0.3e</b> and will not work in earlier versions!</remarks>
* <returns>
* <b><c>1</c></b> - Will prevent other scripts from receiving this callback.<br />
* <b><c>0</c></b> - Indicates that this callback will be passed to the next script.<br />
* It is always called first in filterscripts.
* </returns>
*/
#if !defined SELECT_OBJECT
#define SELECT_OBJECT: _:
#endif
forward OnPlayerSelectObject(playerid, SELECT_OBJECT:type, objectid, modelid, Float:fX, Float:fY, Float:fZ);

/**
* <summary>This callback is called when a player finishes editing an object (<a href="#EditObject">EditObject</a>/<a
* href="#EditPlayerObject">EditPlayerObject</a>).</summary>
* <param name="playerid">The ID of the player that edited an object</param>
* <param name="playerobject"><b><c>0</c></b> if it is a global object or <b><c>1</c></b> if it is a
* playerobject</param>
* <param name="objectid">The ID of the edited object</param>
* <param name="response">The type of response</param>
* <param name="fX">The X offset for the object that was edited</param>
* <param name="fY">The Y offset for the object that was edited</param>
* <param name="fZ">The Z offset for the object that was edited</param>
* <param name="fRotX">The X rotation for the object that was edited</param>
* <param name="fRotY">The Y rotation for the object that was edited</param>
* <param name="fRotZ">The Z rotation for the object that was edited</param>
* <seealso name="EditObject" />
* <seealso name="CreateObject" />
* <seealso name="DestroyObject" />
* <seealso name="MoveObject" />
* <remarks>This callback was added in <b>SA-MP 0.3e</b> and will not work in earlier versions!</remarks>
* <remarks>When using <b><c>EDIT_RESPONSE_UPDATE</c></b> be aware that this callback will not be called
* when releasing an edit in progress resulting in the last update of <b><c>EDIT_RESPONSE_UPDATE</c></b>
* being out of sync of the objects current position.</remarks>
* <returns>
* <b><c>1</c></b> - Will prevent other scripts from receiving this callback.<br />
* <b><c>0</c></b> - Indicates that this callback will be passed to the next script.<br />
* It is always called first in filterscripts.
* </returns>
*/
#if !defined EDIT_RESPONSE
#define EDIT_RESPONSE: _:
#endif
forward OnPlayerEditObject(playerid, playerobject, objectid, EDIT_RESPONSE:response, Float:fX, Float:fY, Float:fZ, Float:fRotX, Float:fRotY, Float:fRotZ);

/**
* <summary>This callback is called when a player ends attached object edition mode.</summary>
* <param name="playerid">The ID of the player that ended edition mode</param>
* <param name="response"><b><c>0</c></b> if they cancelled (ESC) or <b><c>1</c></b> if they clicked
* the save icon</param>
* <param name="index">The index of the attached object</param>
* <param name="modelid">The model of the attached object that was edited</param>
* <param name="boneid">The bone of the attached object that was edited</param>
* <param name="fOffsetX">The X offset for the attached object that was edited</param>
* <param name="fOffsetY">The Y offset for the attached object that was edited</param>
* <param name="fOffsetZ">The Z offset for the attached object that was edited</param>
* <param name="fRotX">The X rotation for the attached object that was edited</param>
* <param name="fRotY">The Y rotation for the attached object that was edited</param>
* <param name="fRotZ">The Z rotation for the attached object that was edited</param>
* <param name="fScaleX">The X scale for the attached object that was edited</param>
* <param name="fScaleY">The Y scale for the attached object that was edited</param>
* <param name="fScaleZ">The Z scale for the attached object that was edited</param>
* <seealso name="EditAttachedObject" />
* <seealso name="SetPlayerAttachedObject" />
* <remarks>This callback was added in <b>SA-MP 0.3e</b> and will not work in earlier versions!</remarks>
* <remarks>Editions should be discarded if response was <b><c>0</c></b> (cancelled). This must be
* done by storing the offsets etc. in an array BEFORE using <a href="#EditAttachedObject">EditAttachedObject</a>.</remarks>
* <returns>
* <b><c>1</c></b> - Will prevent other scripts from receiving this callback.<br />
* <b><c>0</c></b> - Indicates that this callback will be passed to the next script.<br />
* It is always called first in filterscripts.
* </returns>
*/
#if !defined EDIT_RESPONSE
#define EDIT_RESPONSE: _:
#endif
forward OnPlayerEditAttachedObject(playerid, EDIT_RESPONSE:response, index, modelid, boneid, Float:fOffsetX, Float:fOffsetY, Float:fOffsetZ, Float:fRotX, Float:fRotY, Float:fRotZ, Float:fScaleX, Float:fScaleY, Float:fScaleZ);

/**
* <summary>This callback is called when an object is moved after <a href="#MoveObject">MoveObject</a>
* (when it stops moving).</summary>
* <param name="objectid">The ID of the object that was moved</param>
* <seealso name="MoveObject" />
* <seealso name="IsObjectMoving" />
* <seealso name="StopObject" />
* <seealso name="OnPlayerObjectMoved" />
* <remarks><a href="#SetObjectPos">SetObjectPos</a> does not work when used in this callback. To fix
* it, recreate the object.</remarks>
* <returns>
* This callback does not handle returns.<br />
* It is always called first in filterscripts.
* </returns>
*/
forward OnObjectMoved(objectid);

/**
* <summary>This callback is called when a player object is moved after <a href="#MovePlayerObject">MovePlayerObject</a>
* (when it stops moving).</summary>
* <param name="playerid">The playerid the object is assigned to</param>
* <param name="objectid">The ID of the player object that was moved</param>
* <seealso name="OnObjectMoved" />
* <seealso name="MovePlayerObject" />
* <seealso name="IsPlayerObjectMoving" />
* <seealso name="StopPlayerObject" />
* <remarks>This callback can also be called for NPC.</remarks>
* <returns>
* This callback does not handle returns.<br />
* It is always called first in filterscripts.
* </returns>
*/
forward OnPlayerObjectMoved(playerid, objectid);

Loading

0 comments on commit b0f9fe7

Please sign in to comment.