Skip to content

Commit

Permalink
Added more core scripting functions documents. (#794)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
adib-yg authored Dec 16, 2023
1 parent 4753b8f commit b8d3c13
Show file tree
Hide file tree
Showing 40 changed files with 915 additions and 5 deletions.
1 change: 1 addition & 0 deletions docs/scripting/callbacks/OnPlayerText.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
36 changes: 36 additions & 0 deletions docs/scripting/functions/AddServerRule.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
---
title: AddServerRule
description: Add a server rule.
tags: ["rule"]
---

<VersionWarn version='omp v1.1.0.2612' />

## 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.
1 change: 1 addition & 0 deletions docs/scripting/functions/AllowAdminTeleport.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
1 change: 1 addition & 0 deletions docs/scripting/functions/AllowInteriorWeapons.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
39 changes: 39 additions & 0 deletions docs/scripting/functions/AllowNickNameCharacter.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
---
title: AllowNickNameCharacter
description: Allows a character to be used in the nick name.
tags: []
---

<VersionWarn version='omp v1.1.0.2612' />

## 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.
29 changes: 24 additions & 5 deletions docs/scripting/functions/ApplyAnimation.md
Original file line number Diff line number Diff line change
Expand Up @@ -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) |

Expand All @@ -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
Expand All @@ -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)
36 changes: 36 additions & 0 deletions docs/scripting/functions/AreAllAnimationsEnabled.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
---
title: AreAllAnimationsEnabled
description: Are the animations missing from some versions enabled?
tags: ["animation"]
---

<VersionWarn version='omp v1.1.0.2612' />

## 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)
30 changes: 30 additions & 0 deletions docs/scripting/functions/AreInteriorWeaponsAllowed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
---
title: AreInteriorWeaponsAllowed
description: Can weapons be used in interiors?
tags: []
---

<VersionWarn version='omp v1.1.0.2612' />

## 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.
5 changes: 5 additions & 0 deletions docs/scripting/functions/BlockIpAddress.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
27 changes: 27 additions & 0 deletions docs/scripting/functions/ChatTextReplacementToggled.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
---
title: ChatTextReplacementToggled
description: Checks if the chat input filtering is enabled or disabled.
tags: []
---

<VersionWarn version='omp v1.1.0.2612' />

## 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.
54 changes: 54 additions & 0 deletions docs/scripting/functions/ClearBanList.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
---
title: ClearBanList
description: Clears the ban list.
tags: []
---

<VersionWarn version='omp v1.1.0.2612' />

## 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.
27 changes: 27 additions & 0 deletions docs/scripting/functions/CountRunningTimers.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
---
title: CountRunningTimers
description: Get the running timers.
tags: []
---

<VersionWarn version='omp v1.1.0.2612' />

## 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.
53 changes: 53 additions & 0 deletions docs/scripting/functions/EnableAllAnimations.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
---
title: EnableAllAnimations
description: Allow use of the animations missing from some versions.
tags: ["animation"]
---

<VersionWarn version='omp v1.1.0.2612' />

## 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)
2 changes: 2 additions & 0 deletions docs/scripting/functions/GameTextForAll.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Loading

0 comments on commit b8d3c13

Please sign in to comment.