Difference between revisions of "009A"

From GTAMods Wiki
Jump to navigation Jump to search
Line 1: Line 1:
{{Icon|trilogy}}
+
{{OpCode
<hr />
+
| games      = {{Icon|t}}
'''Description'''
+
| command    = CREATE_CHAR
: Spawns a character at a point
+
| description = Creates a character at the coordinates point
'''Syntax'''
+
| syntax1    = 009A: [''var''] = create_actor [''int1''] [''int2''] at [''flt1''] [''flt2''] [''flt3'']
: 009A: [''var''] = create_actor [''int1''] [''int2''] at [''flt1''] [''flt2''] [''flt3'']
+
| syntax2    = Actor.Create( [''var''], [''int1''], [''int2''], [''flt1''], [''flt2''], [''flt3''] )
: Actor.Create( [''var''], [''int1''], [''int2''], [''flt1''], [''flt2''], [''flt3''] )
+
| p1t        = [''var'']
'''Parameter'''
+
| p1d        = Variable to store the handle of the character
: [''var'']
+
| p2t        = [''int1'']
:: Variable to store the handle of the character
+
| p2d        = [[Ped type]]
: [''int1'']
+
| p3t        = [''int2'']
:: [[Ped type]]
+
| p3d        = Valid character model ID number as defined in the [[PEDS|PEDS section]] of the [[IDE]] file; also acceptable is model's [[DFF]] name with a hash character
: [''int2'']
+
| p4t        = [''flt1'']
:: Valid character model ID number as defined in the [[PEDS|PEDS section]] of the [[IDE]] file; also acceptable is model's [[DFF]] name with a hash character
+
| p4d        = X-coordinate
: [''flt1'']
+
| p5t        = [''flt2'']
:: X-coordinate
+
| p5d        = Y-coordinate
: [''flt2'']
+
| p6t        = [''flt3'']
:: Y-coordinate
+
| p6d        = Z-coordinate
: [''flt3'']
+
| native      = [[CREATE_CHAR]]
:: Z-coordinate
+
}}
'''Native analog'''
 
: [[CREATE_CHAR]]
 
  
This spawns a character at a point. Using this opcode requires the model to be loaded through opcode [[0247]] or else the game might crash. The major script editors like [[Sanny Builder]] support using the character's DFF model name and automatically converts those values into integers upon compilation. Once spawned, the character will be permanent in the game even after it dies or after you die or get busted. If you no longer need your character anymore, you could turn it into a random ped using opcode [[01C2]] or destroy it instantly using opcodes [[009B]] or [[034F]].
+
This opcode creates a character at the coordinates point. Using this opcode requires the model to be already loaded, usually through opcode [[0247]], or else the game can crash. The major script editors like [[Sanny Builder]] support using the character's DFF model name and automatically converts it to the corresponding model ID number upon compilation. All characters created by this opcode outside the [[Create a mission|standard mission structure]] will become near-permanent in the game until opcode [[01C2]] is used to mark it as no longer needed or removed from the world through other means like [[009B]] or [[034F]].
  
 
== Example ==
 
== Example ==
 
:''See also: [[Spawn a ped]]''
 
:''See also: [[Spawn a ped]]''
 
The following example, using Sanny Builder, will spawn a ped close to the player character.
 
The following example, using Sanny Builder, will spawn a ped close to the player character.
<source lang="scm">
+
<syntaxhighlight lang="scm">
 
// set constants
 
// set constants
 
const
 
const
Line 55: Line 53:
 
0249: release_model CHAR_MODEL
 
0249: release_model CHAR_MODEL
 
01C2: remove_references_to_actor CHAR_HANDLE
 
01C2: remove_references_to_actor CHAR_HANDLE
</source>
+
</syntaxhighlight>
  
 
== Special Peds ==
 
== Special Peds ==
Line 95: Line 93:
 
</source>
 
</source>
  
==Keywords==
+
== Keywords ==
 
create, spawn, actor, ped, pedestrian, pedtype, model, character
 
create, spawn, actor, ped, pedestrian, pedtype, model, character
  
 
__NOTOC__
 
__NOTOC__
 
[[Category:OpCodes]]
 

Revision as of 22:02, 26 January 2016

GTA III Vice City San Andreas CREATE_CHAR


Description
Creates a character at the coordinates point
Syntax
009A: [var] = create_actor [int1] [int2] at [flt1] [flt2] [flt3]
Actor.Create( [var], [int1], [int2], [flt1], [flt2], [flt3] )
Parameter
[var]
Variable to store the handle of the character
[int1]
Ped type
[int2]
Valid character model ID number as defined in the PEDS section of the IDE file; also acceptable is model's DFF name with a hash character
[flt1]
X-coordinate
[flt2]
Y-coordinate
[flt3]
Z-coordinate
Native analog
CREATE_CHAR

This opcode creates a character at the coordinates point. Using this opcode requires the model to be already loaded, usually through opcode 0247, or else the game can crash. The major script editors like Sanny Builder support using the character's DFF model name and automatically converts it to the corresponding model ID number upon compilation. All characters created by this opcode outside the standard mission structure will become near-permanent in the game until opcode 01C2 is used to mark it as no longer needed or removed from the world through other means like 009B or 034F.

Example

See also: Spawn a ped

The following example, using Sanny Builder, will spawn a ped close to the player character.

// set constants
const
CHAR_MODEL = #BFORI
CHAR_HANDLE = 0@
X_POS = 1@
Y_POS = 2@
Z_POS = 3@
end

// load model, required to prevent unnecessary crash!
0247: request_model CHAR_MODEL
// check if model is loaded
repeat
    wait 0
    if
        0248:   model CHAR_MODEL available
    then
        break
    end
until false
// spawn character
00A0: store_actor $PLAYER_ACTOR position_to X_POS Y_POS Z_POS
X_POS += 4.0
009A: CHAR_HANDLE = create_actor 4 CHAR_MODEL at X_POS Y_POS Z_POS
// cleanup
0249: release_model CHAR_MODEL
01C2: remove_references_to_actor CHAR_HANDLE

Special Peds

Special peds uses models SPECIAL#.dff, where # is a number from 01 to 04 in GTA3, 01 to 21 in Vice City, and 01 to 10 in San Andreas. It is used in conjunction with 023C. The special actor ID number corresponds to the number in SPECIAL#.dff. You do not have to load SPECIAL#.dff as it is always loaded into the game. Each special actor ID can accommodate only one special ped at a time and can be replaced by another special ped if the other special ped has the same ID.

In GTA 3 and Vice City, every special actor number is used at least once. In San Andreas, the game actively uses special actor numbers 1 to 5 while the rest is not actively used in the game.

Example

Loading special peds is similar to loading regular peds. The following example, using Sanny Builder, will spawn a special ped close to the player character.

// set constants
const
CHAR_HANDLE = 0@
X_POS = 1@
Y_POS = 2@
Z_POS = 3@
end

// assign special model to slot
023C: load_special_actor 1 'PLAYER'  // GTA III and Vice City only
// 023C: load_special_actor 'ANDRE' as 1  // uncomment for SA
// check if model in slot is available
repeat
    wait 0
    if
        023D:   special_actor 1 loaded
    then
        break
    end
until false
// spawn character
00A0: store_actor $PLAYER_ACTOR position_to X_POS Y_POS Z_POS
X_POS += 4.0
009A: CHAR_HANDLE = create_actor_pedtype 21 model #SPECIAL01 at X_POS Y_POS Z_POS  // GTA III and Vice City only
// 009A: CHAR_HANDLE = create_actor_pedtype 23 model #SPECIAL01 at X_POS Y_POS Z_POS  // uncomment for SA
// cleanup
0296: unload_special_actor 1
01C2: remove_references_to_actor CHAR_HANDLE

Keywords

create, spawn, actor, ped, pedestrian, pedtype, model, character