跳到主要內容

NPC_Shoot

注意

此函式於 omp v1.5.8.3079 版本中新增,在更早的版本中無法使用!

Description​

Makes an NPC fire a weapon shot.

NameDescription
npcidThe ID of the NPC
weaponThe weapon ID to use for shooting
hitIdThe ID of the target entity being shot
hitTypeThe type of entity being hit (player, NPC, vehicle, etc.)
endPointXX coordinate of the bullet end point
endPointYY coordinate of the bullet end point
endPointZZ coordinate of the bullet end point
offsetXX offset from the hit point
offsetYY offset from the hit point
offsetZZ offset from the hit point
isHitWhether the shot actually hits the target
checkInBetweenFlagsEntity check flags (default: NPC_ENTITY_CHECK_ALL)

Returns​

Returns true if the operation was successful, false otherwise.

Examples​

public OnPlayerCommandText(playerid, cmdtext[])
{
if (!strcmp(cmdtext, "/npcshoot", true))
{
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 Float:x, Float:y, Float:z;
GetPlayerPos(playerid, x, y, z);

new weapon = NPC_GetWeapon(npcid);
NPC_Shoot(npcid, WEAPON:weapon, playerid, 1, x, y, z, 0.0, 0.0, 0.0, true, NPC_ENTITY_CHECK_ALL);

SendClientMessage(playerid, 0x00FF00FF, "NPC %d fired a shot at you.", npcid);
return 1;
}
return 0;
}

Notes​

  • The NPC must have a weapon set with NPC_SetWeapon before shooting
  • Use isHit = false for warning shots or suppression fire
  • The checkInBetweenFlags parameter determines what entities block the shot