Skip to content

Commit d240922

Browse files
committed
finish all Get funcs
1 parent a8a1086 commit d240922

22 files changed

+364
-492
lines changed

frontend/docs/scripting/functions/NPC_GetEnteringVehicle.md

Lines changed: 41 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,19 +33,52 @@ public OnPlayerCommandText(playerid, cmdtext[])
3333
if (!NPC_IsValid(npcid))
3434
return SendClientMessage(playerid, 0xFF0000FF, "Invalid NPC.");
3535

36-
if (!NPC_IsEnteringVehicle(npcid))
37-
return SendClientMessage(playerid, 0xFFFF00FF, "NPC %d is not entering a vehicle.", npcid);
36+
// Start monitoring if not already running
37+
if (PlayerEnterVehicleMonitor[playerid] == INVALID_TIMER_ID)
38+
{
39+
PlayerEnterVehicleMonitor[playerid] = SetTimerEx("CheckNPCEnteringVehicle", 200, true, "i", playerid);
40+
PlayerWasEnteringVehicle[playerid] = false;
41+
SendClientMessage(playerid, 0x00FF00FF, "Started monitoring NPC %d vehicle entry.", npcid);
42+
}
43+
else
44+
{
45+
SendClientMessage(playerid, 0xFFFF00FF, "Already monitoring NPC %d vehicle entry.", npcid);
46+
}
47+
return 1;
48+
}
49+
return 0;
50+
}
3851

52+
forward CheckNPCEnteringVehicle(playerid);
53+
public CheckNPCEnteringVehicle(playerid)
54+
{
55+
if (!IsPlayerConnected(playerid))
56+
{
57+
StopPlayerEnterVehicleMonitor(playerid);
58+
return 0;
59+
}
60+
61+
new npcid = PlayerNPC[playerid];
62+
if (npcid == INVALID_NPC_ID || !NPC_IsValid(npcid))
63+
{
64+
StopPlayerEnterVehicleMonitor(playerid);
65+
return 0;
66+
}
67+
68+
new bool:isEntering = NPC_IsEnteringVehicle(npcid);
69+
70+
if (isEntering)
71+
{
3972
new vehicleid = NPC_GetEnteringVehicle(npcid);
4073
new seatid = NPC_GetEnteringVehicleSeat(npcid);
4174

42-
if (vehicleid == INVALID_VEHICLE_ID || vehicleid == 0)
43-
return SendClientMessage(playerid, 0xFFFF00FF, "NPC %d has no pending target vehicle.", npcid);
44-
45-
SendClientMessage(playerid, 0x00FF00FF, "NPC %d is entering vehicle %d (seat %d).", npcid, vehicleid, seatid);
46-
return 1;
75+
if (vehicleid != INVALID_VEHICLE_ID && vehicleid != 0)
76+
{
77+
SendClientMessage(playerid, 0xFFFF00FF, "NPC %d entering vehicle %d (seat %d)", npcid, vehicleid, seatid);
78+
}
4779
}
48-
return 0;
80+
81+
return 1;
4982
}
5083
```
5184

frontend/docs/scripting/functions/NPC_GetEnteringVehicleID.md

Lines changed: 44 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ Returns the vehicle ID the NPC is entering, or INVALID_VEHICLE_ID if not enterin
2424
```c
2525
public OnPlayerCommandText(playerid, cmdtext[])
2626
{
27-
if (!strcmp(cmdtext, "/checkenteringvehicleid", true))
27+
if (!strcmp(cmdtext, "/checkenterveh", true))
2828
{
2929
new npcid = PlayerNPC[playerid];
3030
if (npcid == INVALID_NPC_ID)
@@ -33,16 +33,53 @@ public OnPlayerCommandText(playerid, cmdtext[])
3333
if (!NPC_IsValid(npcid))
3434
return SendClientMessage(playerid, 0xFF0000FF, "Invalid NPC.");
3535

36-
new vehicleid = NPC_GetEnteringVehicleID(npcid);
37-
38-
if (vehicleid == INVALID_VEHICLE_ID)
39-
return SendClientMessage(playerid, 0xFFFF00FF, "NPC %d is not entering any vehicle.", npcid);
40-
41-
SendClientMessage(playerid, 0x00FF00FF, "NPC %d is entering vehicle ID: %d", npcid, vehicleid);
36+
// Start monitoring if not already running
37+
if (PlayerEnterVehicleMonitor[playerid] == INVALID_TIMER_ID)
38+
{
39+
PlayerEnterVehicleMonitor[playerid] = SetTimerEx("CheckNPCEnteringVehicle", 200, true, "i", playerid);
40+
PlayerWasEnteringVehicle[playerid] = false;
41+
SendClientMessage(playerid, 0x00FF00FF, "Started monitoring NPC %d vehicle entry.", npcid);
42+
}
43+
else
44+
{
45+
SendClientMessage(playerid, 0xFFFF00FF, "Already monitoring NPC %d vehicle entry.", npcid);
46+
}
4247
return 1;
4348
}
4449
return 0;
4550
}
51+
52+
forward CheckNPCEnteringVehicle(playerid);
53+
public CheckNPCEnteringVehicle(playerid)
54+
{
55+
if (!IsPlayerConnected(playerid))
56+
{
57+
StopPlayerEnterVehicleMonitor(playerid);
58+
return 0;
59+
}
60+
61+
new npcid = PlayerNPC[playerid];
62+
if (npcid == INVALID_NPC_ID || !NPC_IsValid(npcid))
63+
{
64+
StopPlayerEnterVehicleMonitor(playerid);
65+
return 0;
66+
}
67+
68+
new bool:isEntering = NPC_IsEnteringVehicle(npcid);
69+
70+
if (isEntering)
71+
{
72+
new vehicleid = NPC_GetEnteringVehicle(npcid);
73+
new seatid = NPC_GetEnteringVehicleSeat(npcid);
74+
75+
if (vehicleid != INVALID_VEHICLE_ID && vehicleid != 0)
76+
{
77+
SendClientMessage(playerid, 0xFFFF00FF, "NPC %d entering vehicle %d (seat %d)", npcid, vehicleid, seatid);
78+
}
79+
}
80+
81+
return 1;
82+
}
4683
```
4784
4885
## Notes

frontend/docs/scripting/functions/NPC_GetEnteringVehicleSeat.md

Lines changed: 43 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ Returns the seat number the NPC is entering, or -1 if not entering.
2424
```c
2525
public OnPlayerCommandText(playerid, cmdtext[])
2626
{
27-
if (!strcmp(cmdtext, "/checkentervehseat", true))
27+
if (!strcmp(cmdtext, "/checkenterveh", true))
2828
{
2929
new npcid = PlayerNPC[playerid];
3030
if (npcid == INVALID_NPC_ID)
@@ -33,15 +33,52 @@ public OnPlayerCommandText(playerid, cmdtext[])
3333
if (!NPC_IsValid(npcid))
3434
return SendClientMessage(playerid, 0xFF0000FF, "Invalid NPC.");
3535

36-
if (!NPC_IsEnteringVehicle(npcid))
37-
return SendClientMessage(playerid, 0xFFFF00FF, "NPC %d is not entering any vehicle.", npcid);
36+
// Start monitoring if not already running
37+
if (PlayerEnterVehicleMonitor[playerid] == INVALID_TIMER_ID)
38+
{
39+
PlayerEnterVehicleMonitor[playerid] = SetTimerEx("CheckNPCEnteringVehicle", 200, true, "i", playerid);
40+
PlayerWasEnteringVehicle[playerid] = false;
41+
SendClientMessage(playerid, 0x00FF00FF, "Started monitoring NPC %d vehicle entry.", npcid);
42+
}
43+
else
44+
{
45+
SendClientMessage(playerid, 0xFFFF00FF, "Already monitoring NPC %d vehicle entry.", npcid);
46+
}
47+
return 1;
48+
}
49+
return 0;
50+
}
51+
52+
forward CheckNPCEnteringVehicle(playerid);
53+
public CheckNPCEnteringVehicle(playerid)
54+
{
55+
if (!IsPlayerConnected(playerid))
56+
{
57+
StopPlayerEnterVehicleMonitor(playerid);
58+
return 0;
59+
}
3860

61+
new npcid = PlayerNPC[playerid];
62+
if (npcid == INVALID_NPC_ID || !NPC_IsValid(npcid))
63+
{
64+
StopPlayerEnterVehicleMonitor(playerid);
65+
return 0;
66+
}
67+
68+
new bool:isEntering = NPC_IsEnteringVehicle(npcid);
69+
70+
if (isEntering)
71+
{
72+
new vehicleid = NPC_GetEnteringVehicle(npcid);
3973
new seatid = NPC_GetEnteringVehicleSeat(npcid);
4074

41-
SendClientMessage(playerid, 0x00FF00FF, "NPC %d is entering vehicle seat: %d", npcid, seatid);
42-
return 1;
75+
if (vehicleid != INVALID_VEHICLE_ID && vehicleid != 0)
76+
{
77+
SendClientMessage(playerid, 0xFFFF00FF, "NPC %d entering vehicle %d (seat %d)", npcid, vehicleid, seatid);
78+
}
4379
}
44-
return 0;
80+
81+
return 1;
4582
}
4683
```
4784

frontend/docs/scripting/functions/NPC_GetSkin.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,27 @@ Returns the skin/model ID of the NPC, or -1 if invalid.
2121

2222
## Examples
2323

24+
```c
25+
public OnPlayerCommandText(playerid, cmdtext[])
26+
{
27+
if (!strcmp(cmdtext, "/checkskin", true))
28+
{
29+
new npcid = PlayerNPC[playerid];
30+
if (npcid == INVALID_NPC_ID)
31+
return SendClientMessage(playerid, 0xFF0000FF, "You are not debugging a NPC.");
32+
33+
if (!NPC_IsValid(npcid))
34+
return SendClientMessage(playerid, 0xFF0000FF, "Invalid NPC.");
35+
36+
new skinid = NPC_GetSkin(npcid);
37+
38+
SendClientMessage(playerid, 0x00FF00FF, "NPC %d skin: %d", npcid, skinid);
39+
return 1;
40+
}
41+
return 0;
42+
}
43+
```
44+
2445
## Notes
2546
2647
- Returns the current skin/model the NPC is using

frontend/docs/scripting/functions/NPC_GetVehicle.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ public OnPlayerCommandText(playerid, cmdtext[])
4848
## Notes
4949
5050
- Returns INVALID_VEHICLE_ID if the NPC is not in any vehicle
51-
- Use this to check if an NPC is driving or is a passenger
5251
5352
## Related Functions
5453

frontend/docs/scripting/functions/NPC_GetVehicleGearState.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,14 @@ public OnPlayerCommandText(playerid, cmdtext[])
3636
if (NPC_GetVehicle(npcid) == INVALID_VEHICLE_ID)
3737
return SendClientMessage(playerid, 0xFFFF00FF, "NPC %d is not in any vehicle.", npcid);
3838

39-
new gearState = NPC_GetVehicleGearState(npcid);
39+
new LANDING_GEAR_STATE:gearState = NPC_GetVehicleGearState(npcid);
4040

4141
if (gearState == LANDING_GEAR_STATE_UP)
4242
SendClientMessage(playerid, 0x00FF00FF, "NPC %d: Landing gear UP", npcid);
4343
else
4444
SendClientMessage(playerid, 0x00FF00FF, "NPC %d: Landing gear DOWN", npcid);
4545

46-
return 1;
46+
return 1;
4747
}
4848
return 0;
4949
}

frontend/docs/scripting/functions/NPC_GetVehicleHealth.md

Lines changed: 14 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -22,73 +22,36 @@ Returns the vehicle health as a float value, or 0.0 if the NPC is not in a vehic
2222
## Examples
2323

2424
```c
25-
public OnGameModeInit()
26-
{
27-
new npcid = NPC_Create("Driver");
28-
NPC_Spawn(npcid);
29-
30-
new vehicleid = CreateVehicle(411, 1958.33, 1343.12, 15.36, 0.0, -1, -1, 300);
31-
NPC_PutInVehicle(npcid, vehicleid, 0);
25+
public OnPlayerCommandText(playerid, cmdtext[])
26+
{
27+
if (!strcmp(cmdtext, "/checkvehiclehealth", true))
28+
{
29+
new npcid = PlayerNPC[playerid];
30+
if (npcid == INVALID_NPC_ID)
31+
return SendClientMessage(playerid, 0xFF0000FF, "You are not debugging a NPC.");
3232

33-
new Float:health = NPC_GetVehicleHealth(npcid);
34-
printf("NPC %d vehicle health: %.1f", npcid, health);
33+
if (!NPC_IsValid(npcid))
34+
return SendClientMessage(playerid, 0xFF0000FF, "Invalid NPC.");
3535

36-
return 1;
37-
}
36+
if (NPC_GetVehicle(npcid) == INVALID_VEHICLE_ID)
37+
return SendClientMessage(playerid, 0xFFFF00FF, "NPC %d is not in any vehicle.", npcid);
3838

39-
public OnPlayerCommandText(playerid, cmdtext[])
40-
{
41-
if (!strcmp(cmdtext, "/checkvehicles", true))
42-
{
43-
new npcs[MAX_NPCS];
44-
new count = NPC_GetAll(npcs);
45-
46-
new Float:health = NPC_GetVehicleHealth(0);
47-
48-
new status[16];
49-
if (health >= 800.0)
50-
status = "Excellent";
51-
else if (health >= 600.0)
52-
status = "Good";
53-
else if (health >= 400.0)
54-
status = "Damaged";
55-
else if (health >= 200.0)
56-
status = "Badly Damaged";
57-
else
58-
status = "Critical";
59-
60-
new msg[64];
61-
format(msg, sizeof(msg), "NPC 0 vehicle: %.1f HP - %s", health, status);
62-
SendClientMessage(playerid, 0xFFFFFFFF, msg);
39+
new Float:health;
40+
NPC_GetVehicleHealth(npcid, health);
6341

42+
SendClientMessage(playerid, 0x00FF00FF, "NPC %d vehicle health: %.2f", npcid, health);
6443
return 1;
6544
}
6645
return 0;
6746
}
6847

69-
forward MonitorVehicleHealth();
70-
public MonitorVehicleHealth()
71-
{
72-
new Float:health = NPC_GetVehicleHealth(0);
73-
74-
if (health < 300.0)
75-
{
76-
printf("Warning: NPC 0 vehicle health critical: %.1f", health);
77-
78-
// Auto-repair if too low
79-
NPC_SetVehicleHealth(0, 1000.0);
80-
printf("Auto-repaired NPC 0 vehicle");
81-
}
82-
}
8348
```
8449
8550
## Notes
8651
8752
- Returns 0.0 if the NPC is not in a vehicle
8853
- Vehicle health typically ranges from 0.0 to 1000.0
8954
- Health below 250.0 usually means the vehicle will catch fire
90-
- Only works when the NPC is the driver of the vehicle
91-
- Use this to monitor vehicle condition for maintenance or replacement
9255
9356
## Related Functions
9457

0 commit comments

Comments
 (0)