CreateObject: Difference between revisions

From Onset Developer Wiki
No edit summary
No edit summary
 
(2 intermediate revisions by one other user not shown)
Line 7: Line 7:
{{FuncParameters}}
{{FuncParameters}}
{{FuncParam|modelid|The [[Objects|model identifier]] for which object to spawn.}}
{{FuncParam|modelid|The [[Objects|model identifier]] for which object to spawn.}}
{{FuncParam|x|__EDIT_ME__}}
{{FuncParam|x|X coordinate}}
{{FuncParam|y|__EDIT_ME__}}
{{FuncParam|y|Y coordinate}}
{{FuncParam|z |__EDIT_ME__}}
{{FuncParam|z|Z coordinate}}
{{FuncParam|rx|__EDIT_ME__}}
{{FuncParamOptional|rx|Pitch}}
{{FuncParam|ry|__EDIT_ME__}}
{{FuncParamOptional|ry|Yaw}}
{{FuncParam|rz|__EDIT_ME__}}
{{FuncParamOptional|rz|Roll}}
{{FuncParam|sx|__EDIT_ME__}}
{{FuncParamOptional|sx|X scale}}
{{FuncParam|sy|__EDIT_ME__}}
{{FuncParamOptional|sy|Y scale}}
{{FuncParamOptional|sz|__EDIT_ME__}}
{{FuncParamOptional|sz|Z scale}}


{{FuncReturnValue|Returns an identifier to the new object. '''false''' on error.}}
{{FuncReturnValue|Returns an identifier to the new object. '''false''' on error.}}


== Example ==
== Example ==
__EDIT_ME__
<syntaxhighlight lang="Lua">
function cmd_objtest(player)
local x, y, z = 64151.0234375, 48423.33984375, 4516.530273
 
for c=1,50 do
for r=1,50 do
CreateObject(592, x + (c * 350.0), y + (r * 350.0), z)
end
end
end
AddCommand("objtest", cmd_objtest)
</syntaxhighlight>


{{RelatedFunctions}}
{{RelatedFunctions}}
{{ObjectFunctions}}
{{ObjectFunctions}}

Latest revision as of 14:47, 12 August 2019

CreateObject

Type: Function
Context: Server
Introduced: v1.0

Description

This function creates an object at a desired location. See Objects for a list of models.

Syntax

CreateObject(modelid, x, y, z [, rx, ry, rz, sx, sy, sz])

Parameters

  • modelid
    The model identifier for which object to spawn.
  • x
    X coordinate
  • y
    Y coordinate
  • z
    Z coordinate
  • rx (optional)
    Pitch
  • ry (optional)
    Yaw
  • rz (optional)
    Roll
  • sx (optional)
    X scale
  • sy (optional)
    Y scale
  • sz (optional)
    Z scale

Return Value

  • Returns an identifier to the new object. false on error.

Example

function cmd_objtest(player)
	local x, y, z = 64151.0234375, 48423.33984375, 4516.530273

	for c=1,50 do
		for r=1,50 do
			CreateObject(592, x + (c * 350.0), y + (r * 350.0), z)
		end
	end
end
AddCommand("objtest", cmd_objtest)

See also