跳至主要内容

NPC_StartPlayback

注意

This function was added in omp v1.5.8.3079 and will not work in earlier versions!

Description

Starts playing a recording file for an NPC by filename.

NameDescription
npcidThe ID of the NPC
recordName[]The filename of the recording to play
autoUnloadWhether to unload the recording when finished
startXStarting X coordinate
startYStarting Y coordinate
startZStarting Z coordinate
rotXStarting X rotation
rotYStarting Y rotation
rotZStarting Z rotation

Returns

Returns true if the playback was started successfully, false otherwise.

Examples

public OnPlayerCommandText(playerid, cmdtext[])
{
if (!strcmp(cmdtext, "/startplayback ", true, 15))
{
new npcid = PlayerNPC[playerid];
if (npcid == INVALID_NPC_ID)
return SendClientMessage(playerid, 0xFF0000FF, "You are not debugging a NPC.");

if (!NPC_IsValid(npcid))
return SendClientMessage(playerid, 0xFF0000FF, "Invalid NPC.");

new recordName[64];
new len = strlen(cmdtext);
if (len <= 15)
return SendClientMessage(playerid, 0xFF0000FF, "Usage: /startplayback [recordname]");

strmid(recordName, cmdtext, 15, len);

new Float:x, Float:y, Float:z;
NPC_GetPos(npcid, x, y, z);

new bool:success = NPC_StartPlayback(npcid, recordName, true, x, y, z, 0.0, 0.0, 0.0);

if (success)
SendClientMessage(playerid, 0x00FF00FF, "NPC %d started playback: %s", npcid, recordName);
else
SendClientMessage(playerid, 0xFF0000FF, "Failed to start playback for NPC %d", npcid);

return 1;
}
return 0;
}

Notes

  • The recording file must exist in the npcmodes\recordings directory
  • If autoUnload is true, the recording is unloaded when playback ends
  • Use NPC_StartPlaybackEx for better control with pre-loaded recordings