|
15 | 15 | #include <game/CTasks.h> |
16 | 16 | #include <game/TaskBasic.h> |
17 | 17 | #include <game/CAnimManager.h> |
| 18 | +#include "CLuaPedDefs.h" |
18 | 19 |
|
19 | 20 | #define MIN_CLIENT_REQ_REMOVEPEDFROMVEHICLE_CLIENTSIDE "1.3.0-9.04482" |
20 | 21 | #define MIN_CLIENT_REQ_WARPPEDINTOVEHICLE_CLIENTSIDE "1.3.0-9.04482" |
@@ -61,6 +62,7 @@ void CLuaPedDefs::LoadFunctions() |
61 | 62 | {"setPedEnterVehicle", ArgumentParser<SetPedEnterVehicle>}, |
62 | 63 | {"setPedExitVehicle", ArgumentParser<SetPedExitVehicle>}, |
63 | 64 | {"setPedBleeding", ArgumentParser<SetPedBleeding>}, |
| 65 | + {"playPedVoiceLine", ArgumentParser<PlayPedVoiceLine>}, |
64 | 66 |
|
65 | 67 | {"getPedVoice", GetPedVoice}, |
66 | 68 | {"getElementBonePosition", ArgumentParser<GetElementBonePosition>}, |
@@ -210,6 +212,7 @@ void CLuaPedDefs::AddClass(lua_State* luaVM) |
210 | 212 | lua_classfunction(luaVM, "setEnterVehicle", "setPedEnterVehicle"); |
211 | 213 | lua_classfunction(luaVM, "setExitVehicle", "setPedExitVehicle"); |
212 | 214 | lua_classfunction(luaVM, "setBleeding", "setPedBleeding"); |
| 215 | + lua_classfunction(luaVM, "playPedVoiceLine", "playVoiceLine"); |
213 | 216 |
|
214 | 217 | lua_classvariable(luaVM, "vehicle", OOP_WarpPedIntoVehicle, GetPedOccupiedVehicle); |
215 | 218 | lua_classvariable(luaVM, "vehicleSeat", NULL, "getPedOccupiedVehicleSeat"); |
@@ -2497,3 +2500,15 @@ bool CLuaPedDefs::killPedTask(CClientPed* ped, taskType taskType, std::uint8_t t |
2497 | 2500 | return false; |
2498 | 2501 | } |
2499 | 2502 | } |
| 2503 | + |
| 2504 | +void CLuaPedDefs::PlayPedVoiceLine(CClientPed* ped, int speechId, std::optional<float> probabilty) |
| 2505 | +{ |
| 2506 | + auto speechContextId = static_cast<ePedSpeechContext>(speechId); |
| 2507 | + if (speechContextId < ePedSpeechContext::NOTHING || speechContextId >= ePedSpeechContext::NUM_PED_CONTEXT) |
| 2508 | + throw LuaFunctionError("The argument speechId is invalid. The valid range is 0-359."); |
| 2509 | + |
| 2510 | + if (probabilty.has_value() && probabilty < 0.0f) |
| 2511 | + throw LuaFunctionError("The argument probabilty cannot have a negative value."); |
| 2512 | + |
| 2513 | + ped->Say(speechContextId, probabilty.value_or(1.0f)); |
| 2514 | +} |
0 commit comments