DestroyNPC: Difference between revisions
From Onset Developer Wiki
Created page with "{{Info|Function|Server|1.0}} {{FuncDescription|__EDIT_ME__}} {{FuncSyntax|DestroyNPC(npc)}} {{FuncParameters}} {{FuncParam|npc|__EDIT_ME__}} {{FuncReturnValue|__EDIT_ME__}..." |
No edit summary |
||
(2 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
{{Info|Function|Server|1.0}} | {{Info|Function|Server|1.0}} | ||
{{FuncDescription| | {{FuncDescription|Destroy/remove any NPC by its identifier.}} | ||
{{FuncSyntax|DestroyNPC(npc)}} | {{FuncSyntax|DestroyNPC(npc)}} | ||
{{FuncParameters}} | {{FuncParameters}} | ||
{{FuncParam|npc| | {{FuncParam|npc|NPC You want to destroy/remove}} | ||
{{FuncReturnValue| | {{FuncReturnValue|Returns '''true''' on success.}} | ||
== Example == | == Example == | ||
<syntaxhighlight lang="Lua"> | |||
function deleteNPC(player, npc) | |||
if IsValidNPC(tonumber(npc)) then --Check if npc is valid first | |||
DestroyNPC(tonumber(npc)) | |||
end | |||
end | |||
AddCommand('removenpc', deleteNPC) | |||
</syntaxhighlight> | |||
{{RelatedFunctions}} | {{RelatedFunctions}} | ||
* [[CreateNPC]] | |||
* [[IsValidNPC]] |
Latest revision as of 15:27, 17 November 2019
Description
Destroy/remove any NPC by its identifier.
Syntax
DestroyNPC(npc)
Parameters
- npc
NPC You want to destroy/remove
Return Value
- Returns true on success.
Example
function deleteNPC(player, npc)
if IsValidNPC(tonumber(npc)) then --Check if npc is valid first
DestroyNPC(tonumber(npc))
end
end
AddCommand('removenpc', deleteNPC)