SetObjectModel: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
 
(8 intermediate revisions by 6 users not shown)
Line 1: Line 1:
__NOTOC__  
__NOTOC__  
{{Deprecated|setElementModel}}
This sets a new object model to the specified element.
This sets a new object model to the specified element.


==Syntax==  
==Syntax==  
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
bool setObjectModel ( element object, int id )         
bool setObjectModel ( object theObject, int id )         
</syntaxhighlight>  
</syntaxhighlight>  


===Required Arguments===  
===Required Arguments===  
*'''object:''' A valid [[element]].
*'''theObject:''' A valid [[object]].
*'''id:''' An [[int]] specifying the model id.
*'''id:''' An [[int]] specifying the model id.


Line 15: Line 17:


==Example==  
==Example==  
This example does...
<section name="Server" class="server" show="true">
This will continually change an object model every 2.5 seconds at the location -1084.52, -1634.81, 76.36 (Truth's farm).
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
--This line does...
myobject = createObject ( 5822, -1084.52, -1634.81, 76.36 )
blabhalbalhb --abababa
-- We create an initial object element. I choose object model 5822 to begin with.
--This line does this...
 
mooo
function objectRandomization () 
</syntaxhighlight>
    local randomobjectnumber = math.random(1, 18000)
    -- Choose a random number between 1 and 18000 as a whole integer and assign it to
    -- the variable 'randomobjectnumber'
    setObjectModel ( myobject, randomobjectnumber )
    -- Change our object appearance by applying a new model ID
end
 
setTimer ( objectRandomization, 2500, 0 )
-- Every 2.5 seconds, the function 'objectRandomization' is called by this timer.
-- Each time the function runs, it changes the object model by applying a new whole-
-- integer random object ID. This timer is called an infinite amount of times since 
-- its repeat value is set to 0.
</syntaxhighlight> </section>


==See Also==
==See Also==
{{Object functions}}
{{Object functions}}
[[Category:Incomplete]]
{{Server function}}

Latest revision as of 09:12, 9 November 2018


Emblem-important.png This function is deprecated. This means that its use is discouraged and that it might not exist in future versions.

Please use setElementModel instead.


This sets a new object model to the specified element.

Syntax

bool setObjectModel ( object theObject, int id )        

Required Arguments

  • theObject: A valid object.
  • id: An int specifying the model id.

Returns

Returns true if the model change was successful, false otherwise.

Example

Click to collapse [-]
Server

This will continually change an object model every 2.5 seconds at the location -1084.52, -1634.81, 76.36 (Truth's farm).

myobject = createObject ( 5822, -1084.52, -1634.81, 76.36 )
-- We create an initial object element. I choose object model 5822 to begin with.

function objectRandomization ()  
    local randomobjectnumber = math.random(1, 18000)
    -- Choose a random number between 1 and 18000 as a whole integer and assign it to
    -- the variable 'randomobjectnumber'
    setObjectModel ( myobject, randomobjectnumber )
    -- Change our object appearance by applying a new model ID
end

setTimer ( objectRandomization, 2500, 0 )
-- Every 2.5 seconds, the function 'objectRandomization' is called by this timer.
-- Each time the function runs, it changes the object model by applying a new whole-
-- integer random object ID. This timer is called an infinite amount of times since  
-- its repeat value is set to 0.

See Also