From b8d3c133e91d09dd3669bc7a4e929dc9ee14074f Mon Sep 17 00:00:00 2001 From: Adib Date: Sat, 16 Dec 2023 10:05:48 +0330 Subject: [PATCH] Added more core scripting functions documents. (#794) * add AddServerRule.md * add RemoveServerRule.md * add IsValidServerRule.md * add AllowNickNameCharacter.md * add IsValidNickName.md * add ToggleChatTextReplacement.md * add ChatTextReplacementToggled.md * add EnableAllAnimations.md * add IsValidAnimationLibrary.md * add tags for IsValidAnimationLibrary.md * add AreAllAnimationsEnabled.md * add AreInteriorWeaponsAllowed.md * add IsAdminTeleportAllowed.md * add IsBanned.md * add ClearBanList.md * add HideGameTextForPlayer.md * add HideGameTextForAll.md * add GetPlayerWeather.md * add GetWeather.md * add GetWorldTime.md * add CountRunningTimers.md * add GetRunningTimers.md * add GetPlayers.md * update callbacks/OnPlayerText.md * update AllowAdminTeleport.md * update AllowInteriorWeapons.md * update ApplyAnimation.md * update BlockIpAddress.md * update UnBlockIpAddress.md * update GameTextForAll.md * update GameTextForPlayer.md * update GetPlayerName.md * update SetPlayerName.md * update SetPlayerWeather.md * update KillTimer.md * update SetTimer.md * update SetTimerEx.md * update SetWeather.md * update SetWorldTime.md * update GetPlayers.md * add GetVehicles.md * add GetActors.md * update IsAdminTeleportAllowed.md --- docs/scripting/callbacks/OnPlayerText.md | 1 + docs/scripting/functions/AddServerRule.md | 36 +++++++++++++ .../scripting/functions/AllowAdminTeleport.md | 1 + .../functions/AllowInteriorWeapons.md | 1 + .../functions/AllowNickNameCharacter.md | 39 ++++++++++++++ docs/scripting/functions/ApplyAnimation.md | 29 ++++++++-- .../functions/AreAllAnimationsEnabled.md | 36 +++++++++++++ .../functions/AreInteriorWeaponsAllowed.md | 30 +++++++++++ docs/scripting/functions/BlockIpAddress.md | 5 ++ .../functions/ChatTextReplacementToggled.md | 27 ++++++++++ docs/scripting/functions/ClearBanList.md | 54 +++++++++++++++++++ .../scripting/functions/CountRunningTimers.md | 27 ++++++++++ .../functions/EnableAllAnimations.md | 53 ++++++++++++++++++ docs/scripting/functions/GameTextForAll.md | 2 + docs/scripting/functions/GameTextForPlayer.md | 2 + docs/scripting/functions/GetActors.md | 30 +++++++++++ docs/scripting/functions/GetPlayerName.md | 1 + docs/scripting/functions/GetPlayerWeather.md | 33 ++++++++++++ docs/scripting/functions/GetPlayers.md | 30 +++++++++++ docs/scripting/functions/GetRunningTimers.md | 31 +++++++++++ docs/scripting/functions/GetVehicles.md | 30 +++++++++++ docs/scripting/functions/GetWeather.md | 26 +++++++++ docs/scripting/functions/GetWorldTime.md | 25 +++++++++ .../scripting/functions/HideGameTextForAll.md | 45 ++++++++++++++++ .../functions/HideGameTextForPlayer.md | 37 +++++++++++++ .../functions/IsAdminTeleportAllowed.md | 32 +++++++++++ docs/scripting/functions/IsBanned.md | 45 ++++++++++++++++ .../functions/IsValidAnimationLibrary.md | 40 ++++++++++++++ docs/scripting/functions/IsValidNickName.md | 46 ++++++++++++++++ docs/scripting/functions/IsValidServerRule.md | 37 +++++++++++++ docs/scripting/functions/KillTimer.md | 1 + docs/scripting/functions/RemoveServerRule.md | 30 +++++++++++ docs/scripting/functions/SetPlayerName.md | 2 + docs/scripting/functions/SetPlayerWeather.md | 1 + docs/scripting/functions/SetTimer.md | 1 + docs/scripting/functions/SetTimerEx.md | 1 + docs/scripting/functions/SetWeather.md | 1 + docs/scripting/functions/SetWorldTime.md | 1 + .../functions/ToggleChatTextReplacement.md | 47 ++++++++++++++++ docs/scripting/functions/UnBlockIpAddress.md | 4 ++ 40 files changed, 915 insertions(+), 5 deletions(-) create mode 100644 docs/scripting/functions/AddServerRule.md create mode 100644 docs/scripting/functions/AllowNickNameCharacter.md create mode 100644 docs/scripting/functions/AreAllAnimationsEnabled.md create mode 100644 docs/scripting/functions/AreInteriorWeaponsAllowed.md create mode 100644 docs/scripting/functions/ChatTextReplacementToggled.md create mode 100644 docs/scripting/functions/ClearBanList.md create mode 100644 docs/scripting/functions/CountRunningTimers.md create mode 100644 docs/scripting/functions/EnableAllAnimations.md create mode 100644 docs/scripting/functions/GetActors.md create mode 100644 docs/scripting/functions/GetPlayerWeather.md create mode 100644 docs/scripting/functions/GetPlayers.md create mode 100644 docs/scripting/functions/GetRunningTimers.md create mode 100644 docs/scripting/functions/GetVehicles.md create mode 100644 docs/scripting/functions/GetWeather.md create mode 100644 docs/scripting/functions/GetWorldTime.md create mode 100644 docs/scripting/functions/HideGameTextForAll.md create mode 100644 docs/scripting/functions/HideGameTextForPlayer.md create mode 100644 docs/scripting/functions/IsAdminTeleportAllowed.md create mode 100644 docs/scripting/functions/IsBanned.md create mode 100644 docs/scripting/functions/IsValidAnimationLibrary.md create mode 100644 docs/scripting/functions/IsValidNickName.md create mode 100644 docs/scripting/functions/IsValidServerRule.md create mode 100644 docs/scripting/functions/RemoveServerRule.md create mode 100644 docs/scripting/functions/ToggleChatTextReplacement.md diff --git a/docs/scripting/callbacks/OnPlayerText.md b/docs/scripting/callbacks/OnPlayerText.md index c761440cb..a8cb36231 100644 --- a/docs/scripting/callbacks/OnPlayerText.md +++ b/docs/scripting/callbacks/OnPlayerText.md @@ -45,3 +45,4 @@ The following functions might be useful, as they're related to this callback in - [SendPlayerMessageToPlayer](../functions/SendPlayerMessageToPlayer): Force a player to send text for one player. - [SendPlayerMessageToAll](../functions/SendPlayerMessageToAll): Force a player to send text for all players. +- [ToggleChatTextReplacement](../functions/ToggleChatTextReplacement): Toggles the chat input filter. diff --git a/docs/scripting/functions/AddServerRule.md b/docs/scripting/functions/AddServerRule.md new file mode 100644 index 000000000..ee938580e --- /dev/null +++ b/docs/scripting/functions/AddServerRule.md @@ -0,0 +1,36 @@ +--- +title: AddServerRule +description: Add a server rule. +tags: ["rule"] +--- + + + +## Description + +Add a server rule. + +| Name | Description | +| ----------------- | ----------------------------------------------------------- | +| const rule[] | The server rule name to add. | +| const format[] | The server rule value. | +| OPEN_MP_TAGS:... | Indefinite number of arguments of any tag. | + +## Returns + +Returns true if the function executed successfully, otherwise false. + +## Examples + +```c +public OnGameModeInit() +{ + AddServerRule("discord", "discord.gg/samp"); + return 1; +} +``` + +## Related Functions + +- [RemoveServerRule](RemoveServerRule): Remove the server rule. +- [IsValidServerRule](IsValidServerRule): Checks if the given server rule is valid. diff --git a/docs/scripting/functions/AllowAdminTeleport.md b/docs/scripting/functions/AllowAdminTeleport.md index 913cf7245..d5543cf0b 100644 --- a/docs/scripting/functions/AllowAdminTeleport.md +++ b/docs/scripting/functions/AllowAdminTeleport.md @@ -35,5 +35,6 @@ public OnGameModeInit() ## Related Functions +- [IsAdminTeleportAllowed](IsAdminTeleportAllowed): Checks if the RCON admins allowed to teleport by right-clicking on the map. - [IsPlayerAdmin](IsPlayerAdmin): Checks if a player is logged into RCON. - [AllowPlayerTeleport](AllowPlayerTeleport): Toggle waypoint teleporting for players. diff --git a/docs/scripting/functions/AllowInteriorWeapons.md b/docs/scripting/functions/AllowInteriorWeapons.md index b7bbab990..de3d03251 100644 --- a/docs/scripting/functions/AllowInteriorWeapons.md +++ b/docs/scripting/functions/AllowInteriorWeapons.md @@ -37,6 +37,7 @@ This function does not work in the current SA:MP version! ## Related Functions +- [AreInteriorWeaponsAllowed](AreInteriorWeaponsAllowed): Can weapons be used in interiors? - [SetPlayerInterior](SetPlayerInterior): Set a player's interior. - [GetPlayerInterior](GetPlayerInterior): Get the current interior of a player. - [OnPlayerInteriorChange](../callbacks/OnPlayerInteriorChange): Called when a player changes interior. diff --git a/docs/scripting/functions/AllowNickNameCharacter.md b/docs/scripting/functions/AllowNickNameCharacter.md new file mode 100644 index 000000000..a5959e331 --- /dev/null +++ b/docs/scripting/functions/AllowNickNameCharacter.md @@ -0,0 +1,39 @@ +--- +title: AllowNickNameCharacter +description: Allows a character to be used in the nick name. +tags: [] +--- + + + +## Description + +Allows a character to be used in the nick name. + +| Name | Description | +| -------- | --------------------------------------- | +| character | The character to allow or disallow. | +| bool:allow | true-Allow, false-Disallow | + +## Returns + +This function does not return any specific values. + +## Examples + +```c +public OnGameModeInit() +{ + AllowNickNameCharacter('*', true); // Allow char * + AllowNickNameCharacter('[', false); // Disallow char [ + AllowNickNameCharacter(']', false); // Disallow char ] + + return 1; +} +``` + +## Related Functions + +- [IsValidNickName](IsValidNickName): Checks if a nick name is valid. +- [SetPlayerName](SetPlayerName): Sets the name of a player. +- [GetPlayerName](GetPlayerName): Gets the name of a player. diff --git a/docs/scripting/functions/ApplyAnimation.md b/docs/scripting/functions/ApplyAnimation.md index cc545b9a5..fa21c087f 100644 --- a/docs/scripting/functions/ApplyAnimation.md +++ b/docs/scripting/functions/ApplyAnimation.md @@ -11,13 +11,13 @@ Apply an animation to a player. | Name | Description | | ---------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | playerid | The ID of the player to apply the animation to. | -| animlib[] | The animation library from which to apply an animation. | +| animlib[] | The [animation library](../resources/animations) from which to apply an animation. | | animname[] | The name of the animation to apply, within the specified library. | | fDelta | The speed to play the animation (use 4.1). | -| loop | If set to 1, the animation will loop. If set to 0, the animation will play once. | -| lockx | If set to 0, the player is returned to their old X coordinate once the animation is complete (for animations that move the player such as walking). 1 will not return them to their old position. | +| loop | If set to 'true', the animation will loop. If set to 'false', the animation will play once. | +| lockx | If set to 'false', the player is returned to their old X coordinate once the animation is complete (for animations that move the player such as walking). 'true' will not return them to their old position. | | locky | Same as above but for the Y axis. Should be kept the same as the previous parameter. | -| freeze | Setting this to 1 will freeze the player at the end of the animation. 0 will not. | +| freeze | Setting this to 'true' will freeze the player at the end of the animation. 'false' will not. | | time | Timer in milliseconds. For a never-ending loop it should be 0. | | forcesync | Set to 1 to make server sync the animation with all other players in streaming radius (optional). 2 works same as 1, but will ONLY apply the animation to streamed-in players, but NOT the actual player being animated (useful for npc animations and persistent animations when players are being streamed) | @@ -28,7 +28,20 @@ This function always returns 1, even if the player specified does not exist, or ## Examples ```c -ApplyAnimation(playerid, "PED", "WALK_DRUNK", 4.1, 1, 1, 1, 1, 1, 1); +ApplyAnimation(playerid, "PED", "WALK_DRUNK", 4.1, true, true, true, true, 1, 1); +``` + +An example for open.mp: + +```c +ApplyAnimation(playerid, "PED", "WALK_DRUNK", 4.1, true, true, true, true, 1, SYNC_NONE); +// SYNC_NONE: Don't force sync to anyone else. + +ApplyAnimation(playerid, "PED", "WALK_DRUNK", 4.1, true, true, true, true, 1, SYNC_ALL); +// SYNC_ALL: Sync to all streamed-in players. + +ApplyAnimation(playerid, "PED", "WALK_DRUNK", 4.1, true, true, true, true, 1, SYNC_OTHER); +// SYNC_OTHER: Sync to all streamed-in players, except the player with the animation. ``` ## Notes @@ -50,3 +63,9 @@ An invalid animation library will crash the player's game. - [ClearAnimations](ClearAnimations): Clear any animations a player is performing. - [SetPlayerSpecialAction](SetPlayerSpecialAction): Set a player's special action. - [GetPlayerAnimFlags](GetPlayerAnimFlags): Get the player animation flags. +- [IsValidAnimationLibrary](IsValidAnimationLibrary): Checks if the given animation library is valid. +- [EnableAllAnimations](EnableAllAnimations): Allow use of the animations missing from some versions. + +## Related Resources + +- [Animations](../resources/animations) diff --git a/docs/scripting/functions/AreAllAnimationsEnabled.md b/docs/scripting/functions/AreAllAnimationsEnabled.md new file mode 100644 index 000000000..ef27f223c --- /dev/null +++ b/docs/scripting/functions/AreAllAnimationsEnabled.md @@ -0,0 +1,36 @@ +--- +title: AreAllAnimationsEnabled +description: Are the animations missing from some versions enabled? +tags: ["animation"] +--- + + + +## Description + +Are the animations missing from some versions enabled? + +## Returns + +true: Enable. + +false: False. + +## Examples + +```c +if (AreAllAnimationsEnabled()) +{ + // Do something +} +``` + +## Related Functions + +- [EnableAllAnimations](EnableAllAnimations): Allow use of the animations missing from some versions. +- [ApplyAnimation](ApplyAnimation): Apply an animation to a player. +- [ClearAnimations](ClearAnimations): Clear any animations a player is performing. + +## Related Resources + +- [Animations](../resources/animations) diff --git a/docs/scripting/functions/AreInteriorWeaponsAllowed.md b/docs/scripting/functions/AreInteriorWeaponsAllowed.md new file mode 100644 index 000000000..e77f77a40 --- /dev/null +++ b/docs/scripting/functions/AreInteriorWeaponsAllowed.md @@ -0,0 +1,30 @@ +--- +title: AreInteriorWeaponsAllowed +description: Can weapons be used in interiors? +tags: [] +--- + + + +## Description + +Can weapons be used in interiors? + +## Returns + +true: Allowed. + +false: Not allowed. + +## Examples + +```c +if (AreInteriorWeaponsAllowed()) +{ + // Do something +} +``` + +## Related Functions + +- [AllowInteriorWeapons](AllowInteriorWeapons): Toggle whether the usage of weapons in interiors is allowed or not. diff --git a/docs/scripting/functions/BlockIpAddress.md b/docs/scripting/functions/BlockIpAddress.md index 9f0f35240..284bc2fe1 100644 --- a/docs/scripting/functions/BlockIpAddress.md +++ b/docs/scripting/functions/BlockIpAddress.md @@ -43,4 +43,9 @@ Wildcards can be used with this function, for example blocking the IP '6.9._._' ## Related Functions - [UnBlockIpAddress](UnBlockIpAddress): Unblock an IP that was previously blocked. +- [IsBanned](IsBanned): Checks if the given IP address is banned. + +## Related Callbacks + +- [OnRconLoginAttempt](../callbacks/OnRconLoginAttempt): Called when someone attempts to log in to RCON in-game. - [OnIncomingConnection](../callbacks/OnIncomingConnection): Called when a player is attempting to connect to the server. diff --git a/docs/scripting/functions/ChatTextReplacementToggled.md b/docs/scripting/functions/ChatTextReplacementToggled.md new file mode 100644 index 000000000..a95f6852c --- /dev/null +++ b/docs/scripting/functions/ChatTextReplacementToggled.md @@ -0,0 +1,27 @@ +--- +title: ChatTextReplacementToggled +description: Checks if the chat input filtering is enabled or disabled. +tags: [] +--- + + + +## Description + +Checks if the chat input filtering is enabled or disabled. + +## Returns + +true: Enable. + +false: Disable. + +## Examples + +```c +printf("Chat input filter is %s", ChatTextReplacementToggled() ? "Enable" : "Disable"); +``` + +## Related Functions + +- [ToggleChatTextReplacement](ToggleChatTextReplacement): Toggles the chat input filter. diff --git a/docs/scripting/functions/ClearBanList.md b/docs/scripting/functions/ClearBanList.md new file mode 100644 index 000000000..6aa170fcf --- /dev/null +++ b/docs/scripting/functions/ClearBanList.md @@ -0,0 +1,54 @@ +--- +title: ClearBanList +description: Clears the ban list. +tags: [] +--- + + + +## Description + +Clears the ban list. + +## Returns + +false: Failed to execute the function. + +true: Success. + +## Examples + +```c +public OnPlayerCommandText(playerid, cmdtext[]) +{ + if (!strcmp(cmdtext, "/clearbanlist", true)) + { + if (!IsPlayerAdmin(playerid)) + { + return 1; + } + + ClearBanList(); + SendClientMessage(playerid, -1, "[SERVER]: Ban list cleared."); + return 1; + } + return 0; +} +``` + +## Notes + +:::tip + +You can see the ban list in the bans.json file. + +::: + +## Related Functions + +- [BlockIpAddress](BlockIpAddress): Block an IP address from connecting to the server for a set amount of time. +- [UnBlockIpAddress](UnBlockIpAddress): Unblock an IP that was previously blocked. +- [Ban](Ban): Ban a player from playing on the server. +- [BanEx](BanEx): Ban a player with a custom reason. +- [Kick](Kick): Kick a player from the server. +- [IsBanned](IsBanned): Checks if the given IP address is banned. diff --git a/docs/scripting/functions/CountRunningTimers.md b/docs/scripting/functions/CountRunningTimers.md new file mode 100644 index 000000000..8da27fd66 --- /dev/null +++ b/docs/scripting/functions/CountRunningTimers.md @@ -0,0 +1,27 @@ +--- +title: CountRunningTimers +description: Get the running timers. +tags: [] +--- + + + +## Description + +Get the running timers. ([SetTimer](SetTimer) & [SetTimerEx](SetTimerEx)) + +## Returns + +Returns the amount of running timers. + +## Examples + +```c +printf("Running timers: %d", CountRunningTimers()); +``` + +## Related Functions + +- [SetTimer](SetTimer): Set a timer. +- [SetTimerEx](SetTimerEx): Set a timer with parameters. +- [KillTimer](KillTimer): Kills (stops) a running timer. diff --git a/docs/scripting/functions/EnableAllAnimations.md b/docs/scripting/functions/EnableAllAnimations.md new file mode 100644 index 000000000..ea3be97d9 --- /dev/null +++ b/docs/scripting/functions/EnableAllAnimations.md @@ -0,0 +1,53 @@ +--- +title: EnableAllAnimations +description: Allow use of the animations missing from some versions. +tags: ["animation"] +--- + + + +## Description + +Allow use of the animations missing from some versions. + +| Name | Description | +| ------ | ----------------------------------------------- | +| bool:enable | 'true' to enable missing animations or 'false' to disable them. | + +## Returns + +This function does not return any specific values. + +## Examples + +```c +public OnGameModeInit() +{ + EnableAllAnimations(true); + return 1; +} +``` + +## Notes + +:::tip + +You can also enable or disable missing animations from the config.json file. + +```json +"game": { + "use_all_animations": false, +}, +``` + +::: + +## Related Functions + +- [AreAllAnimationsEnabled](AreAllAnimationsEnabled): Are the animations missing from some versions enabled? +- [ApplyAnimation](ApplyAnimation): Apply an animation to a player. +- [ClearAnimations](ClearAnimations): Clear any animations a player is performing. + +## Related Resources + +- [Animations](../resources/animations) diff --git a/docs/scripting/functions/GameTextForAll.md b/docs/scripting/functions/GameTextForAll.md index 0af7e441c..d7240d9ab 100644 --- a/docs/scripting/functions/GameTextForAll.md +++ b/docs/scripting/functions/GameTextForAll.md @@ -47,5 +47,7 @@ Do note that the players may crash because of odd number of tilde (~) symbols us ## Related Functions +- [HideGameTextForAll](HideGameTextForAll): Stop showing a gametext style for all players. - [GameTextForPlayer](GameTextForPlayer): Display gametext to a player. +- [HideGameTextForPlayer](HideGameTextForPlayer): Stop showing a gametext style to a player. - [TextDrawShowForAll](TextDrawShowForAll): Show a textdraw for all players. diff --git a/docs/scripting/functions/GameTextForPlayer.md b/docs/scripting/functions/GameTextForPlayer.md index 3a4f24842..92a450798 100644 --- a/docs/scripting/functions/GameTextForPlayer.md +++ b/docs/scripting/functions/GameTextForPlayer.md @@ -43,5 +43,7 @@ Also, a blank space at end of the string may result in faliure. For example: `"H ## Related Functions +- [HideGameTextForPlayer](HideGameTextForPlayer): Stop showing a gametext style to a player. - [GameTextForAll](GameTextForAll): Display gametext to all players. +- [HideGameTextForAll](HideGameTextForAll): Stop showing a gametext style for all players. - [TextDrawShowForAll](TextDrawShowForAll): Show a textdraw for all players. diff --git a/docs/scripting/functions/GetActors.md b/docs/scripting/functions/GetActors.md new file mode 100644 index 000000000..586a398a2 --- /dev/null +++ b/docs/scripting/functions/GetActors.md @@ -0,0 +1,30 @@ +--- +title: GetActors +description: Gets an array variable of the IDs of the created actors on the server. +tags: ["actor"] +--- + + + +## Description + +Gets an array variable of the IDs of the created actors on the server. + +| Name | Description | +| ------------- | ------------------------------------------------------------------ | +| actors[] | An array into which to store the actor IDs, passed by reference. | +| size | The size of the array. | + +## Examples + +```c +new actors[MAX_ACTORS]; + +GetActors(actors, sizeof(actors)); +// The `actors` array now contains created actor IDs. { 0, 1, 2, 3, 4, ... } +``` + +## Related Functions + +- [GetPlayers](GetPlayers): Gets an array variable of the IDs of the current players on the server. +- [GetVehicles](GetVehicles): Gets an array variable of the IDs of the created vehicles on the server. diff --git a/docs/scripting/functions/GetPlayerName.md b/docs/scripting/functions/GetPlayerName.md index 11f519150..0bf04167c 100644 --- a/docs/scripting/functions/GetPlayerName.md +++ b/docs/scripting/functions/GetPlayerName.md @@ -47,6 +47,7 @@ A player's name can be up to 24 characters long (as of 0.3d R2) by using SetPlay ## Related Functions - [SetPlayerName](SetPlayerName): Set a player's name. +- [IsValidNickName](IsValidNickName): Checks if a nick name is valid. - [GetPlayerIp](GetPlayerIp): Get a player's IP. - [GetPlayerPing](GetPlayerPing): Get the ping of a player. - [GetPlayerScore](GetPlayerScore): Get the score of a player. diff --git a/docs/scripting/functions/GetPlayerWeather.md b/docs/scripting/functions/GetPlayerWeather.md new file mode 100644 index 000000000..fdbb60dd8 --- /dev/null +++ b/docs/scripting/functions/GetPlayerWeather.md @@ -0,0 +1,33 @@ +--- +title: GetPlayerWeather +description: Get a player's weather. +tags: ["player"] +--- + + + +## Description + +Get a player's weather. + +| Name | Description | +| -------- | ---------------------------------------- | +| playerid | The ID of the player to get the weather of. | + +## Returns + +Returns the player's weather. + +## Examples + +```c +SetPlayerWeather(playerid, 8); + +printf("Player weather: %d", GetPlayerWeather(playerid)); +// The output will be 'Player weather: 8' +``` + +## Related Functions + +- [SetPlayerWeather](SetPlayerWeather): Set a player's weather. +- [SetWeather](SetWeather): Set the world weather for all players. \ No newline at end of file diff --git a/docs/scripting/functions/GetPlayers.md b/docs/scripting/functions/GetPlayers.md new file mode 100644 index 000000000..6242eeec0 --- /dev/null +++ b/docs/scripting/functions/GetPlayers.md @@ -0,0 +1,30 @@ +--- +title: GetPlayers +description: Gets an array variable of the IDs of the current players on the server. +tags: ["player"] +--- + + + +## Description + +Gets an array variable of the IDs of the current players on the server. + +| Name | Description | +| ------------- | ----------------------------------------------------------------- | +| players[] | An array into which to store the player IDs, passed by reference. | +| size | The size of the array. | + +## Examples + +```c +new players[MAX_PLAYERS]; + +GetPlayers(players, sizeof(players)); +// The `players` array now contains online player IDs. { 0, 1, 2, 3, 4, ... } +``` + +## Related Functions + +- [GetVehicles](GetVehicles): Gets an array variable of the IDs of the created vehicles on the server. +- [GetActors](GetActors): Gets an array variable of the IDs of the created actors on the server. diff --git a/docs/scripting/functions/GetRunningTimers.md b/docs/scripting/functions/GetRunningTimers.md new file mode 100644 index 000000000..6957e77d8 --- /dev/null +++ b/docs/scripting/functions/GetRunningTimers.md @@ -0,0 +1,31 @@ +--- +title: GetRunningTimers +description: Get the running timers. +tags: [] +--- + +:::warning + +This function is deprecated, see [CountRunningTimers](CountRunningTimers). + +::: + +## Description + +Get the running timers. ([SetTimer](SetTimer) & [SetTimerEx](SetTimerEx)) + +## Returns + +Returns the amount of running timers. + +## Examples + +```c +printf("Running timers: %d", GetRunningTimers()); +``` + +## Related Functions + +- [SetTimer](SetTimer): Set a timer. +- [SetTimerEx](SetTimerEx): Set a timer with parameters. +- [KillTimer](KillTimer): Kills (stops) a running timer. diff --git a/docs/scripting/functions/GetVehicles.md b/docs/scripting/functions/GetVehicles.md new file mode 100644 index 000000000..787d525fb --- /dev/null +++ b/docs/scripting/functions/GetVehicles.md @@ -0,0 +1,30 @@ +--- +title: GetVehicles +description: Gets an array variable of the IDs of the created vehicles on the server. +tags: ["vehicle"] +--- + + + +## Description + +Gets an array variable of the IDs of the created vehicles on the server. + +| Name | Description | +| ------------- | ------------------------------------------------------------------ | +| vehicles[] | An array into which to store the vehicle IDs, passed by reference. | +| size | The size of the array. | + +## Examples + +```c +new vehicles[MAX_VEHICLES]; + +GetVehicles(vehicles, sizeof(vehicles)); +// The `vehicles` array now contains created vehicle IDs. { 0, 1, 2, 3, 4, ... } +``` + +## Related Functions + +- [GetPlayers](GetPlayers): Gets an array variable of the IDs of the current players on the server. +- [GetActors](GetActors): Gets an array variable of the IDs of the created actors on the server. diff --git a/docs/scripting/functions/GetWeather.md b/docs/scripting/functions/GetWeather.md new file mode 100644 index 000000000..e55d185b8 --- /dev/null +++ b/docs/scripting/functions/GetWeather.md @@ -0,0 +1,26 @@ +--- +title: GetWeather +description: Get the current world weather. +tags: [] +--- + + + +## Description + +Get the current world weather. + +## Examples + +```c +SetWeather(19); + +printf("Current world weather: %d", GetWeather()); +// The output will be 'Current world weather: 19' +``` + +## Related Functions + +- [SetWeather](SetWeather): Set the world weather for all players. +- [GetPlayerWeather](GetPlayerWeather): Get a player's weather. +- [SetPlayerWeather](SetPlayerWeather): Set a player's weather. \ No newline at end of file diff --git a/docs/scripting/functions/GetWorldTime.md b/docs/scripting/functions/GetWorldTime.md new file mode 100644 index 000000000..25c3d41be --- /dev/null +++ b/docs/scripting/functions/GetWorldTime.md @@ -0,0 +1,25 @@ +--- +title: GetWorldTime +description: Get the current world time. +tags: [] +--- + + + +## Description + +Get the current world time. + +## Examples + +```c +SetWorldTime(12); + +printf("Current world time: %d", GetWorldTime()); +// The output will be 'Current world time: 12' +``` + +## Related Functions + +- [SetWorldTime](SetWorldTime): Sets the world time (for all players) to a specific hour. +- [SetPlayerTime](SetPlayerTime): Set a player's time. \ No newline at end of file diff --git a/docs/scripting/functions/HideGameTextForAll.md b/docs/scripting/functions/HideGameTextForAll.md new file mode 100644 index 000000000..c3bea4612 --- /dev/null +++ b/docs/scripting/functions/HideGameTextForAll.md @@ -0,0 +1,45 @@ +--- +title: HideGameTextForAll +description: Stop showing a gametext style for all players. +tags: ["player"] +--- + + + +## Description + +Stop showing a gametext style for all players. + +| Name | Description | +| -------------- | ----------------------------------------------------------------- | +| style | The [style](../resources/gametextstyles) of text to hide. | + +## Returns + +This function does not return any specific value. + +## Examples + +```c +public OnPlayerCommandText(playerid, cmdtext[]) +{ + if (!strcmp(cmdtext, "/hidegametext3", true)) + { + if (!IsPlayerAdmin(playerid)) + { + return 1; + } + + HideGameTextForAll(3); + return 1; + } + return 0; +} +``` + +## Related Functions + +- [HideGameTextForPlayer](HideGameTextForPlayer): Stop showing a gametext style to a player. +- [GameTextForPlayer](GameTextForPlayer): Display gametext to a player. +- [GameTextForAll](GameTextForAll): Display gametext to all players. +- [TextDrawHideForAll](TextDrawHideForAll): Hide a textdraw for all players. diff --git a/docs/scripting/functions/HideGameTextForPlayer.md b/docs/scripting/functions/HideGameTextForPlayer.md new file mode 100644 index 000000000..bc7816626 --- /dev/null +++ b/docs/scripting/functions/HideGameTextForPlayer.md @@ -0,0 +1,37 @@ +--- +title: HideGameTextForPlayer +description: Stop showing a gametext style to a player. +tags: ["player"] +--- + + + +## Description + +Stop showing a gametext style to a player. + +| Name | Description | +| -------------- | ----------------------------------------------------------------- | +| playerid | The ID of the player to hide the gametext for. | +| style | The [style](../resources/gametextstyles) of text to hide. | + +## Returns + +This function does not return any specific value. + +## Examples + +```c +public OnPlayerDeath(playerid, killerid, reason) +{ + HideGameTextForPlayer(playerid, 3); + return 1; +} +``` + +## Related Functions + +- [HideGameTextForAll](HideGameTextForAll): Stop showing a gametext style for all players. +- [GameTextForPlayer](GameTextForPlayer): Display gametext to a player. +- [GameTextForAll](GameTextForAll): Display gametext to all players. +- [TextDrawHideForAll](TextDrawHideForAll): Hide a textdraw for all players. diff --git a/docs/scripting/functions/IsAdminTeleportAllowed.md b/docs/scripting/functions/IsAdminTeleportAllowed.md new file mode 100644 index 000000000..6227bf1de --- /dev/null +++ b/docs/scripting/functions/IsAdminTeleportAllowed.md @@ -0,0 +1,32 @@ +--- +title: IsAdminTeleportAllowed +description: Checks if the RCON admins allowed to teleport by right-clicking on the map. +tags: [] +--- + + + +## Description + +Checks if the RCON admins allowed to teleport by right-clicking on the map. + +## Returns + +true: Allowed. + +false: Not allowed. + +## Examples + +```c +if (IsAdminTeleportAllowed()) +{ + // Do something +} +``` + +## Related Functions + +- [AllowAdminTeleport](AllowAdminTeleport): Determine whether RCON admins will be teleported to their waypoint when they set one. +- [AllowPlayerTeleport](AllowPlayerTeleport): Toggle waypoint teleporting for players. +- [IsPlayerAdmin](IsPlayerAdmin): Checks if a player is logged into RCON. diff --git a/docs/scripting/functions/IsBanned.md b/docs/scripting/functions/IsBanned.md new file mode 100644 index 000000000..3a1e2174f --- /dev/null +++ b/docs/scripting/functions/IsBanned.md @@ -0,0 +1,45 @@ +--- +title: IsBanned +description: Checks if the given IP address is banned. +tags: [] +--- + + + +## Description + +Checks if the given IP address is banned. + +| Name | Description | +| ----------------- | ------------------------ | +| const ipaddress[] | The IP address to check. | + +## Returns + +Returns true if the IP address is banned, otherwise false. + +## Examples + +```c +if (IsBanned("255.255.255.255")) +{ + // Do something +} +``` + +## Notes + +:::tip + +You can see the ban list in the bans.json file. + +::: + +## Related Functions + +- [BlockIpAddress](BlockIpAddress): Block an IP address from connecting to the server for a set amount of time. +- [UnBlockIpAddress](UnBlockIpAddress): Unblock an IP that was previously blocked. +- [Ban](Ban): Ban a player from playing on the server. +- [BanEx](BanEx): Ban a player with a custom reason. +- [Kick](Kick): Kick a player from the server. +- [ClearBanList](ClearBanList): Clears the ban list. diff --git a/docs/scripting/functions/IsValidAnimationLibrary.md b/docs/scripting/functions/IsValidAnimationLibrary.md new file mode 100644 index 000000000..dbad93dfd --- /dev/null +++ b/docs/scripting/functions/IsValidAnimationLibrary.md @@ -0,0 +1,40 @@ +--- +title: IsValidAnimationLibrary +description: Checks if the given animation library is valid. +tags: ["animation"] +--- + + + +## Description + +Checks if the given animation library is valid. + +| Name | Description | +| ------------ | ----------------------------------------------------------- | +| const name[] | The animation library name to check. | + +## Returns + +Returns true if the animation library is valid, otherwise false. + +## Examples + +```c +if (IsValidAnimationLibrary("PED")) +{ + // Animation library is valid +} +else +{ + // Animation library is not valid +} +``` + +## Related Functions + +- [ApplyAnimation](ApplyAnimation): Apply an animation to a player. + +## Related Resources + +- [Animations](../resources/animations) diff --git a/docs/scripting/functions/IsValidNickName.md b/docs/scripting/functions/IsValidNickName.md new file mode 100644 index 000000000..3e88be64f --- /dev/null +++ b/docs/scripting/functions/IsValidNickName.md @@ -0,0 +1,46 @@ +--- +title: IsValidNickName +description: Checks if a nick name is valid. +tags: [] +--- + + + +## Description + +Checks if a nick name is valid. + +| Name | Description | +| ------------ | ----------------------------------------------------------- | +| const name[] | The nick name to check. | + +## Returns + +Returns true if the nick name is valid, otherwise false. + +## Examples + +```c +if (IsValidNickName("Barnaby_Keene")) +{ + // Do something +} +else +{ + SendClientMessage(playerid, 0xFF0000FF, "Your nick name is not valid."); +} +``` + +## Notes + +:::tip + +By default the valid characters in the nick name is (0-9, a-z, A-Z, [], (), \$ @ . \_ and = only). + +::: + +## Related Functions + +- [AllowNickNameCharacter](AllowNickNameCharacter): Allows a character to be used in the nick name. +- [SetPlayerName](SetPlayerName): Sets the name of a player. +- [GetPlayerName](GetPlayerName): Gets the name of a player. diff --git a/docs/scripting/functions/IsValidServerRule.md b/docs/scripting/functions/IsValidServerRule.md new file mode 100644 index 000000000..3918199ea --- /dev/null +++ b/docs/scripting/functions/IsValidServerRule.md @@ -0,0 +1,37 @@ +--- +title: IsValidServerRule +description: Checks if the given server rule is valid. +tags: ["rule"] +--- + + + +## Description + +Checks if the given server rule is valid. + +| Name | Description | +| ------------ | ----------------------------------------------------------- | +| const rule[] | The server rule name to check. | + +## Returns + +Returns true if the server rule is valid, otherwise false. + +## Examples + +```c +if (IsValidServerRule("version")) +{ + // Server rule is valid +} +else +{ + // Server rule is not valid +} +``` + +## Related Functions + +- [AddServerRule](AddServerRule): Add a server rule. +- [RemoveServerRule](RemoveServerRule): Remove the server rule. diff --git a/docs/scripting/functions/KillTimer.md b/docs/scripting/functions/KillTimer.md index 02835d15e..5eb567503 100644 --- a/docs/scripting/functions/KillTimer.md +++ b/docs/scripting/functions/KillTimer.md @@ -47,3 +47,4 @@ public WelcomeTimer(playerid) - [SetTimer](SetTimer): Set a timer. - [SetTimerEx](SetTimerEx): Set a timer with parameters. +- [CountRunningTimers](CountRunningTimers): Get the running timers. diff --git a/docs/scripting/functions/RemoveServerRule.md b/docs/scripting/functions/RemoveServerRule.md new file mode 100644 index 000000000..4399e158a --- /dev/null +++ b/docs/scripting/functions/RemoveServerRule.md @@ -0,0 +1,30 @@ +--- +title: RemoveServerRule +description: Remove the server rule. +tags: ["rule"] +--- + + + +## Description + +Remove the server rule. + +| Name | Description | +| ----------------- | ----------------------------------------------------------- | +| const rule[] | The server rule name to remove. | + +## Returns + +Returns true if the function executed successfully, otherwise false. + +## Examples + +```c +RemoveServerRule("rule"); +``` + +## Related Functions + +- [AddServerRule](AddServerRule): Add a server rule. +- [IsValidServerRule](IsValidServerRule): Checks if the given server rule is valid. diff --git a/docs/scripting/functions/SetPlayerName.md b/docs/scripting/functions/SetPlayerName.md index 7c5c96375..3a4773d53 100644 --- a/docs/scripting/functions/SetPlayerName.md +++ b/docs/scripting/functions/SetPlayerName.md @@ -65,3 +65,5 @@ Changing the players' name to the same name but with different character cases ( ## Related Functions - [GetPlayerName](GetPlayerName): Get a player's name. +- [IsValidNickName](IsValidNickName): Checks if a nick name is valid. +- [AllowNickNameCharacter](AllowNickNameCharacter): Allows a character to be used in the nick name. diff --git a/docs/scripting/functions/SetPlayerWeather.md b/docs/scripting/functions/SetPlayerWeather.md index 4fd97b674..b4fed3446 100644 --- a/docs/scripting/functions/SetPlayerWeather.md +++ b/docs/scripting/functions/SetPlayerWeather.md @@ -41,5 +41,6 @@ If TogglePlayerClock is enabled, weather will slowly change over time, instead o ## Related Functions +- [GetPlayerWeather](GetPlayerWeather): Get a player's weather. - [SetWeather](SetWeather): Set the global weather. - [SetGravity](SetGravity): Set the global gravity. diff --git a/docs/scripting/functions/SetTimer.md b/docs/scripting/functions/SetTimer.md index 98e52c4a8..b16afb3a5 100644 --- a/docs/scripting/functions/SetTimer.md +++ b/docs/scripting/functions/SetTimer.md @@ -47,3 +47,4 @@ Timer intervals are not accurate (roughly 25% off). There are fixes available he - [SetTimerEx](SetTimerEx): Set a timer with parameters. - [KillTimer](KillTimer): Stop a timer. +- [CountRunningTimers](CountRunningTimers): Get the running timers. diff --git a/docs/scripting/functions/SetTimerEx.md b/docs/scripting/functions/SetTimerEx.md index f6bc3c461..dcc5aef6e 100644 --- a/docs/scripting/functions/SetTimerEx.md +++ b/docs/scripting/functions/SetTimerEx.md @@ -74,5 +74,6 @@ The function to be called must be public. That means it has to be forwarded. - [SetTimer](SetTimer): Set a timer. - [KillTimer](KillTimer): Stop a timer. +- [CountRunningTimers](CountRunningTimers): Get the running timers. - [CallLocalFunction](CallLocalFunction): Call a function in the script. - [CallRemoteFunction](CallRemoteFunction): Call a function in any loaded script. diff --git a/docs/scripting/functions/SetWeather.md b/docs/scripting/functions/SetWeather.md index 53a4eacad..922749799 100644 --- a/docs/scripting/functions/SetWeather.md +++ b/docs/scripting/functions/SetWeather.md @@ -36,5 +36,6 @@ If TogglePlayerClock is enabled, weather will slowly change over time, instead o ## Related Functions +- [GetWeather](GetWeather): Get the current world weather. - [SetPlayerWeather](SetPlayerWeather): Set a player's weather. - [SetGravity](SetGravity): Set the global gravity. diff --git a/docs/scripting/functions/SetWorldTime.md b/docs/scripting/functions/SetWorldTime.md index 98255bf9c..da016ab97 100644 --- a/docs/scripting/functions/SetWorldTime.md +++ b/docs/scripting/functions/SetWorldTime.md @@ -39,6 +39,7 @@ To set the minutes and/or to set the time for individual players, see SetPlayerT ## Related Functions +- [GetWorldTime](GetWorldTime): Get the current world time. - [SetPlayerTime](SetPlayerTime): Set a player's time. - [SetWeather](SetWeather): Set the global weather. - [SetGravity](SetGravity): Set the global gravity. diff --git a/docs/scripting/functions/ToggleChatTextReplacement.md b/docs/scripting/functions/ToggleChatTextReplacement.md new file mode 100644 index 000000000..764128f3c --- /dev/null +++ b/docs/scripting/functions/ToggleChatTextReplacement.md @@ -0,0 +1,47 @@ +--- +title: ToggleChatTextReplacement +description: Toggles the chat input filter. +tags: [] +--- + + + +## Description + +Toggles the chat input filter. + +Disable it to use of chars like % in the chat. + +| Name | Description | +| ----------- | --------------------------------------------------------------------- | +| bool:enable | 'true' to enable or 'false' to disable the chat input filter. | + +## Returns + +This function does not return any specific value. + +## Examples + +```c +public OnGameModeInit() +{ + ToggleChatTextReplacement(false); + return 1; +} +``` + +## Notes + +:::tip + +You can also toggle the chat input filter in the config.json file. + +```json +"chat_input_filter": true, +``` + +::: + +## Related Functions + +- [ChatTextReplacementToggled](ChatTextReplacementToggled): Checks if the chat input filtering is enabled or disabled. diff --git a/docs/scripting/functions/UnBlockIpAddress.md b/docs/scripting/functions/UnBlockIpAddress.md index b1b8678a8..62c08a81f 100644 --- a/docs/scripting/functions/UnBlockIpAddress.md +++ b/docs/scripting/functions/UnBlockIpAddress.md @@ -31,4 +31,8 @@ public OnGameModeInit() ## Related Functions - [BlockIpAddress](BlockIpAddress): Block an IP address from connecting to the server for a set amount of time. +- [IsBanned](IsBanned): Checks if the given IP address is banned. + +## Related Callbacks + - [OnIncomingConnection](../callbacks/OnIncomingConnection): Called when a player is attempting to connect to the server.