Skip to content

Commit fce25fd

Browse files
authored
Merge pull request #1186 from NexiusTailer/master
Fix misleading example in PutPlayerInVehicle
2 parents 80823c7 + ddec036 commit fce25fd

2 files changed

Lines changed: 4 additions & 66 deletions

File tree

frontend/docs/scripting/functions/PutPlayerInVehicle.md

Lines changed: 2 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -24,40 +24,9 @@ Puts a player in a vehicle.
2424
## Examples
2525

2626
```c
27-
// Global array to track which vehicle belongs to each player.
28-
// INVALID_VEHICLE_ID is used as a placeholder for players without a vehicle.
29-
static s_PlayerVehicle[MAX_PLAYERS] = { INVALID_VEHICLE_ID, ... };
30-
31-
public OnPlayerSpawn(playerid)
32-
{
33-
// Check if the player already has a valid vehicle.
34-
if (!IsValidVehicle(s_PlayerVehicle[playerid]))
35-
{
36-
// If not, create a new vehicle for the player and store its ID.
37-
s_PlayerVehicle[playerid] = CreateVehicle(411, 0.0, 0.0, 3.5, 0.0, -1, -1, -1);
38-
}
39-
40-
// Mark that the player should be placed in their vehicle once it is fully loaded.
41-
// This avoids issues where the vehicle might not yet be loaded on the client's side.
42-
SetPVarInt(playerid, "PutPlayerInVehicle", 1);
43-
44-
return 1;
45-
}
46-
47-
public OnVehicleStreamIn(vehicleid, forplayerid)
27+
public OnPlayerEnterVehicle(playerid, vehicleid, ispassanger)
4828
{
49-
// This callback is triggered when a vehicle streams in for the player (i.e. when it is loaded into memory).
50-
// Check if the streamed-in vehicle is the player's and if they need to be placed in it.
51-
if (vehicleid == s_PlayerVehicle[forplayerid] && GetPVarInt(forplayerid, "PutPlayerInVehicle"))
52-
{
53-
// Put the player into the vehicle.
54-
PutPlayerInVehicle(forplayerid, vehicleid, 0);
55-
56-
// Clear the marker to prevent repeatedly putting the player into the vehicle
57-
// (e.g., if the player leaves the vehicle and it streams in again later).
58-
DeletePVar(forplayerid, "PutPlayerInVehicle");
59-
}
60-
29+
PutPlayerInVehicle(playerid, vehicleid, 0);
6130
return 1;
6231
}
6332

frontend/i18n/fa/docusaurus-plugin-content-docs/current/scripting/functions/PutPlayerInVehicle.md

Lines changed: 2 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -24,40 +24,9 @@ tags: ["player", "vehicle"]
2424
## مثال‌ها
2525

2626
```c
27-
// Global array baraye radgirigiye inke kodum vehicle motealeq be har player hast.
28-
// INVALID_VEHICLE_ID baraye placeholder playerhayi ke vehicle nadarand estefade mishe.
29-
static s_PlayerVehicle[MAX_PLAYERS] = { INVALID_VEHICLE_ID, ... };
30-
31-
public OnPlayerSpawn(playerid)
32-
{
33-
// Check mikonim age player ghablan vehicle dashteh ya na.
34-
if (!IsValidVehicle(s_PlayerVehicle[playerid]))
35-
{
36-
// Age nadareh, ye vehicle jadid barash misazim va ID esh ro zakhire mikonim.
37-
s_PlayerVehicle[playerid] = CreateVehicle(411, 0.0, 0.0, 3.5, 0.0, -1, -1, -1);
38-
}
39-
40-
// Moshakhas mikonim ke player bayad dar vehicle gharar begireh vaghti ke kamel load shod.
41-
// In az moshkelat jologirigiri mikone ke vehicle hanuz dar samte client load nashode bashe.
42-
SetPVarInt(playerid, "PutPlayerInVehicle", 1);
43-
44-
return 1;
45-
}
46-
47-
public OnVehicleStreamIn(vehicleid, forplayerid)
27+
public OnPlayerEnterVehicle(playerid, vehicleid, ispassanger)
4828
{
49-
// In callback vaghti ejra mishe ke ye vehicle baraye player stream in mishe (yaani dar hafeze load mishe).
50-
// Check mikonim age vehicle ke stream in shode motealeq be hamun player bashe va lazem bashe dar un gharar begire.
51-
if (vehicleid == s_PlayerVehicle[forplayerid] && GetPVarInt(forplayerid, "PutPlayerInVehicle"))
52-
{
53-
// Player ro dar vehicle gharar midim.
54-
PutPlayerInVehicle(forplayerid, vehicleid, 0);
55-
56-
// Marker ro pak mikonim ta az tekrar gharar dadan player dar vehicle
57-
// jologirigiri konim (meslan age player az vehicle biyad birun va dobre stream in beshe).
58-
DeletePVar(forplayerid, "PutPlayerInVehicle");
59-
}
60-
29+
PutPlayerInVehicle(playerid, vehicleid, 0);
6130
return 1;
6231
}
6332
```

0 commit comments

Comments
 (0)