Difference between revisions of "004F"

From GTAMods Wiki
Jump to navigation Jump to search
(page updates)
Line 1: Line 1:
{{Icon|trilogy}} '''START_NEW_SCRIPT'''
+
{{OpCode
<hr />
+
| games      = {{Icon|t}}
'''Description'''
+
| command    = START_NEW_SCRIPT
: Creates a new thread
+
| description = Starts a [[Create a script|new script]]
'''Syntax'''
+
| syntax1    = 004F: create_thread [''label''] ( [''any'']
: 004F: create_thread [''offset''] [''params'']
+
| syntax2    = create_thread [''label''] ( [''any'']
: create_thread [''offset''] [''params'']
+
| p1t        = [''label'']
'''Parameter'''
+
| p1d        = The position in the script it will go to, usually identified by a [[label]]
: ''offset''
+
| p2t        = [''any'']
:: The position in the script from where the thread is started, usually identified by a [[label]]  
+
| p2d        = Parameters if there are ones (optional), up to 16+2 for GTA III and Vice City, 32+2 for San Andreas
: ''params''
+
| native      = [[START_NEW_SCRIPT]]
:: optional integer or float parameters
+
}}
'''Native analog'''
 
: [[START_NEW_SCRIPT]]
 
  
This creates a new [[thread]], which begins an execution from the position in the <code>[[main.scm]]</code> identified by a label or an integer value.
+
This opcode starts a new script and begins an execution from the label. It has a variable number of parameters. The first parameter of the opcode is required, with extra parameters depending on the scripter needs. The extra parameters set the values of the local variables of the new script. The first extra parameter (the second parameter of the opcode) sets the value for the new script's local variable <span style="color:blue">0@</span>, the second extra parameter sets the value for <span style="color:blue">1@</span>, and so forth. The total number of extra parameters varies from game to game: 16+2 for GTA III and Vice City, 32+2 for San Andreas. Opcodes [[004E]] or [[0459]] can be used to terminate the scripts. This opcode is similar to opcode [[00D7]] but the latter has only one parameter, without extra ones.
  
This opcode has a variable number of parameters. The first parameter of the opcode is required, extra parameters depends on the scripter needs. The point is, the extra parameters set the values of the local variables of the new thread. The first extra parameter (the second one in the opcode) sets the value for the local variable 0@, the second extra parameter sets the value for 1@ and so forth. A total number of extra parameters varies from game to game: 16+2 for GTA 3 and Vice City, 32+2 for San Andreas.
+
== Example ==
 
+
<syntaxhighlight lang="scm">
To end the thread execution and free the memory use [[004E]] or [[0459]].
 
 
 
This opcode is similar to the opcode [[00D7]] but the latter has only one parameter, without extra ones.
 
 
 
==Example==
 
<source lang="scm">
 
 
$VAR = 10
 
$VAR = 10
 
004F: create_thread @MONEY 10 $VAR
 
004F: create_thread @MONEY 10 $VAR
Line 37: Line 29:
 
:EXIT
 
:EXIT
 
004E: end_thread
 
004E: end_thread
</source>
+
</syntaxhighlight>
 
When the game starts, it will execute this code and the player will receive 10 dollars.
 
When the game starts, it will execute this code and the player will receive 10 dollars.
  
==Keywords==
+
== Keywords ==
 
thread, script, create, start
 
thread, script, create, start
  
==See also==
+
== See also ==
* [[00D7]] &ndash; starts a new script with no parameters
 
* [[0417]] &ndash; launches a mission
 
* [[0A92]] &ndash; starts a new [[CLEO]] script
 
 
* [[Create a thread]]
 
* [[Create a thread]]
 
+
* {{Icon|t}} [[00D7]], starts a new script with no parameters
[[Category:OpCodes]]
+
* {{Icon|t}} [[0417]], launches a mission
 +
* {{Icon|t}} [[0A92]], starts a new [[CLEO]] script

Revision as of 06:26, 27 January 2016

GTA III Vice City San Andreas START_NEW_SCRIPT


Description
Starts a new script
Syntax
004F: create_thread [label] ( [
create_thread [label] ( [
Parameter
[label]
The position in the script it will go to, usually identified by a label
[any]
Parameters if there are ones (optional), up to 16+2 for GTA III and Vice City, 32+2 for San Andreas
Native analog
START_NEW_SCRIPT

This opcode starts a new script and begins an execution from the label. It has a variable number of parameters. The first parameter of the opcode is required, with extra parameters depending on the scripter needs. The extra parameters set the values of the local variables of the new script. The first extra parameter (the second parameter of the opcode) sets the value for the new script's local variable 0@, the second extra parameter sets the value for 1@, and so forth. The total number of extra parameters varies from game to game: 16+2 for GTA III and Vice City, 32+2 for San Andreas. Opcodes 004E or 0459 can be used to terminate the scripts. This opcode is similar to opcode 00D7 but the latter has only one parameter, without extra ones.

Example

$VAR = 10
004F: create_thread @MONEY 10 $VAR
 ...
 ...
:MONEY
03A4: name_thread 'MONEY'
00D6: if 0
003B:   0@ == 1@
004D: jump_if_false @EXIT
0109: player $PLAYER_CHAR money += 0@
  
:EXIT
004E: end_thread

When the game starts, it will execute this code and the player will receive 10 dollars.

Keywords

thread, script, create, start

See also