Quantcast

Jump to content

» «
Photo

Is This Possible?

3 replies to this topic
gtafan113
  • gtafan113

    Untitled

  • Members
  • Joined: 01 Mar 2009

#1

Posted 02 July 2013 - 06:08 AM

I tried searching about this but I wasn't even sure how to word the searches to get any meaningful results. That's why my title is a bit vague also.

I am wondering if it would be possible to use a string variable to determine where to read from/write to in an .ini file.

For example:

CODE

0@s = "SLOT1"
read_int_from_ini_file "CLEO\TEST.INI" section 0@s key "TIME" store_to 1@


If this isn't specific enough I will try to explain in more detail, but does anyone know how to get something like this to work?

Thanks in advance!


ZAZ
  • ZAZ

    Kernlochbohrer

  • Feroci
  • Joined: 10 Jan 2005
  • European-Union
  • Contribution Award [Mods]
    Helpfulness Awards [Mods]

#2

Posted 02 July 2013 - 02:19 PM Edited by ZAZ, 02 July 2013 - 02:41 PM.

Example, the test.ini have following content:
CODE
[DRIVETYPE]
CABBIE=4456448
FORTUNE=8
[HEALTH]
CABBIE=1000
FORTUNE=775


then read with string variable opcodes
CODE
{$CLEO .cs}
thread 'test'
wait 1000

06D2: 4@v = "TEST.INI" † † †// @v = 16-byte string, local, reserves 4 locals (have more chars)
05AA: 8@s = 'CABBIE' † † † †// @s = 8-byte string, local, reserves 2 locals (have max. 7 chars)
05AA: 10@s = 'FORTUNE' † † †// @s = 8-byte string, local, reserves 2 locals (have max. 7 chars)
06D2: 12@v = "drivetype" † †// @v = 16-byte string, local, reserves 4 locals (have more chars)
05AA: 16@s = 'HEALTH' † † † // @s = 8-byte string, local, reserves 2 locals (have max. 7 chars)†

while true
wait 0
† †03F0: enable_text_draw 1
† †045A: text_draw_1number †50.0 †100.0 'NUMBER' 0@
† †045A: text_draw_1number †50.0 †110.0 'NUMBER' 1@
† †045A: text_draw_1number †50.0 †120.0 'NUMBER' 2@
† †045A: text_draw_1number †50.0 †130.0 'NUMBER' 3@
† †if
† †0AB0: † key_pressed 8
† †then

† † † †0AF0: 0@ = get_int_from_ini_file 4@v section 12@v key 8@s
† † † †0AF0: 1@ = get_int_from_ini_file 4@v section 16@s key 8@s
† † † †0AF0: 2@ = get_int_from_ini_file 4@v section 12@v key 10@s
† † † †0AF0: 3@ = get_int_from_ini_file 4@v section 16@s key 10@s
† † † † † † † †
† †wait 1000
† †end

end

{
test.ini:
[section]
entry=integer value

contains following content:

[DRIVETYPE]
CABBIE=4456448
FORTUNE=8
[HEALTH]
CABBIE=1000
FORTUNE=775

}
text_draw codes shows the result on screen

gtafan113
  • gtafan113

    Untitled

  • Members
  • Joined: 01 Mar 2009

#3

Posted 02 July 2013 - 05:42 PM

Thank you very much ZAZ! This is will be useful for mods I would like to release because I'd rather use .ini files than CLEO variables so that they don't cause problems with other mods that also use CLEO variables.

toonskull
  • toonskull

    Necromancer

  • Members
  • Joined: 04 Aug 2009

#4

Posted 02 July 2013 - 09:02 PM

Interesting, could this also write the variables to a file as well? Does it go both ways?

For example, if I pull the players x,y,z coordinates and then write them out to a readable text file. If possible, how could I get the variables into a readable string format?




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users