Difference between revisions of "004F"

From GTAMods Wiki
Jump to navigation Jump to search
m (Example)
m
 
(4 intermediate revisions by 2 users not shown)
Line 1: Line 1:
<code>004F=-1,%1p%</code><br>
+
{{OpCode
'''Description''': Creates a new thread<br>
+
| games      = {{Icon|t}}
'''Parameter 1''': [[Label]]<br>
+
| command    = START_NEW_SCRIPT
'''+extra parameters'''<br>
+
| description = Starts a [[Create a script|new script]]
'''Supports''': GTA3, Vice City, San Andreas<br>
+
| syntax1    = 004F: create_thread [''label''] ( [''any''] &hellip; )
 +
| syntax2    = create_thread [''label''] ( [''any''] &hellip; )
 +
| p1t        = [''label'']
 +
| p1d        = The position in the script it will go to, usually identified by a [[label]]
 +
| p2t        = ( [''any''] &hellip; )
 +
| p2d        = Optional parameters in any data type, up to 16+2 for GTA III and Vice City, 32+2 for San Andreas
 +
| native      = [[START_NEW_SCRIPT]]
 +
}}
  
This opcode creates a new [[thread]]. It begins an execution from the place marked by the label passed as the parameter.<br>
+
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.
The distinctive feature of this opcode is that it has various number of the parameters. The first parameter (a label) must be always, extra parameters depends on the scripter needs. The aim of using of the extra parameters is to set the values of the local variables of the created thread. The first extra parameter (the second in the opcode) sets the value for the variable 0@, the second extra parameters set the one for 1@ and so on. Total possible number of extra parameters depends on the local variables number for the game: 16+2 for GTA3 and VC, 32+2 for SA. This opcode is similar to opcode [[00D7]] but with only one parameter, without extra ones.
 
  
==Example==
+
== Example ==
<source lang="scm">
+
The following script, using Sanny Builder, will add $10 to the player when the script is started.
$VAR = 10
+
 
004F: create_thread @MONEY 10 $VAR
+
{{Pre|class=sb-code|1=
 +
<span class="nv">$VAR</span> = <span class="m">10</span>
 +
004F: <span class="k">create_thread</span> <span class="nl">@MONEY</span> <span class="m">10</span> <span class="nv">$VAR</span>
 
  ...
 
  ...
 
  ...
 
  ...
:MONEY
+
<span class="nl">:MONEY</span>
03A4: name_thread 'MONEY'
+
[[03A4]]: name_thread <span class="s1">'MONEY'</span>
00D6: if 0
+
<span class="k">if</span>
003B:  0@ == 1@
+
    [[003B]]<span class="nv">0@</span> == <span class="nv">1@</span>
004D: jump_if_false @EXIT
+
<span class="k">then</span>
0109: player $PLAYER_CHAR money += 0@
+
    [[0109]]: player <span class="nv">$PLAYER_CHAR</span> money += <span class="nv">0@</span>
 
+
<span class="k">end</span>
:EXIT
+
[[004E]]: <span class="k">end_thread</span>
004E: end_thread
+
}}
</source>
 
When the game starts, it will execute this code and the player will receive 10 dollars.
 
 
 
==Keywords==
 
thread, create
 
  
==See also==
+
== Keywords ==
[[Create a thread]]
+
thread, script, create, start
  
{{SA-navi}}
+
== See also ==
[[Category:OpCodes]]
+
* [[Create a script]]
 +
* {{Icon|t}} [[00D7]], starts a new script with no parameters
 +
* {{Icon|t}} [[0417]], launches a mission
 +
* {{Icon|t}} [[0A92]], starts a new [[CLEO]] script

Latest revision as of 02:26, 6 December 2016

GTA III Vice City San Andreas START_NEW_SCRIPT


Description
Starts a new script
Syntax
004F: create_thread [label] ( [any] … )
create_thread [label] ( [any] … )
Parameter
[label]
The position in the script it will go to, usually identified by a label
( [any] … )
Optional parameters in any data type, 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

The following script, using Sanny Builder, will add $10 to the player when the script is started.

$VAR = 10
004F: create_thread @MONEY 10 $VAR
 ...
 ...
:MONEY
03A4: name_thread 'MONEY'
if
    003B:   0@ == 1@
then
    0109: player $PLAYER_CHAR money += 0@
end
004E: end_thread

Keywords

thread, script, create, start

See also