- DeadstrokeScripter CLEO - Intermediário
- Mensagens : 529
Reputação : 42
Desde : 08/02/2016
Localização : São Paulo
- PROBLEMA:
- Olá pessoal, tenho um problema complicação de conversão de mods de SCM para GTA3Script. Fiz o Realistic Weapons Settings com o SCM script e estou querendo, pelo menos ainda, pegasr alguns recursos para o GTA3Script. Mas não consigo converter o leitor que fiz com a grande ajuda do Pep_Legal (autor do SAAS e Truck & Trailers) de SCMscript para GTA3Script.
Acredito que o maior problema esteja quando uso o SCAN_STRING, que não consegue ler a string na variável que uso, tanto com o pointer numa thread memory quanto usando o ALLOCATE_MEMORY.
Agradecido para quem ajudar, acho até que é bom essa função para outros autores fazerem mods mais complexos e interessantes.- SCM script:
- Código:
//START: save weapon values
:scmfunc_SavingWeaponsValues
const
_MOD_SAVING_ = 0@
ARRAY_SAVING = 1@
TEMP_1I = 2@
TEMP_2V = 3@
TEMP_3I = 7@
TEMP_4V = 8@
REMAINDER = 12@
TH_MEM_LIST = 13@
FILE_WEAP_INI = 14@
COUNTER = 15@
//16@ to 19@ free
WEAP_NUMB = 20@
MUN_LIM_LIMITED = 21@
MUN_LIM_CHEC = 22@
MUN_LIM_AMOUNT = 23@
RECHARGEABLE = 24@
RELOAD_CURR_AMMO = 25@
MANUAL_FIRE = 26@
//27@ to 30@ free
BUFFER_INDEX = 31@
BUFFER_HANDLE = 33@(BUFFER_INDEX,1v)
end
var
TEMP_1I : int
TEMP_3I : int
REMAINDER : int
BUFFER_INDEX : int = 0
BUFFER_HANDLE : ARRAY 1 of LONGSTRING //any array will do
end
//----------------------------------------------------------------------------------------------------------
_MOD_SAVING_ = 1
:label_PrepareBuffer
//Prepare Buffer
0AC7: TEMP_1I = var 33@ offset // get the pointer to the last usable variable
0AC6: TEMP_2V = label @Buffer_128 offset // get the pointer to the thread area to store the new variables data
0A8F: TEMP_3I = TEMP_2V - TEMP_1I // get the offset from variable 33@ to the memory
BUFFER_INDEX = TEMP_3I
0016: BUFFER_INDEX /= 16 // this index is a long-string index, so 16 bytes
0B14: REMAINDER = TEMP_3I mod 16 //Rest of division!!!!
//Read Ini File
0A9A: FILE_WEAP_INI = openfile "cleo\RWS_Weapons.ini" mode "rt"
//Preparing Counter
COUNTER = 0 //Counter can be used in mod 1 (counter of lines) or mod 2 (counter of values that will be saved)
//---------------------------------------------------------------------------------------------------------
:label_ReadINIfile
if 0AD7: read_string_from_file FILE_WEAP_INI to BUFFER_HANDLE size 128 // read a line of text from INI file
then
0AC6: TEMP_2V = label @Buffer_128 offset // pointer to Buffer (which has the read text line)
0062: TEMP_2V -= REMAINDER // compensate address offset bettween BUFFER_HANDLE and Buffer
0085: TEMP_4V = TEMP_2V // preserve beggining address of buffer
// scan Buffer looking for ":" in the text line
for TEMP_1I = 0 to 15
0A8D: TEMP_3I = read_memory TEMP_2V size 1 virtual_protect 0
if or
TEMP_3I == 0x3A // ":"
TEMP_3I == 0x00 // end of text
then Break
end
TEMP_2V += 1
end
// Did we find ":"?
if TEMP_3I == 0x3A
jf jump @label_ReadINIfile
//Getting values
0A8C: write_memory TEMP_2V size 1 value 0 virtual_protect 0 //put a zero at the end of filename segment...so buffer will behave like a null terminated string
0AD4: TEMP_1I = scan_string TEMP_4V format '%d%s' store_num_results_to WEAP_NUMB TEMP_2V //read file name
if and
WEAP_NUMB >= 0
not WEAP_NUMB > 999
then
TEMP_2V += 1 //advance one byte (prepare to read the rest of the buffer)
0AD4: TEMP_1I = scan_string TEMP_2V format '%d%d%d%d%d%d' store_num_results_to MUN_LIM_CHEC MUN_LIM_LIMITED MUN_LIM_AMOUNT RECHARGEABLE RELOAD_CURR_AMMO MANUAL_FIRE
0A8E: TEMP_3I = WEAP_HOWMANY_INFOS + -1
if 0039: TEMP_1I == TEMP_3I
then
//Checking values and standarding them
if _MOD_SAVING_ == 2
then
//Standarding values
if and
not MUN_LIM_CHEC == 1
not MUN_LIM_CHEC == 2
then MUN_LIM_CHEC = 0
end
if not MUN_LIM_LIMITED == 2
then MUN_LIM_LIMITED = 1
end
if not MUN_LIM_AMOUNT >= 0
then MUN_LIM_CHEC = -1
end
if not RECHARGEABLE == 1
then RECHARGEABLE = 0
end
if not RELOAD_CURR_AMMO == 0
then RELOAD_CURR_AMMO = 1
end
if not MANUAL_FIRE == 1
then MANUAL_FIRE = 0
end
//Save values
For TEMP_1I = 0 to TEMP_3I
0AB1: call_scm_func @SET_VAR_TO_ARRAY 3 array ARRAY_SAVING index COUNTER set_var WEAP_NUMB(TEMP_1I,1i)
COUNTER += 1
end
//Counting one more line
else COUNTER += 1
end
0000: //Avoid Crash!
end
end
jump @label_ReadINIfile
end
//----------------------------------------------------------------------------------------------------------
//If the mod is 1 (counting lines)
if _MOD_SAVING_ == 1
then
//Saving lines qunatity
0AC6: TEMP_1I = label @Buffer_Infos offset
0A8E: TEMP_1I = TEMP_1I + 76 //Th_Mem_Infos/Number of weapon in RWS_Weapons.ini
0A8C: write_memory TEMP_1I size 4 value COUNTER virtual_protect 0
//Creating array for weapons
COUNTER *= WEAP_HOWMANY_INFOS
0AB1: call_scm_func @CREATE_ARRAY 1 size COUNTER handle_to ARRAY_SAVING
_MOD_SAVING_ = 2
jump @label_PrepareBuffer
end
0000: //Avoid Crashes!
0AB2: ret 1 ARRAY_SAVING 0
//END: save weapon values
//===================================================================================================================================
:CREATE_ARRAY
0A90: 2@ = 4 * 0@ // 4 * size
0AC8: 1@ = allocate_memory_size 2@
0AB2: ret 1 1@
//-------------------------------------------------------------------------------------------------------------
:DESTROY_ARRAY
0AC9: free_allocated_memory 0@
0AB2: ret 0 0
//-------------------------------------------------------------------------------------------------------------
:SET_VAR_TO_ARRAY
0A90: 3@ = 4 * 1@ // 4 * size
0A8E: 4@ = 0@ + 3@ // Buffer + offset
0A8C: write_memory 4@ size 4 value 2@ virtual_protect 0
0AB2: ret 0 0
//-------------------------------------------------------------------------------------------------------------
:GET_VAR_TO_ARRAY
0A90: 3@ = 4 * 1@ // 4 * size
0A8E: 4@ = 0@ + 3@ // Buffer + offset
0A8D: 2@ = read_memory 4@ size 4 virtual_protect 0
0AB2: ret 1 2@ 0
//===================================================================================================================================
:scmfunc_UselessLabel
0000: avoid crashes!
0AB2: ret 0 0 0
//===================================================================================================================================
//===================================================================================================================================
:Buffer_128
hex
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
end
//===================================================================================================================================
- GTA3Script Código:
- Código:
//Functions: read and save RWS_Weapons
{
//Local vars and constatns
LVAR_INT buffer_index
LVAR_INT buffer_now
LVAR_INT tempi_1 tempi_2
LVAR_INT file_ini
LVAR_INT counter
LVAR_INT saving_mod // 0 -> read; 1 -> save
LVAR_INT weap_infos[7]
LVAR_INT memory_weapon_infos
//LVAR_TEXT_LABEL16 temp16_2
function_read_RWS_Weapons:
saving_mod = 0
ALLOCATE_MEMORY 128 buffer_index
label_read_ini1:
OPEN_FILE "cleo\RWS_Weapons.ini" 0x72 file_ini
counter = 0
label_read_ini2:
WRITE_MEMORY buffer_index 128 0 0 //Cleaning buffer_128
IF READ_STRING_FROM_FILE file_ini buffer_index 128
buffer_now = buffer_index
REPEAT 15 tempi_1
READ_MEMORY buffer_now 1 0 tempi_2
IF tempi_2 = 0x3A // ":"
OR tempi_2 = 0x00 // end of text
GOTO label_read_ini3
ENDIF
buffer_now += 1
ENDREPEAT
label_read_ini3:
// Did we find ":'?
IF NOT tempi_2 = 0x3A // ":"
GOTO label_read_ini2
ENDIF
//Getting values
WRITE_MEMORY buffer_now 1 0 0 //put a zero at the end of filename segment...so buffer will behave like a null terminated string
SCAN_STRING buffer_index '%d%s' tempi_1 (weap_infos[0] buffer_now)
PRINT_FORMATTED_NOW "Ai está: %d" 500 weap_infos[0]
WAIT 500
IF weap_infos[0] >= 0
buffer_now += 1 //advance one byte (prepare to read the rest of the buffer)
SCAN_STRING buffer_now '%d%d%d%d%d%d' tempi_1 (weap_infos[1] weap_infos[2] weap_infos[3] weap_infos[4] weap_infos[5] weap_infos[6])
tempi_2 = TIMEFORALLWEAPONS - 1
IF tempi_1 = tempi_2
IF saving_mod = 1
//Limited munition - type of check
IF NOT weap_infos[1] = 1
AND NOT weap_infos[1] = 2
weap_infos[1] = -1
ENDIF
//Limited munition - type of amount
IF NOT weap_infos[2] = 2
weap_infos[2] = 1
ENDIF
//Limited munition - amount of ammo
IF NOT weap_infos[3] >= 0
weap_infos[1] = -1
ENDIF
// Reload weapon
IF NOT weap_infos[4] = 1
weap_infos[4] = -1
ENDIF
// lose current weapon
IF NOT weap_infos[5] = 0
weap_infos[5] = 1
ENDIF
// Manual fire
IF weap_infos[6] = 1
weap_infos[6] = 0
ENDIF
PRINT_FORMATTED_NOW "%d -> %d %d %d %d %d %d" 2000 weap_infos[0] weap_infos[1] weap_infos[2] weap_infos[3] weap_infos[4] weap_infos[5] weap_infos[6]
WAIT 2000
//Saving values
REPEAT 6 tempi_1
CLEO_CALL function_array_int_write 0 (memory_weapon_infos counter weap_infos[tempi_1])
counter += 1
ENDREPEAT
ELSE
counter += 1 //Counting line
ENDIF
ENDIF
ENDIF
GOTO label_read_ini2
ENDIF
//end label_read_ini2
IF saving_mod = 0
GET_LABEL_POINTER buffer_Infos tempi_1
tempi_1 += 72 //Number of weapon in RWS_Weapons.ini
WRITE_MEMORY tempi_1 4 counter 0
counter *= TIMEFORALLWEAPONS
CLEO_CALL function_array_create 0 (counter) (memory_weapon_infos)
saving_mod = 1
GOTO label_read_ini1
ENDIF
//end label_read_ini1
FREE_MEMORY buffer_index
CLEO_RETURN 0 memory_weapon_infos
}
//=========================================================================================================================================
//Functions: read/write values on vars with bigger memories
//Creating memories
{
function_array_create:
LVAR_INT save_size
LVAR_INT var_to_memory
save_size *= 4
ALLOCATE_MEMORY save_size var_to_memory
CLEO_RETURN 0 var_to_memory
}
//Freeing and writing memories
{
LVAR_INT memory
LVAR_INT size
LVAR_INT int_write_var
LVAR_FLOAT float_write_var
function_array_destroy:
FREE_MEMORY memory
CLEO_RETURN 0
function_array_int_write:
GOSUB sub_define_vars1
WRITE_MEMORY size 4 int_write_var 0
CLEO_RETURN 0
function_array_float_write:
GOSUB sub_define_vars2
WRITE_MEMORY size 4 float_write_var 0
CLEO_RETURN 0
sub_define_vars1:
size *= 4
size = memory + size
RETURN
}
//Reading memories
{
LVAR_INT memory
LVAR_INT size
LVAR_INT int_read_var
LVAR_INT float_read_var
function_array_int_read:
GOSUB sub_define_vars1
READ_MEMORY size 4 0 int_read_var
CLEO_RETURN 0 int_read_var
function_array_float_read:
GOSUB sub_define_vars2
READ_MEMORY size 4 0 float_read_var
CLEO_RETURN 0 float_read_var
sub_define_vars2:
size *= 4
size = memory + size
RETURN
}
//=========================================================================================================================================
//Buffers
{
buffer_128:
DUMP
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
ENDDUMP
}
- SOLUÇÃO:
- O Fábio me ajudou apontando o $ nas variável que se tornam strings. E com alguns ajustei e até melhorias, consegui fazer o script rodar.
Deixo um modelo abaixo de como ler e salvar linhas de arquivos como .ini e .dat de uma linha inteira estilo o Realistic Weapons Settings ou o SAAS.
Vem também algumas funções para ler a salvar valores em variáveis com ALLOCATE_MEMORY , que é importante para essa função.- Script - GTA3:
- Código:
//Function: read and save from a file: .ini or .dat for example
{
//Local vars and constatns
CONST_INT HOW_MANY_INFOS_BY_LINE 7 //IT'S IMPORTANT: IT COUNTS HOW MANY INFOS THERE ARE BY LINE ON FILE
LVAR_INT buffer_index
LVAR_INT buffer_now
LVAR_INT var_buffer
LVAR_INT tempi_1 tempi_2
LVAR_INT file_ini
LVAR_INT counter
LVAR_INT saving_mod // 0 -> read; 1 -> save
LVAR_INT infos_file[HOW_MANY_INFOS_BY_LINE]
LVAR_INT memory_local_var
//LVAR_TEXT_LABEL16 temp16_2
function_read_file_lines:
saving_mod = 0
ALLOCATE_MEMORY 128 buffer_index
ALLOCATE_MEMORY 128 buffer_now
label_read_ini1:
OPEN_FILE "YOURFILE" 0x72 file_ini
counter = 0
label_read_ini2:
WRITE_MEMORY buffer_index 128 0 0 //Cleaning buffer_index
IF READ_STRING_FROM_FILE file_ini buffer_index 128
buffer_now = buffer_index
REPEAT 15 tempi_1
READ_MEMORY buffer_now 1 0 tempi_2
IF tempi_2 = 0x3A // ":"
GOTO label_read_ini3
ENDIF
IF tempi_2 = 0x00 // end of text
OR tempi_2 = 0x23 // #
OR tempi_2 = 0x3B // ;
GOTO label_read_ini2
ENDIF
buffer_now += 1
ENDREPEAT
label_read_ini3:
// Did we find ":'?
// Check more on: http://www.thortech.ind.br/img/products/505d181f53.pdf
IF NOT tempi_2 = 0x3A // ":"
GOTO label_read_ini2
ENDIF
//Getting values
WRITE_MEMORY buffer_now 1 0 0 //put a zero at the end of filename segment...so buffer will behave like a null terminated string
//GET_VAR_POINTER buffer_index var_buffer
SCAN_STRING $buffer_index "%d%s" tempi_1 (infos_file[0] buffer_now)
IF infos_file[0] >= 0
buffer_now += 1 //advance one byte (prepare to read the rest of the buffer)
SCAN_STRING $buffer_now "%d%d%d%d%d%d" tempi_1 (infos_file[1] infos_file[2] infos_file[3] infos_file[4] infos_file[5] infos_file[6])
tempi_2 = HOW_MANY_INFOS_BY_LINE - 1
IF tempi_1 = tempi_2
IF saving_mod = 1
// OPTIONAL: IT'S ONLY PARAMETERS FOR INFORMATIONS
/*
//Limited munition - type of check
IF NOT infos_file[1] = 1
AND NOT infos_file[1] = 2
infos_file[1] = -1
ENDIF
//Limited munition - type of amount
IF NOT infos_file[2] = 2
infos_file[2] = 1
ENDIF
//Limited munition - amount of ammo
IF NOT infos_file[3] >= 0
infos_file[1] = -1
ENDIF
// Reload weapon
IF NOT infos_file[4] = 1
infos_file[4] = -1
ENDIF
// lose current weapon
IF NOT infos_file[5] = 0
infos_file[5] = 1
ENDIF
// Manual fire
IF infos_file[6] = 1
infos_file[6] = 0
ENDIF
*/
//Saving values
REPEAT HOW_MANY_INFOS_BY_LINE tempi_1
CLEO_CALL function_array_int_write 0 (memory_local_var counter infos_file[tempi_1])
counter += 1
ENDREPEAT
ELSE
counter += 1 //Counting line
ENDIF
ENDIF
ENDIF
GOTO label_read_ini2
ENDIF
//end label_read_ini2
// IF saving_mod = 0, it'll create a var to save all mods,
// IF saving_mod = 1, all informations have been saved on var and the function can end.
IF saving_mod = 0
// Save how many lines was read: it's an example from my RWS
GET_LABEL_POINTER buffer_Infos tempi_1 //Any thread memory
tempi_1 += 72
WRITE_MEMORY tempi_1 4 counter 0
// Create a var to save all informations from mods
counter *= HOW_MANY_INFOS_BY_LINE
CLEO_CALL function_array_create 0 (counter) (memory_local_var)
// Set saving_mod = 1 to next step
saving_mod = 1
GOTO label_read_ini1
ENDIF
//end label_read_ini1
FREE_MEMORY buffer_index
FREE_MEMORY buffer_now
CLEO_RETURN 0 memory_local_var
}
//=========================================================================================================================================
//Functions: read/write values on vars with bigger memories
//Creating memories
{
//CLEO_CALL function_array_create 0 (size) (memory_var)
function_array_create:
LVAR_INT save_size
LVAR_INT var_to_memory
save_size *= 4
ALLOCATE_MEMORY save_size var_to_memory
CLEO_RETURN 0 var_to_memory
}
//Freeing and writing memories
{
LVAR_INT memory
LVAR_INT size
LVAR_INT int_write_var
LVAR_FLOAT float_write_var
//CLEO_CALL function_array_create 0 (memory_var)
function_array_destroy:
FREE_MEMORY memory
CLEO_RETURN 0
//CLEO_CALL function_array_int_write 0 (memory_var local var_int_to_be_saved)
function_array_int_write:
GOSUB sub_define_vars1
WRITE_MEMORY size 4 int_write_var 0
CLEO_RETURN 0
//CLEO_CALL function_array_float_write 0 (memory_var local var_float_to_be_saved)
function_array_float_write:
GOSUB sub_define_vars2
WRITE_MEMORY size 4 float_write_var 0
CLEO_RETURN 0
sub_define_vars1:
size *= 4
size = memory + size
RETURN
}
//Reading memories
{
LVAR_INT memory
LVAR_INT size
LVAR_INT int_read_var
LVAR_INT float_read_var
//CLEO_CALL function_array_int_read 0 (memory_var local) (var_int_to_read)
function_array_int_read:
GOSUB sub_define_vars1
READ_MEMORY size 4 0 int_read_var
CLEO_RETURN 0 int_read_var
//CLEO_CALL function_array_float_read 0 (memory_var local) (var_float_to_read)
function_array_float_read:
GOSUB sub_define_vars2
READ_MEMORY size 4 0 float_read_var
CLEO_RETURN 0 float_read_var
sub_define_vars2:
size *= 4
size = memory + size
RETURN
}
- Exemplo de arquivo:
- # Realistic Weapons Settings v1.1
# In this section, you set the weapons configurations.
#--------------------------------------------------------------------------------------------------------------------------------------
# A - Weapon Number
# B - Limited Munition - type of check (where the amount of ammo will be checked)
# 0 = there isn't a limit of ammo in this weapon
# 1 = In total ammo (standard)
# 2 = In reserved ammo (that's not used in current weapon in clip)
# C - Limited Munition - type of limit
# 1 = limit by total of ammo (standard)
# 2 = limit by clip (ammo will be multiplied by the maximum ammo in clip)
# D - Limited Munition - Max quantity of ammo that you can use, depends of type of limit C and where it's allocated in B
# E - rechargeable weapon (Reload Mod) = 1 - activatable; 0 - not activatable
# F - Lose Current Ammo in Reload.
# 1 = Lose current ammo in clip (standard)
# 0 = Don't lose current ammo in clip
# G - Manual Fire = it'll force a weapon to fire manually
# 0 - Manual
# 1 - Automatic
#--------------------------------------------------------------------------------------------------------------------------------------
[WeaponsValues]
#A B C D E F G
#Pistols
22 : 2 2 6 1 1 1 ;Pistol
23 : 2 2 6 1 1 1 ;Silenced Pistol
24 : 2 2 4 1 1 1 ;Desert Eagle
#Shotguns
25 : 2 2 30 1 0 1 ;Shotgun
26 : 2 2 25 1 0 1 ;Sawnoff Shotgun
27 : 2 2 5 1 0 1 ;Combat Shotgun
#Sub machine guns
28 : 2 2 6 1 1 0 ;Micro-uzi
32 : 2 2 4 1 1 0 ;Tec9
29 : 2 2 4 1 1 0 ;MP5
#Assault rifles
30 : 2 2 4 1 1 0 ;AK-47
31 : 2 2 4 1 1 0 ;M4
#Rifles
33 : 2 2 30 1 1 1 ;Rifle
34 : 2 2 30 1 1 1 ;Sniper rifle
#Heavy weapons
35 : 1 2 8 1 1 1 ;RPG
36 : 1 2 5 1 1 1 ;Missile Launcher
37 : 2 2 2 0 0 0 ;Flame Thrower
38 : 1 1 500 0 0 0 ;Minigun
#Through weapons
16 : 1 2 6 1 1 0 ;Grenade
17 : 1 2 8 1 1 0 ;Teargas
18 : 1 2 8 1 1 0 ;Coquetel Molotov
39 : 1 2 6 1 1 0 ;Satchel Charges
#Other weapons
41 : 2 2 2 0 1 0 ;Spray can
42 : 2 2 2 0 1 0 ;Extinguisher
43 : 2 2 6 0 1 1 ;Camera
- Código:
{
buffer_128:
DUMP
...
ENDDUMP
}
eu ainda não tinha feito isto de escrever o buffer dentro de um escopo, sempre faço fora depois de script_end, isto muda alguma coisa?

- Spoiler:
- Código:
}
script_end
buffer_128:
DUMP
...
ENDDUMP
↑ Muda absolutamente nada.
O seu problema possivelmente é a ordem dos parâmetros do SCAN_STRING.
Tenho quase certeza de que a primeira variável do SCAN_STRING é o retorno, a segunda é a fonte, e o que vem em seguida é a formatação.
O seu problema possivelmente é a ordem dos parâmetros do SCAN_STRING.
Tenho quase certeza de que a primeira variável do SCAN_STRING é o retorno, a segunda é a fonte, e o que vem em seguida é a formatação.
Mais uma coisa para o grupo do 'tanto faz', como os parênteses@Junior_Djjr escreveu:↑ Muda absolutamente nada.

GTA3script tem coisa pakas no "tanto faz".
Você pode escrever o script inteiro em letras minúsculas ou maiúsculas que dá tudo no mesmo. Colocar um monte de ( ) , que também dá tudo no mesmo.
(não excluindo o Sanny Builder que também é bem assim)
Várias outras programações você tem que digitar tudo exatamente como deve ser digitado, ou é erro.
Você pode escrever o script inteiro em letras minúsculas ou maiúsculas que dá tudo no mesmo. Colocar um monte de ( ) , que também dá tudo no mesmo.
(não excluindo o Sanny Builder que também é bem assim)
Várias outras programações você tem que digitar tudo exatamente como deve ser digitado, ou é erro.
- DeadstrokeScripter CLEO - Intermediário
- Mensagens : 529
Reputação : 42
Desde : 08/02/2016
Localização : São Paulo
@Junior_Djjr escreveu:↑ Muda absolutamente nada.
O seu problema possivelmente é a ordem dos parâmetros do SCAN_STRING.
Tenho quase certeza de que a primeira variável do SCAN_STRING é o retorno, a segunda é a fonte, e o que vem em seguida é a formatação.
Bem, com certeza não é essa ordem, pois o VSC disse:
- Código:
SCAN_STRING STRING, STRING, INT, PARAM
Mas ele não explica o que é cada string especificamente, me baseei pelo opcode antigo. Até tentei o que você ordenou mas crashou. E tentei até inverter e outras coisas, mas realmente não funcionou mesmo.
- Código:
SCAN_STRING buffer_index '%d%s' tempi_1 (weap_infos[0] buffer_now)
Ele sempre lê a var weap_infos[0] como 0.
Edit.: o compilador compila o script, mas sempre vem com uma mensagem "message: 'text label collides with some variable name'
at: '519,33'", significa alguma coisa preocupante?
http://gtag.gtagaming.com/opcode-database/opcode/0AD4/
Precisa usar $ quando for usar variável ao invés de string.
@_@ Onde?
Edit.: o compilador compila o script, mas sempre vem com uma mensagem "message: 'text label collides with some variable name'
Precisa usar $ quando for usar variável ao invés de string.
at: '519,33'", significa alguma coisa preocupante?
@_@ Onde?
______________________________
![[RESOLVIDO] [SCM -> GTA3Script]: leitor de linhas de arquivos 226c0ef57f9d7520d171cbadc68b3c56](https://2img.net/h/i.picasion.com/pic62/226c0ef57f9d7520d171cbadc68b3c56.gif)
Modifico quase qualquer coisa. :)
------------------>>>http://gtamodvicio.blogspot.com/ <<<------------------
![[RESOLVIDO] [SCM -> GTA3Script]: leitor de linhas de arquivos 76561198069372249](https://2img.net/h/steamsignature.com/profile/default/76561198069372249.png)
Meu PC:
- Spoiler:
Configurações PC:
*Processador: Intel Core i7 4790K 4.00GHz LGA1150
*Placa Mãe: GIGABYTE GA-H97M-D3H Intel (LGA1150)
*HD: 1TB Seagate Barracuda 64MB Sata III 7200RPM (2x - RAID 0)
*HD²: SAMSUNG M3 Externo USB 5400RPM 1TB
*Placa de vídeo: Nvidia GTX660 2GB DDR5 192bit EVGA
*RAM: 8GB DDR3 1600MHZ Kingston HYPER X BEAST (2x4GB)
*Fonte: Corsair 600W Reais CX600M Modular - CP-9020060-WW (80 Plus Bronze)
*Gabinete: Gabinete Raidmax Super Hurricane Branco - 248WB
*Monitor: LG 23MP55HQ Full HD HDMI 23'
- DeadstrokeScripter CLEO - Intermediário
- Mensagens : 529
Reputação : 42
Desde : 08/02/2016
Localização : São Paulo
@Fabio , você salvou de novo, muito obrigado.
A última pergunta era parte do aviso, acho que deixei meio mal explicado.
Como presente, deixo um modelo em GTA3Script para ler e salvar linhas de arquivos .ini e .dat de maneira eficiente como no SAAS e no Realistic Weapons Settings. @Um_Geek , você pode utilizar se quiser para mods como Ladders ou outros que for fazer se entender bem. Vem também como em usar var com ALLOCATE_MEMORY como thread memories, para usar com esse mod.
Mudei também o nome e a capa para verem rapidamente a respeito do assunto:
A última pergunta era parte do aviso, acho que deixei meio mal explicado.
Como presente, deixo um modelo em GTA3Script para ler e salvar linhas de arquivos .ini e .dat de maneira eficiente como no SAAS e no Realistic Weapons Settings. @Um_Geek , você pode utilizar se quiser para mods como Ladders ou outros que for fazer se entender bem. Vem também como em usar var com ALLOCATE_MEMORY como thread memories, para usar com esse mod.
Mudei também o nome e a capa para verem rapidamente a respeito do assunto:
- Modelo de script:
- Código:
//Function: read and save from a file: .ini or .dat for example
{
//Local vars and constatns
CONST_INT HOW_MANY_INFOS_BY_LINE 7 //IT'S IMPORTANT: IT COUNTS HOW MANY INFOS THERE ARE BY LINE ON FILE
LVAR_INT buffer_index
LVAR_INT buffer_now
LVAR_INT var_buffer
LVAR_INT tempi_1 tempi_2
LVAR_INT file_ini
LVAR_INT counter
LVAR_INT saving_mod // 0 -> read; 1 -> save
LVAR_INT infos_file[HOW_MANY_INFOS_BY_LINE]
LVAR_INT memory_local_var
//LVAR_TEXT_LABEL16 temp16_2
function_read_file_lines:
saving_mod = 0
ALLOCATE_MEMORY 128 buffer_index
ALLOCATE_MEMORY 128 buffer_now
label_read_ini1:
OPEN_FILE "YOURFILE" 0x72 file_ini
counter = 0
label_read_ini2:
WRITE_MEMORY buffer_index 128 0 0 //Cleaning buffer_index
IF READ_STRING_FROM_FILE file_ini buffer_index 128
buffer_now = buffer_index
REPEAT 15 tempi_1
READ_MEMORY buffer_now 1 0 tempi_2
IF tempi_2 = 0x3A // ":"
GOTO label_read_ini3
ENDIF
IF tempi_2 = 0x00 // end of text
OR tempi_2 = 0x23 // #
OR tempi_2 = 0x3B // ;
GOTO label_read_ini2
ENDIF
buffer_now += 1
ENDREPEAT
label_read_ini3:
// Did we find ":'?
// Check more on: http://www.thortech.ind.br/img/products/505d181f53.pdf
IF NOT tempi_2 = 0x3A // ":"
GOTO label_read_ini2
ENDIF
//Getting values
WRITE_MEMORY buffer_now 1 0 0 //put a zero at the end of filename segment...so buffer will behave like a null terminated string
//GET_VAR_POINTER buffer_index var_buffer
SCAN_STRING $buffer_index "%d%s" tempi_1 (infos_file[0] buffer_now)
IF infos_file[0] >= 0
buffer_now += 1 //advance one byte (prepare to read the rest of the buffer)
SCAN_STRING $buffer_now "%d%d%d%d%d%d" tempi_1 (infos_file[1] infos_file[2] infos_file[3] infos_file[4] infos_file[5] infos_file[6])
tempi_2 = HOW_MANY_INFOS_BY_LINE - 1
IF tempi_1 = tempi_2
IF saving_mod = 1
// OPTIONAL: IT'S ONLY PARAMETERS FOR INFORMATIONS
/*
//Limited munition - type of check
IF NOT infos_file[1] = 1
AND NOT infos_file[1] = 2
infos_file[1] = -1
ENDIF
//Limited munition - type of amount
IF NOT infos_file[2] = 2
infos_file[2] = 1
ENDIF
//Limited munition - amount of ammo
IF NOT infos_file[3] >= 0
infos_file[1] = -1
ENDIF
// Reload weapon
IF NOT infos_file[4] = 1
infos_file[4] = -1
ENDIF
// lose current weapon
IF NOT infos_file[5] = 0
infos_file[5] = 1
ENDIF
// Manual fire
IF infos_file[6] = 1
infos_file[6] = 0
ENDIF
*/
//Saving values
REPEAT HOW_MANY_INFOS_BY_LINE tempi_1
CLEO_CALL function_array_int_write 0 (memory_local_var counter infos_file[tempi_1])
counter += 1
ENDREPEAT
ELSE
counter += 1 //Counting line
ENDIF
ENDIF
ENDIF
GOTO label_read_ini2
ENDIF
//end label_read_ini2
// IF saving_mod = 0, it'll create a var to save all mods,
// IF saving_mod = 1, all informations have been saved on var and the function can end.
IF saving_mod = 0
// Save how many lines was read: it's an example from my RWS
GET_LABEL_POINTER buffer_Infos tempi_1 //Any thread memory
tempi_1 += 72
WRITE_MEMORY tempi_1 4 counter 0
// Create a var to save all informations from mods
counter *= HOW_MANY_INFOS_BY_LINE
CLEO_CALL function_array_create 0 (counter) (memory_local_var)
// Set saving_mod = 1 to next step
saving_mod = 1
GOTO label_read_ini1
ENDIF
//end label_read_ini1
FREE_MEMORY buffer_index
FREE_MEMORY buffer_now
CLEO_RETURN 0 memory_local_var
}
//=========================================================================================================================================
//Functions: read/write values on vars with bigger memories
//Creating memories
{
//CLEO_CALL function_array_create 0 (size) (memory_var)
function_array_create:
LVAR_INT save_size
LVAR_INT var_to_memory
save_size *= 4
ALLOCATE_MEMORY save_size var_to_memory
CLEO_RETURN 0 var_to_memory
}
//Freeing and writing memories
{
LVAR_INT memory
LVAR_INT size
LVAR_INT int_write_var
LVAR_FLOAT float_write_var
//CLEO_CALL function_array_create 0 (memory_var)
function_array_destroy:
FREE_MEMORY memory
CLEO_RETURN 0
//CLEO_CALL function_array_int_write 0 (memory_var local var_int_to_be_saved)
function_array_int_write:
GOSUB sub_define_vars1
WRITE_MEMORY size 4 int_write_var 0
CLEO_RETURN 0
//CLEO_CALL function_array_float_write 0 (memory_var local var_float_to_be_saved)
function_array_float_write:
GOSUB sub_define_vars2
WRITE_MEMORY size 4 float_write_var 0
CLEO_RETURN 0
sub_define_vars1:
size *= 4
size = memory + size
RETURN
}
//Reading memories
{
LVAR_INT memory
LVAR_INT size
LVAR_INT int_read_var
LVAR_INT float_read_var
//CLEO_CALL function_array_int_read 0 (memory_var local) (var_int_to_read)
function_array_int_read:
GOSUB sub_define_vars1
READ_MEMORY size 4 0 int_read_var
CLEO_RETURN 0 int_read_var
//CLEO_CALL function_array_float_read 0 (memory_var local) (var_float_to_read)
function_array_float_read:
GOSUB sub_define_vars2
READ_MEMORY size 4 0 float_read_var
CLEO_RETURN 0 float_read_var
sub_define_vars2:
size *= 4
size = memory + size
RETURN
}
Percebi que é bem diferente do lua e do C# onde se esquecer um ";" a coisa desanda toda seriamente@Junior_Djjr escreveu:
Várias outras programações você tem que digitar tudo exatamente como deve ser digitado, ou é erro.

@Deadstroke escreveu:
Deixo um modelo abaixo de como ler e salvar linhas de arquivos como .ini e .dat de uma linha inteira estilo o Realistic Weapons Settings ou o SAAS.
Isto ai parece bem útil, sempre estou procurando algo capas de ler linhas inteiras e ser capas de separar arrays por espaço ou até vírgula mesmo. Sera que consegue pegar por exemplo as coordenadas do arquivo water.dat?

- DeadstrokeScripter CLEO - Intermediário
- Mensagens : 529
Reputação : 42
Desde : 08/02/2016
Localização : São Paulo
@Um Geek escreveu:Isto ai parece bem útil, sempre estou procurando algo capas de ler linhas inteiras e ser capas de separar arrays por espaço ou até vírgula mesmo. Sera que consegue pegar por exemplo as coordenadas do arquivo water.dat?
Deve dar, pode tentar. Mas se o número de campos for muito grande, precisa fazer uns dois SCAN_STRINGS , no estilo que fiz pra checar se tem o ":" e depois ler as linhas normalmente. Também vai precisar salvar as vars adiantadamente lógico.
Mais questão de organização, é melhor para nos que usamos o gta3sc. agora no {} não é tão verídico por este detalhe.

- Código:
{
LVAR_INT a b c d e f g h i j k l m n o p q r s t u v x y w z a2 b2 c2 d2 e2 f2 //-- 32 variaveis
}
{
LVAR_INT a b c d e f g h i j k l m n o p q r s t u v x y w z a2 b2 c2 d2 e2 f2 //-- 32 variaveis
}
vou começar por algo menor, o water.dat é bem complexo, eu tinha pensado e fazer algo como os canais com agua em certos dias da semana. mas é numero demais da conta então deixei de mão

Permissão deste fórum:
Você não pode responder aos tópicos neste fórum