GTA: Modification Area
Would you like to react to this message? Create an account in a few clicks or log in to continue.
GTA: Modification Area

A website for the GTA modding scene

Search
 
 

Display results as :
 


Rechercher Advanced Search

Latest topics
» Big-game starts raising Schneider's profile
Transfer of functions and strings EmptySun Mar 04, 2012 2:28 am by lavivi

» [Help] cleo created lighting
Transfer of functions and strings EmptyThu Oct 14, 2010 1:03 am by findmy012

» Mission Question
Transfer of functions and strings EmptyThu Oct 14, 2010 1:02 am by findmy012

» [IV] Spoiler Script
Transfer of functions and strings EmptyThu Oct 14, 2010 1:02 am by findmy012

» Mission mod [help]
Transfer of functions and strings EmptySat Sep 18, 2010 5:50 pm by jayd00

» Bc7 Mod Help
Transfer of functions and strings EmptyFri Aug 20, 2010 11:19 am by pengpeng

» Found a bug
Transfer of functions and strings EmptyFri Dec 18, 2009 4:22 am by _CJ360_

» [IV] Novitec Rosso 599 GTB
Transfer of functions and strings EmptyTue Nov 17, 2009 4:22 pm by Kotton

» Hello/Guidance Request
Transfer of functions and strings EmptyMon Oct 12, 2009 6:45 am by Adler

Navigation
 Portal
 Index
 Memberlist
 Profile
 FAQ
 Search
Affiliates
image

Image

Image

Image

Image

Image

Image

Image

Image

Image

image

Image

steve-m.com

Image


----- Русский -----

Если ваш сайт содержит большую коллекцию SCM/CLEO-скриптов (больше 16), напишите на мой e-mail, и я добавлю его в список. Приветствуются скрипты, которые не встречаются на других сайтах ... Спасибо. ))))


----- English -----

If your website has a big enough collection of SCM/CLEO scripts (more than 16) notify me by e-mail
, and I will add it to the list. The unique scripts are preferable ... Thank you. ))))
Log in

I forgot my password



November 2024
MonTueWedThuFriSatSun
    123
45678910
11121314151617
18192021222324
252627282930 

Calendar Calendar


You are not connected. Please login or register

Transfer of functions and strings

Go down  Message [Page 1 of 1]

1Transfer of functions and strings Empty Transfer of functions and strings Fri Apr 24, 2009 11:24 am

gtasbigfoot

gtasbigfoot
Admin

To explain on how the scripts are kept in strings. There are two strings used, two types of variables: one for short strings( '...'), and the other - for long strings ( "..."). Variables are indicated by the first type s for short strings (1@s, s$str). And the symbol v for long strings (2@v, v$str1).

Now that the characters themselves are stored as strings. In other programming languages(categorically speaking non-GTA), most often, a variable of type string does not hold an entire set of letters. This variable is stored in a memory address where the letters are. String variable represents in fact a pointer to the first character string, and is, like any other pointer, 4 bytes. No matter what length of the string - 1 letter, or 500, string variable is always 4 bytes in length (in most cases).

In San Andreas strings themselves are stored in variables. As we know, there are 2 kinds of variables - local's & global's. For each of them in the memory have a certain memory area of limited size. For example, for each stream selected foreground appears 32 to 4 bytes and, consequently, the buffer memory to store the values of these variables in 128 bytes. A similar situation with a buffer of global variables (the size may vary in when compiling).

Strings are stored within the buffer variables. This means that the variable string 0@s is not a pointer to the record the first letter of the word 'MAIN', but these are characters (ASCII-code).

Let us now move on to the two types of strings - short and long (variable-length strings).

Short strings are always held in the memory of 8 bytes. In such a variable it can store up to 7 characters, inclusive, the balance is filled with zeros. It does not matter 1 letter in a row and 7, the size of a string is always 8 bytes. Thus, if you type in the variable '1@s' string 'STRING', it takes 8 bytes. Given that the letter strings are stored in the variables themselves (as explained above) and a variable can only store 4 bytes (1 letter - 1 byte), then the string will be recorded in the following order of variables: 2@.


Code:

1@ stores 'STRI', and 2@ stores 'NG'. (total = 'STRING')


With long strings it's a similar situation, with the only difference being that - they took the 4 variables (16 bytes).


Code:

1@v = "LONG_STRING" => 1@ = "LONG", 2@ = "_STR", 3@ "ING", 4@ - Keep balance (zero bytes).


Note 1@v = "MAIN" and even holds only 4 characters, but the record of such a variables values are not only 1 but 2 @ @, 3@ and 4@

16 bytes is the limit for string's variables. You can not write to a variable 1@v string length of 20 characters, as a example(it must be 16 or lower).

If you summarize, the line held in the memory of either 8 or 16 bytes (depending on the type of the string). They want to store 2 or 4 variables that are in a row (0@, 1@, $1, $2, etc...).

Now we proceed to the main. As new waves created opcode 004F, you can send numeric parameters, whose values are recorded on a new flow of local variables. (In other words new data.)


Code:

create_thread @THD 100 $ONMISSION 1@



in the stream @ the new variable 0@ is equal to 100, the value 1@ $ONMISSION, 2@ 1@ is equal to the value stream, which was caused by opcode 004F(create_thread).

And the same rule also apply's when using SCM-functions(call_scm_func):


Code:

0AB1: call_scm_func @Recalculate 1 -1.0


function Recalculate 0@ variable will be equal to -1.0.

But the standard way to convert is not the number but the string in the flow function can not be.


Code:

0AB1: call_scm_func @EndThread 1 'NAME'


('NAME' meaning the name of the thread to end.)
But there is another way. Recall that the string is stored in variables. The line - a collection of letters, which are in fact numbers. We can save the string in a variable string and send it by parts, like this:


Code:

0@s = 'NAME'
0AB1: call_scm_func @EndThread 2 0@ 1@



... and functions use the line through string variables:


Code:

:EndThread
0459: end_thread_named 0@s
0AB2: ret 0


For long string is similar, but we must send a value of 4 variables:


Code:

0@v = "SNEAKERBINCBLK" // 0@..3@
4@v = "SNEAKER" // 4@..7@
8@ = 3
0AB1: call_scm_func @SetClothes 9 0@ 1@ 2@ 3@ 4@ 5@ 6@ 7@ 8@ // pass 2 strings


And so you can set the function, then return from the main.scm function using the brother opcode of 00b1, (0AB2: ret 0) - this opcode is required when using opcode 00b1.


Code:

:SetClothes
087B: set_player $PLAYER_CHAR clothes_texture 0@v model 4@v body_part 8@
0AB2: ret 0


Perhaps to fully understand this clearly you will need a bit of experience in programming as well as imagination. It is important to understand the principles of storing strings in memory, if you do, it all becomes very clear.
______


  • Questions can be asked in this topic.
  • For questions about using SCM-functions, please, create your own topic regarding help. Grin Smile
  • Questions of memory handling can be posted in the SA Memory Example Topic.


Related posts



http://gtamodding.com

Back to top  Message [Page 1 of 1]

Similar topics

-

» San Andreas Strings

Permissions in this forum:
You cannot reply to topics in this forum