Skip to content

Commit

Permalink
Added more scripting functions documents (#805)
Browse files Browse the repository at this point in the history
* add SetModeRestartTime.md

* add GetModeRestartTime.md

* add SetServerRule.md

* add SetServerRuleFlags.md

* add GetServerRuleFlags.md

* update GameModeExit.md

* add ChangeVehicleColours.md

* add GetPlayerHydraReactorAngle.md

* add GetPlayerLandingGearState.md

* add GetPlayerLastSyncedTrailerID.md

* add GetPlayerLastSyncedVehicleID.md

* add GetPlayerSirenState.md

* add GetPlayerTrainSpeed.md

* add GetRandomVehicleColourPair.md

* add GetVehicleCab.md

* add GetVehicleTower.md

* add GetVehicleColours.md

* add GetVehicleHydraReactorAngle.md

* add GetVehicleInterior.md

* add GetVehicleLandingGearState.md

* add GetVehicleLastDriver.md

* add GetVehicleMatrix.md

* add GetVehicleModelCount.md

* add GetVehicleModelsUsed.md

* add GetVehicleNumberPlate.md

* add GetVehicleOccupiedTick.md

* add GetVehiclePaintjob.md

* add GetVehicleRespawnDelay.md

* add GetVehicleRespawnTick.md

* add GetVehicleSirenState.md

* add GetVehicleSpawnInfo.md

* add GetVehicleTrainSpeed.md

* add HasVehicleBeenOccupied.md

* add IsVehicleOccupied.md

* add HideVehicle.md

* add ShowVehicle.md

* add IsVehicleHidden.md

* add IsPlayerInModShop.md

* add SetVehicleDead.md

* add IsVehicleDead.md

* add IsVehicleSirenEnabled.md

* add SetVehicleBeenOccupied.md

* add SetVehicleOccupiedTick.md

* add SetVehicleParamsSirenState.md

* add SetVehicleRespawnDelay.md

* add SetVehicleRespawnTick.md

* add SetVehicleSpawnInfo.md

* add ToggleVehicleSirenEnabled.md

* add VehicleColourIndexToColour.md

* add resources/landinggearstate.md

* update callbacks/OnEnterExitModShop.md

* update AddStaticVehicle.md

* update AddStaticVehicleEx.md

* update ChangeVehicleColor.md

* update ChangeVehiclePaintjob.md

* update CreateVehicle.md

* update GetVehicleDriver.md

* update GetVehicleRotationQuat.md

* update GetVehicleZAngle.md

* update LinkVehicleToInterior.md

* update SetVehicleNumberPlate.md

* update AddStaticVehicle.md

* update GetVehicleParamsSirenState.md

* update SetVehicleParamsSirenState.md

* update AddStaticVehicleEx.md

* update resources/landinggearstate.md

* update GetVehicleModelCount.md

* fix #649

#649
  • Loading branch information
adib-yg authored Jan 4, 2024
1 parent fb645c7 commit 55a5dde
Show file tree
Hide file tree
Showing 62 changed files with 1,920 additions and 20 deletions.
3 changes: 2 additions & 1 deletion docs/scripting/callbacks/OnEnterExitModShop.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
title: OnEnterExitModShop
description: This callback is called when a player enters or exits a mod shop.
tags: []
tags: ["player"]
---

<VersionWarn name='callback' version='SA-MP 0.3a' />
Expand Down Expand Up @@ -54,4 +54,5 @@ The following callbacks might be useful, as they're related to this callback in
The following functions might be useful, as they're related to this callback in one way or another.
- [IsPlayerInModShop](../functions/IsPlayerInModShop): Check if the player is in the mod shop.
- [AddVehicleComponent](../functions/AddVehicleComponent): Add a component to a vehicle.
12 changes: 12 additions & 0 deletions docs/scripting/functions/AddStaticVehicle.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,15 @@ public OnGameModeInit()
- [AddStaticVehicleEx](AddStaticVehicleEx): Add a static vehicle with custom respawn time.
- [CreateVehicle](CreateVehicle): Create a vehicle.
- [DestroyVehicle](DestroyVehicle): Destroy a vehicle.
- [GetVehicleParamsSirenState](GetVehicleParamsSirenState): Check whether a vehicle's siren is on or off.
- [SetVehicleSpawnInfo](SetVehicleSpawnInfo): Adjusts vehicle model, spawn location, colours, respawn delay and interior.
- [GetVehicleSpawnInfo](GetVehicleSpawnInfo): Gets the vehicle spawn location and colours.
- [ChangeVehicleColours](ChangeVehicleColours): Change a vehicle's primary and secondary colors.
- [GetVehicleColours](GetVehicleColours): Gets the vehicle colours.
- [SetVehicleRespawnDelay](SetVehicleRespawnDelay): Set the respawn delay of a vehicle.
- [GetVehicleRespawnDelay](GetVehicleRespawnDelay): Get the respawn delay of a vehicle.

## Related Callbacks

- [OnVehicleSpawn](../callbacks/OnVehicleSpawn): Called when a vehicle respawns.
- [OnVehicleSirenStateChange](../callbacks/OnVehicleSirenStateChange): Called when a vehicle's siren is toggled on/off.
13 changes: 13 additions & 0 deletions docs/scripting/functions/AddStaticVehicleEx.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,16 @@ public OnGameModeInit()

- [AddStaticVehicle](AddStaticVehicle): Add a static vehicle.
- [CreateVehicle](CreateVehicle): Create a vehicle.
- [DestroyVehicle](DestroyVehicle): Destroy a vehicle.
- [GetVehicleParamsSirenState](GetVehicleParamsSirenState): Check whether a vehicle's siren is on or off.
- [SetVehicleSpawnInfo](SetVehicleSpawnInfo): Adjusts vehicle model, spawn location, colours, respawn delay and interior.
- [GetVehicleSpawnInfo](GetVehicleSpawnInfo): Gets the vehicle spawn location and colours.
- [ChangeVehicleColours](ChangeVehicleColours): Change a vehicle's primary and secondary colors.
- [GetVehicleColours](GetVehicleColours): Gets the vehicle colours.
- [SetVehicleRespawnDelay](SetVehicleRespawnDelay): Set the respawn delay of a vehicle.
- [GetVehicleRespawnDelay](GetVehicleRespawnDelay): Get the respawn delay of a vehicle.

## Related Callbacks

- [OnVehicleSpawn](../callbacks/OnVehicleSpawn): Called when a vehicle respawns.
- [OnVehicleSirenStateChange](../callbacks/OnVehicleSirenStateChange): Called when a vehicle's siren is toggled on/off.
4 changes: 4 additions & 0 deletions docs/scripting/functions/ChangeVehicleColor.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,5 +74,9 @@ Some vehicles have only a primary color and some can not have the color changed

## Related Functions

- [GetVehicleColours](GetVehicleColours): Gets the vehicle colours.
- [ChangeVehiclePaintjob](ChangeVehiclePaintjob): Change the paintjob on a vehicle.

## Related Callbacks

- [OnVehicleRespray](../callbacks/OnVehicleRespray): Called when a vehicle is resprayed.
84 changes: 84 additions & 0 deletions docs/scripting/functions/ChangeVehicleColours.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
---
title: ChangeVehicleColours
description: Change a vehicle's primary and secondary colors.
tags: ["vehicle"]
---

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

## Description

Change a vehicle's primary and secondary colors.

| Name | Description |
| --------- | ---------------------------------------------- |
| vehicleid | The ID of the vehicle to change the colors of. |
| color1 | The new vehicle's primary Color ID. |
| color2 | The new vehicle's secondary Color ID. |

## Returns

1: The function executed successfully. The vehicle's color was successfully changed.

0: The function failed to execute. The vehicle does not exist.

## Examples

```c
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
// Change the primary color to black and the secondary color to white
ChangeVehicleColours(vehicleid, 0, 1);
return 1;
}
```
## Snippets
```c
new VehicleColoursTableRGBA[256] = {
// The existing colours from San Andreas
0x000000FF, 0xF5F5F5FF, 0x2A77A1FF, 0x840410FF, 0x263739FF, 0x86446EFF, 0xD78E10FF, 0x4C75B7FF, 0xBDBEC6FF, 0x5E7072FF,
0x46597AFF, 0x656A79FF, 0x5D7E8DFF, 0x58595AFF, 0xD6DAD6FF, 0x9CA1A3FF, 0x335F3FFF, 0x730E1AFF, 0x7B0A2AFF, 0x9F9D94FF,
0x3B4E78FF, 0x732E3EFF, 0x691E3BFF, 0x96918CFF, 0x515459FF, 0x3F3E45FF, 0xA5A9A7FF, 0x635C5AFF, 0x3D4A68FF, 0x979592FF,
0x421F21FF, 0x5F272BFF, 0x8494ABFF, 0x767B7CFF, 0x646464FF, 0x5A5752FF, 0x252527FF, 0x2D3A35FF, 0x93A396FF, 0x6D7A88FF,
0x221918FF, 0x6F675FFF, 0x7C1C2AFF, 0x5F0A15FF, 0x193826FF, 0x5D1B20FF, 0x9D9872FF, 0x7A7560FF, 0x989586FF, 0xADB0B0FF,
0x848988FF, 0x304F45FF, 0x4D6268FF, 0x162248FF, 0x272F4BFF, 0x7D6256FF, 0x9EA4ABFF, 0x9C8D71FF, 0x6D1822FF, 0x4E6881FF,
0x9C9C98FF, 0x917347FF, 0x661C26FF, 0x949D9FFF, 0xA4A7A5FF, 0x8E8C46FF, 0x341A1EFF, 0x6A7A8CFF, 0xAAAD8EFF, 0xAB988FFF,
0x851F2EFF, 0x6F8297FF, 0x585853FF, 0x9AA790FF, 0x601A23FF, 0x20202CFF, 0xA4A096FF, 0xAA9D84FF, 0x78222BFF, 0x0E316DFF,
0x722A3FFF, 0x7B715EFF, 0x741D28FF, 0x1E2E32FF, 0x4D322FFF, 0x7C1B44FF, 0x2E5B20FF, 0x395A83FF, 0x6D2837FF, 0xA7A28FFF,
0xAFB1B1FF, 0x364155FF, 0x6D6C6EFF, 0x0F6A89FF, 0x204B6BFF, 0x2B3E57FF, 0x9B9F9DFF, 0x6C8495FF, 0x4D8495FF, 0xAE9B7FFF,
0x406C8FFF, 0x1F253BFF, 0xAB9276FF, 0x134573FF, 0x96816CFF, 0x64686AFF, 0x105082FF, 0xA19983FF, 0x385694FF, 0x525661FF,
0x7F6956FF, 0x8C929AFF, 0x596E87FF, 0x473532FF, 0x44624FFF, 0x730A27FF, 0x223457FF, 0x640D1BFF, 0xA3ADC6FF, 0x695853FF,
0x9B8B80FF, 0x620B1CFF, 0x5B5D5EFF, 0x624428FF, 0x731827FF, 0x1B376DFF, 0xEC6AAEFF, 0x000000FF,
// SA-MP extended colours (0.3x)
0x177517FF, 0x210606FF, 0x125478FF, 0x452A0DFF, 0x571E1EFF, 0x010701FF, 0x25225AFF, 0x2C89AAFF, 0x8A4DBDFF, 0x35963AFF,
0xB7B7B7FF, 0x464C8DFF, 0x84888CFF, 0x817867FF, 0x817A26FF, 0x6A506FFF, 0x583E6FFF, 0x8CB972FF, 0x824F78FF, 0x6D276AFF,
0x1E1D13FF, 0x1E1306FF, 0x1F2518FF, 0x2C4531FF, 0x1E4C99FF, 0x2E5F43FF, 0x1E9948FF, 0x1E9999FF, 0x999976FF, 0x7C8499FF,
0x992E1EFF, 0x2C1E08FF, 0x142407FF, 0x993E4DFF, 0x1E4C99FF, 0x198181FF, 0x1A292AFF, 0x16616FFF, 0x1B6687FF, 0x6C3F99FF,
0x481A0EFF, 0x7A7399FF, 0x746D99FF, 0x53387EFF, 0x222407FF, 0x3E190CFF, 0x46210EFF, 0x991E1EFF, 0x8D4C8DFF, 0x805B80FF,
0x7B3E7EFF, 0x3C1737FF, 0x733517FF, 0x781818FF, 0x83341AFF, 0x8E2F1CFF, 0x7E3E53FF, 0x7C6D7CFF, 0x020C02FF, 0x072407FF,
0x163012FF, 0x16301BFF, 0x642B4FFF, 0x368452FF, 0x999590FF, 0x818D96FF, 0x99991EFF, 0x7F994CFF, 0x839292FF, 0x788222FF,
0x2B3C99FF, 0x3A3A0BFF, 0x8A794EFF, 0x0E1F49FF, 0x15371CFF, 0x15273AFF, 0x375775FF, 0x060820FF, 0x071326FF, 0x20394BFF,
0x2C5089FF, 0x15426CFF, 0x103250FF, 0x241663FF, 0x692015FF, 0x8C8D94FF, 0x516013FF, 0x090F02FF, 0x8C573AFF, 0x52888EFF,
0x995C52FF, 0x99581EFF, 0x993A63FF, 0x998F4EFF, 0x99311EFF, 0x0D1842FF, 0x521E1EFF, 0x42420DFF, 0x4C991EFF, 0x082A1DFF,
0x96821DFF, 0x197F19FF, 0x3B141FFF, 0x745217FF, 0x893F8DFF, 0x7E1A6CFF, 0x0B370BFF, 0x27450DFF, 0x071F24FF, 0x784573FF,
0x8A653AFF, 0x732617FF, 0x319490FF, 0x56941DFF, 0x59163DFF, 0x1B8A2FFF, 0x38160BFF, 0x041804FF, 0x355D8EFF, 0x2E3F5BFF,
0x561A28FF, 0x4E0E27FF, 0x706C67FF, 0x3B3E42FF, 0x2E2D33FF, 0x7B7E7DFF, 0x4A4442FF, 0x28344EFF
};
```
## Notes

:::tip

Some vehicles have only a primary color and some can not have the color changed at all. A few (cement, squallo) have 4 colors, of which 2 can not be changed in SA:MP

:::

## Related Functions

- [GetVehicleColours](GetVehicleColours): Gets the vehicle colours.
- [ChangeVehiclePaintjob](ChangeVehiclePaintjob): Change the paintjob on a vehicle.

## Related Callbacks

- [OnVehicleRespray](../callbacks/OnVehicleRespray): Called when a vehicle is resprayed.
6 changes: 5 additions & 1 deletion docs/scripting/functions/ChangeVehiclePaintjob.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,15 @@ If vehicle's color is black , paintjob may not be visible. Better to make vehicl

```c
new rand = random(3); // Will either be 0 1 or 2 (all valid)
ChangeVehicleColor(GetPlayerVehicleID(playerid),1,1); // making sure it is white for better result
ChangeVehicleColor(GetPlayerVehicleID(playerid), 1, 1); // making sure it is white for better result
ChangeVehiclePaintjob(GetPlayerVehicleID(playerid), rand); // changes the paintjob of the player's current vehicle to a random one
```
## Related Functions
- [GetVehiclePaintjob](GetVehiclePaintjob): Gets the vehicle's paintjob id.
- [ChangeVehicleColor](ChangeVehicleColor): Set the color of a vehicle.
## Related Callbacks
- [OnVehiclePaintjob](../callbacks/OnVehiclePaintjob): Called when a vehicle's paintjob is changed.
9 changes: 9 additions & 0 deletions docs/scripting/functions/CreateVehicle.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,5 +53,14 @@ Trains can only be added with AddStaticVehicle and AddStaticVehicleEx.
- [AddStaticVehicle](AddStaticVehicle): Add a static vehicle.
- [AddStaticVehicleEx](AddStaticVehicleEx): Add a static vehicle with custom respawn time.
- [GetVehicleParamsSirenState](GetVehicleParamsSirenState): Check whether a vehicle's siren is on or off.
- [SetVehicleSpawnInfo](SetVehicleSpawnInfo): Adjusts vehicle model, spawn location, colours, respawn delay and interior.
- [GetVehicleSpawnInfo](GetVehicleSpawnInfo): Gets the vehicle spawn location and colours.
- [ChangeVehicleColours](ChangeVehicleColours): Change a vehicle's primary and secondary colors.
- [GetVehicleColours](GetVehicleColours): Gets the vehicle colours.
- [SetVehicleRespawnDelay](SetVehicleRespawnDelay): Set the respawn delay of a vehicle.
- [GetVehicleRespawnDelay](GetVehicleRespawnDelay): Get the respawn delay of a vehicle.

## Related Callbacks

- [OnVehicleSpawn](../callbacks/OnVehicleSpawn): Called when a vehicle respawns.
- [OnVehicleSirenStateChange](../callbacks/OnVehicleSirenStateChange): Called when a vehicle's siren is toggled on/off.
4 changes: 4 additions & 0 deletions docs/scripting/functions/GameModeExit.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,7 @@ if (OneTeamHasWon)
GameModeExit();
}
```

## Related Functions

- [SetModeRestartTime](SetModeRestartTime): Sets the delay between loading main scripts, in seconds.
28 changes: 28 additions & 0 deletions docs/scripting/functions/GetModeRestartTime.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
---
title: GetModeRestartTime
description: Gets the delay between loading main scripts, in seconds.
tags: []
---

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

## Description

Gets the delay between loading main scripts, in seconds.

## Return Values

Returns the delay as a float value.

## Examples

```c
SetModeRestartTime(5.0);

new Float:seconds = GetModeRestartTime();
printf("Delay: %.1f", seconds); // Delay: 5.0
```
## Related Functions
- [SetModeRestartTime](SetModeRestartTime): Sets the delay between loading main scripts, in seconds.
27 changes: 27 additions & 0 deletions docs/scripting/functions/GetPlayerHydraReactorAngle.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
---
title: GetPlayerHydraReactorAngle
description: Gets the hydra reactor angle of the player's vehicle.
tags: ["player", "vehicle"]
---

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

## Description

Gets the hydra reactor angle of the player's vehicle.

## Parameters

| Name | Description |
|----------|-----------------------|
| playerid | The ID of the player. |

## Examples

```c
new Float:reactorAngle = GetPlayerHydraReactorAngle(playerid);
```

## Related Functions

- [GetVehicleHydraReactorAngle](GetVehicleHydraReactorAngle): Gets the hydra reactor angle of the vehicle.
31 changes: 31 additions & 0 deletions docs/scripting/functions/GetPlayerLandingGearState.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
---
title: GetPlayerLandingGearState
description: Gets the landing gear state of the current player's vehicle.
tags: ["player", "vehicle"]
---

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

## Description

Gets the [landing gear state](../resources/landinggearstate) of the current player's vehicle.

## Parameters

| Name | Description |
|----------|-----------------------|
| playerid | The ID of the player. |

## Examples

```c
new LANDING_GEAR_STATE:state = GetPlayerLandingGearState(playerid);
```

## Related Functions

- [GetVehicleLandingGearState](GetVehicleLandingGearState): Gets the current vehicle landing gear state from the latest driver.

## Related Resources

- [Vehicle Landing Gear States](../resources/landinggearstate)
31 changes: 31 additions & 0 deletions docs/scripting/functions/GetPlayerLastSyncedTrailerID.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
---
title: GetPlayerLastSyncedTrailerID
description: Gets the player's last synced trailer ID.
tags: ["player", "vehicle"]
---

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

## Description

Gets the player's last synced trailer ID.

## Parameters

| Name | Description |
|----------|-----------------------|
| playerid | The ID of the player. |

## Return Values

Returns the last synced trailer ID.

## Examples

```c
new trailerid = GetPlayerLastSyncedTrailerID(playerid);
```

## Related Functions

- [GetPlayerLastSyncedVehicleID](GetPlayerLastSyncedVehicleID): Gets the player's last synced vehicle ID.
31 changes: 31 additions & 0 deletions docs/scripting/functions/GetPlayerLastSyncedVehicleID.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
---
title: GetPlayerLastSyncedVehicleID
description: Gets the player's last synced vehicle ID.
tags: ["player", "vehicle"]
---

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

## Description

Gets the player's last synced vehicle ID.

## Parameters

| Name | Description |
|----------|-----------------------|
| playerid | The ID of the player. |

## Return Values

Returns the last synced vehicle ID.

## Examples

```c
new vehicleid = GetPlayerLastSyncedVehicleID(playerid);
```

## Related Functions

- [GetPlayerLastSyncedTrailerID](GetPlayerLastSyncedTrailerID): Gets the player's last synced trailer ID.
49 changes: 49 additions & 0 deletions docs/scripting/functions/GetPlayerSirenState.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
---
title: GetPlayerSirenState
description: Gets the siren state of the player's vehicle.
tags: ["player", "vehicle"]
---

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

## Description

Gets the siren state of the player's vehicle.

## Parameters

| Name | Description |
|----------|-----------------------|
| playerid | The ID of the player. |

## Return Values

Returns the vehicle siren state.

## Examples

```c
public OnPlayerCommandText(playerid, cmdtext[])
{
if (!strcmp(cmdtext, "/siren", true))
{
if (!IsPlayerInAnyVehicle(playerid))
{
return 1;
}

new bool:sirenState = GetPlayerSirenState(playerid);

SendClientMessage(playerid, 0xFFFF00FF, "Vehicle siren state: %s", sirenState ? "On" : "Off");
return 1;
}
return 0;
}
```
## Related Functions
- [SetVehicleParamsSirenState](SetVehicleParamsSirenState): Turn the siren for a vehicle on or off.
- [ToggleVehicleSirenEnabled](ToggleVehicleSirenEnabled): Turn the siren for a vehicle on or off.
- [IsVehicleSirenEnabled](IsVehicleSirenEnabled): Checks if a vehicle siren is on or off.
- [GetVehicleSirenState](GetVehicleSirenState): Gets the siren state of the vehicle.
Loading

0 comments on commit 55a5dde

Please sign in to comment.