Skip to content

Commit

Permalink
tweak(natives): fix c# examples throughout the repo (#1180)
Browse files Browse the repository at this point in the history
  • Loading branch information
AvarianKnight authored Aug 27, 2024
1 parent 343958d commit 617cb7c
Show file tree
Hide file tree
Showing 24 changed files with 75 additions and 75 deletions.
4 changes: 2 additions & 2 deletions ENTITY/FreezeEntityPosition.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,11 @@ using static CitizenFX.Core.Native.API;
// Freeze the local player.
// Retrieve the player ped
Ped playerPed = PlayerPedId();
int playerPed = PlayerPedId();

// Freeze the ped
FreezeEntityPosition(playerPed, true);

// or the preferred use of C# wrapper
Game.PlayerPed.IsPositionFrozen = true;
```
```
6 changes: 3 additions & 3 deletions ENTITY/SetPickUpByCargobobDisabled.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,10 @@ SetPickUpByCargobobDisabled(vehicle, true);
using static CitizenFX.Core.Native.API;

// Retrieve the player ped.
Ped playerPed = PlayerPedId();
int playerPed = PlayerPedId();

// Retrieve the player's vehicle.
Vehicle vehicle = GetVehiclePedIsIn(playerPed, false);
int vehicle = GetVehiclePedIsIn(playerPed, false);

// Check if the vehicle exists in the game world.
if (!DoesEntityExist(vehicle)) {
Expand All @@ -76,4 +76,4 @@ if (!DoesEntityExist(vehicle)) {

// Prevent the vehicle from being picked up by Cargobobs.
SetPickUpByCargobobDisabled(vehicle, true);
```
```
6 changes: 3 additions & 3 deletions MISC/GetDistanceBetweenCoords.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,6 @@ float dist = GetDistanceBetweenCoords(0f, 0f, 0f, 5f, 5f, 5f, true)
Vector3 firstVec = new Vector3(0f, 0f, 0f);
Vector3 secondVec = new Vector3(5f, 5f, 5f);

float dist = firstVec.DistanceToSquared(secondVec); -- Use Z
float dist = firstVec.DistanceToSquared2D(secondVec); -- Do not use Z
```
float dist = firstVec.DistanceToSquared(secondVec); // Use Z
float dist = firstVec.DistanceToSquared2D(secondVec); // Do not use Z
```
4 changes: 2 additions & 2 deletions PED/GetVehiclePedIsIn.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,10 @@ console.log(`Vehicle ID: ${vehicle}`);
using static CitizenFX.Core.Native.API;

// Retrieve the player ped
Ped playerPed = PlayerPedId();
int playerPed = PlayerPedId();

// Retrieve the vehicle the player is currently in.
Vehicle vehicle = GetVehiclePedIsIn(playerPed, false);
int vehicle = GetVehiclePedIsIn(playerPed, false);

// Check if the vehicle exists in the game world.
if (!DoesEntityExist(vehicle)) {
Expand Down
6 changes: 3 additions & 3 deletions PED/SetPedPhonePaletteIdx.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ const playerPed = PlayerPedId();
SetPedPhonePaletteIdx(playerPed, PhoneColors.Green);
```

```csharp
```cs
using static CitizenFX.Core.Native.API;

// Define an enum with color names and their corresponding indices
Expand All @@ -84,8 +84,8 @@ public enum PhoneColors
}

// Retrieve the current player ped
Ped playerPed = PlayerPedId();
int playerPed = PlayerPedId();

// Set the phone color of the player's ped to Green using the enum value
SetPedPhonePaletteIdx(playerPed, (int)PhoneColors.Green);
```
```
8 changes: 4 additions & 4 deletions VEHICLE/ArePlaneControlPanelsIntact.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ else
end
```

```javascript
```js
// Retrieve the player ped
const playerPed = PlayerPedId();

Expand All @@ -59,14 +59,14 @@ if (controlPanelsIntact) {
}
```

```csharp
```cs
using static CitizenFX.Core.Native.API;

// Retrieve the player ped
Ped playerPed = PlayerPedId();
int playerPed = PlayerPedId();

// Retrieve the plane the player is currently flying
Vehicle plane = GetVehiclePedIsIn(playerPed, false);
int plane = GetVehiclePedIsIn(playerPed, false);

// If the player is not flying a plane, return
if (plane == 0 || !IsThisModelAPlane(GetEntityModel(plane))) return;
Expand Down
8 changes: 4 additions & 4 deletions VEHICLE/CanCargobobPickUpEntity.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,16 +89,16 @@ if (CanCargobobPickUpEntity(vehicle, entityID)) {
using static CitizenFX.Core.Native.API;

// Retrieve the player ped.
Ped playerPed = PlayerPedId();
int playerPed = PlayerPedId();

// Retrieve the player's vehicle (cargobob).
Vehicle cargobob = GetVehiclePedIsIn(playerPed, false);
int cargobob = GetVehiclePedIsIn(playerPed, false);

// Retrieve the model hash of the cargobob.
uint model = GetEntityModel(cargobob);

// Check if the vehicle exists and if it's a Cargobob. If not, terminate the script.
if (!DoesEntityExist(cargobob) || (uint)GetHashKey("cargobob") != model) {
if (!DoesEntityExist(cargobob) || model != (uint)GetHashKey("cargobob")) {
return;
}

Expand All @@ -115,4 +115,4 @@ if (CanCargobobPickUpEntity(vehicle, entityID)) {
} else {
Debug.WriteLine("Cargobob can't pick up the specified entity");
}
```
```
6 changes: 3 additions & 3 deletions VEHICLE/ClearNitrous.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ if IsNitrousActive(vehicle) then
end
```

```javascript
```js
// Retrieve the player ped.
const playerPed = PlayerPedId();

Expand All @@ -53,7 +53,7 @@ if (IsNitrousActive(vehicle)) {
}
```

```csharp
```cs
using static CitizenFX.Core.Native.API;

// Retrieve the player ped
Expand All @@ -70,4 +70,4 @@ if (IsNitrousActive(vehicle)) {
// If nitrous is active, clear the nitrous boost from the vehicle.
ClearNitrous(vehicle);
}
```
```
4 changes: 2 additions & 2 deletions VEHICLE/DetachEntityFromCargobob.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,10 @@ using static CitizenFX.Core.Native.API;
// This example detaches a specific entity from a Cargobob.
// Retrieve the player ped.
Ped playerPed = PlayerPedId();
int playerPed = PlayerPedId();

// Retrieve the player's vehicle.
Vehicle cargobob = GetVehiclePedIsIn(playerPed, false);
int cargobob = GetVehiclePedIsIn(playerPed, false);

// Retrieve the model hash of the cargobob.
uint cargobobModel = (uint)GetEntityModel(cargobob);
Expand Down
8 changes: 4 additions & 4 deletions VEHICLE/GetBoatVehicleModelAgility.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,10 @@ console.log(`Boat Agility: ${agility}`);
using static CitizenFX.Core.Native.API;

// Retrieve the player ped.
Ped playerPed = PlayerPedId();
int playerPed = PlayerPedId();

// Retrieve the vehicle the player is currently in.
Vehicle vehicle = GetVehiclePedIsIn(playerPed, false);
int vehicle = GetVehiclePedIsIn(playerPed, false);

// Retrieve the model hash of the boat.
uint boatHash = GetEntityModel(vehicle);
Expand All @@ -89,8 +89,8 @@ if (!DoesEntityExist(vehicle) || !IsThisModelABoat(boatHash)) {
}

// Retrieve the agility of the boat.
const float agility = GetBoatVehicleModelAgility(boatHash);
float agility = GetBoatVehicleModelAgility(boatHash);

// Print the agility of the boat.
Debug.WriteLine($"Boat Agility: {agility}");
```
```
4 changes: 2 additions & 2 deletions VEHICLE/GetIsBoatCapsized.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,10 @@ if (GetIsBoatCapsized(vehicle)) {
using static CitizenFX.Core.Native.API;

// Retrieve the LocalPlayer.
Ped playerPed = PlayerPedId();
int playerPed = PlayerPedId();

// Retrieve the vehicle the player is in
Vehicle vehicle = GetVehiclePedIsIn(playerPed, false);
int vehicle = GetVehiclePedIsIn(playerPed, false);

// Retrieve the model of the vehicle
uint vehicleModel = (uint)GetEntityModel(vehicle);
Expand Down
6 changes: 3 additions & 3 deletions VEHICLE/GetMakeNameFromVehicleModel.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,10 @@ console.log(`Vehicle Manufacturer: ${manufacturer}`);
using static CitizenFX.Core.Native.API;

// Retrieve the player ped.
Ped playerPed = PlayerPedId();
int playerPed = PlayerPedId();

// Retrieve the vehicle the player is currently in.
Vehicle vehicle = GetVehiclePedIsIn(playerPed, false);
int vehicle = GetVehiclePedIsIn(playerPed, false);

// If the vehicle does not exist, end the execution of the code here.
if (!DoesEntityExist(vehicle)) {
Expand All @@ -93,4 +93,4 @@ string manufacturer = GetMakeNameFromVehicleModel(vehicleHash);

// Print the manufacturer of the vehicle.
Debug.WriteLine($"Vehicle Manufacturer: {manufacturer}");
```
```
8 changes: 4 additions & 4 deletions VEHICLE/GetVehicleAcceleration.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,19 +67,19 @@ console.log(`Vehicle Acceleration: ${acceleration}`);
using static CitizenFX.Core.Native.API;

// Retrieve the player ped.
Ped playerPed = PlayerPedId();
int playerPed = PlayerPedId();

// Retrieve the vehicle the player is currently in.
Vehicle vehicle = GetVehiclePedIsIn(playerPed, false);
int vehicle = GetVehiclePedIsIn(playerPed, false);

// If the vehicle does not exist, end the execution of the code here.
if (!DoesEntityExist(vehicle)) {
return;
}

// Retrieve the acceleration of the vehicle.
const float acceleration = GetVehicleAcceleration(vehicle);
float acceleration = GetVehicleAcceleration(vehicle);

// Print the acceleration of the vehicle.
Debug.WriteLine($"Vehicle Acceleration: {acceleration}");
```
```
8 changes: 4 additions & 4 deletions VEHICLE/GetVehicleEstimatedMaxSpeed.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,19 +68,19 @@ console.log(`Estimated Max Speed: ${estimatedMaxSpeed}`);
using static CitizenFX.Core.Native.API;

// Retrieve the player ped.
Ped playerPed = PlayerPedId();
int playerPed = PlayerPedId();

// Retrieve the vehicle the player is currently in.
Vehicle vehicle = GetVehiclePedIsIn(playerPed, false);
int vehicle = GetVehiclePedIsIn(playerPed, false);

// If the vehicle does not exist, end the execution of the code here.
if (!DoesEntityExist(vehicle)) {
return;
}

// Retrieve the estimated max speed of the vehicle.
const float estimatedMaxSpeed = GetVehicleEstimatedMaxSpeed(vehicle);
float estimatedMaxSpeed = GetVehicleEstimatedMaxSpeed(vehicle);

// Print the estimated max speed of the vehicle.
Debug.WriteLine($"Estimated Max Speed: {estimatedMaxSpeed}");
```
```
6 changes: 3 additions & 3 deletions VEHICLE/SetCargobobExcludeFromPickupEntity.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,10 @@ SetCargobobExcludeFromPickupEntity(cargobob, entityID);
using static CitizenFX.Core.Native.API;

// Retrieve the player ped
Ped playerPed = PlayerPedId();
int playerPed = PlayerPedId();

// Retrieve the player's vehicle (cargobob)
Vehicle cargobob = GetVehiclePedIsIn(playerPed, false);
int cargobob = GetVehiclePedIsIn(playerPed, false);

// Retrieve the model hash of the cargobob.
uint cargobobModel = GetEntityModel(cargobob);
Expand All @@ -103,4 +103,4 @@ if (!DoesEntityExist(entityID)) {

// Prevent the entity from being detached from the Cargobob.
SetCargobobExcludeFromPickupEntity(cargobob, entityID);
```
```
10 changes: 5 additions & 5 deletions VEHICLE/SetDisableBmxExtraTrickForces.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ if not IsThisModelABicycle(GetEntityModel(bmx)) then return end
SetDisableBmxExtraTrickForces(bmx, true)
```

```javascript
```js
// Retrieve the player ped
const playerPed = PlayerPedId();

Expand All @@ -47,18 +47,18 @@ if (!IsThisModelABicycle(GetEntityModel(bmx))) return;
SetDisableBmxExtraTrickForces(bmx, true);
```

```csharp
```cs
using static CitizenFX.Core.Native.API;

// Retrieve the player ped
Ped playerPed = PlayerPedId();
int playerPed = PlayerPedId();

// Retrieve the BMX bike the player is currently riding
Vehicle bmx = GetVehiclePedIsIn(playerPed, false);
int bmx = GetVehiclePedIsIn(playerPed, false);

// If the player is not riding a BMX bike, return
if (!IsThisModelABicycle(GetEntityModel(bmx))) return;

// Disable the extra forces applied to BMX bikes for tricks
SetDisableBmxExtraTrickForces(bmx, true);
```
```
8 changes: 4 additions & 4 deletions VEHICLE/SetDisableExplodeFromBodyDamageOnCollision.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ local vehicle = GetVehiclePedIsIn(playerPed, false)
SetDisableExplodeFromBodyDamageOnCollision(vehicle, true)
```

```javascript
```js
// Retrieve the player ped
const playerPed = PlayerPedId();

Expand All @@ -44,14 +44,14 @@ const vehicle = GetVehiclePedIsIn(playerPed, false);
SetDisableExplodeFromBodyDamageOnCollision(vehicle, true);
```

```csharp
```cs
using static CitizenFX.Core.Native.API;

// Retrieve the player ped
Ped playerPed = PlayerPedId();
int playerPed = PlayerPedId();

// Retrieve the vehicle the player is currently in
Vehicle vehicle = GetVehiclePedIsIn(playerPed, false);
int vehicle = GetVehiclePedIsIn(playerPed, false);

// Disable explosion from body damage on collision for the vehicle
SetDisableExplodeFromBodyDamageOnCollision(vehicle, true);
Expand Down
6 changes: 3 additions & 3 deletions VEHICLE/SetOpenRearDoorsOnExplosion.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,11 @@ if (modelVehicle === hashStockade) {
using static CitizenFX.Core.Native.API;
// This example disables the rear doors of the vehicle from opening upon explosion.
// Retrieve the LocalPlayer.
Ped playerPed = PlayerPedId();
// Retrieve the local ped.
int playerPed = PlayerPedId();

// Retrieve the vehicle the player is currently in.
Vehicle vehicle = GetVehiclePedIsIn(playerPed, false);
int vehicle = GetVehiclePedIsIn(playerPed, false);

// Check if the vehicle exists in the game world.
if (!DoesEntityExist(vehicle))
Expand Down
6 changes: 3 additions & 3 deletions VEHICLE/SetTransformRateForAnimation.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,10 @@ SetTransformRateForAnimation(vehicle, 2.5);
using static CitizenFX.Core.Native.API;

// Retrieve the player ped
Ped playerPed = PlayerPedId();
int playerPed = PlayerPedId();

// Retrieve the vehicle in which the player is currently seated
Vehicle vehicle = GetVehiclePedIsIn(playerPed, false); // Get the vehicle in which the player is currently seated
int vehicle = GetVehiclePedIsIn(playerPed, false); // Get the vehicle in which the player is currently seated
// Retrieve the vehicle model hash
uint vehicleHash = (uint)GetEntityModel(vehicle);
Expand All @@ -82,4 +82,4 @@ if (!DoesEntityExist(vehicle) || vehicleHash != (uint)GetHashKey("stromberg"))

// Set the transform rate for the submarine car conversion animations to 2.5
SetTransformRateForAnimation(vehicle, 2.5f);
```
```
Loading

0 comments on commit 617cb7c

Please sign in to comment.