CLEO Help Reading From INI = CRASH

CLEO related
Status
Not open for further replies.

Crayder

Active member
Joined
Mar 6, 2014
Messages
148
Reaction score
0
Code:
Code:
	SAMP.IsCommandTyped(0@) 
	0AF2: 0@ = get_float_from_ini_file "cleo\positions.ini" section 0@ key "posX" 
	0AF2: 1@ = get_float_from_ini_file "cleo\positions.ini" section 0@ key "posY" 
	0AF2: 2@ = get_float_from_ini_file "cleo\positions.ini" section 0@ key "posZ"          
	25@ = Marker.CreateIconAndSphere(56, 0@, 1@, 2@)
INI File:
Code:
[test]
posX = 3000.0
posY = 3000.0
posZ = 3000.0
Command Typed:
Code:
/mark test
The crash occurs only when the file reading part is there, when I comment that out it's fine (but of course without valid coordinates). How am I to properly read the coordinates from the file?




EDIT: The code above was just an example, here is the real code.
Code:
{$CLEO .cs}
0000: NOP

REPEAT 
    WAIT 50
UNTIL SAMP.Available()

0B34: samp register_client_command "marker" to_label @CMD_MARKER  
0B34: samp register_client_command "savemark" to_label @CMD_SAVEMARK  
0B34: samp register_client_command "markpos" to_label @CMD_MARKPOS
                                                                         
08A8: set_markers_to_long_distance 1
      
:LOOP
    WAIT 0
    GOTO @LOOP 
    
:CMD_MARKER   
    WAIT 0 
    SAMP.IsCommandTyped(0@)     
    
    IF
        0AD4: 31@ = scan_string 0@ format "%s" 0@
    THEN                       
        0AF2: 1@ = get_float_from_ini_file "cleo\positions.ini" section 0@ key "posX" 
        0AF2: 2@ = get_float_from_ini_file "cleo\positions.ini" section 0@ key "posY" 
        0AF2: 3@ = get_float_from_ini_file "cleo\positions.ini" section 0@ key "posZ"  
        
        IF AND
            1@ == 0.0 
            2@ == 0.0 
            3@ == 0.0            
        THEN     
            CHATMSG "ERROR: Invalid position name." -1
        ELSE            
            Marker.Disable(25@)           
            25@ = Marker.CreateIconAndSphere(56, 0@, 1@, 2@)
            
            CHATMSG "Marker position loaded." -1
            018C: play_sound 1137 at 0.0 0.0 0.0
        END
    ELSE
        CHATMSG "USAGE: /mark <place name from ini>" -1
    END      
    
    SAMP.CmdRet
    GOTO @LOOP
    
:CMD_SAVEMARK   
    WAIT 0 
    SAMP.IsCommandTyped(0@)     
    
    IF
        0AD4: 31@ = scan_string 0@ format "%s" 0@
    THEN                          
        Actor.StorePos($Player_actor, 1@, 2@, 3@)
        0AF3: write_float 1@ to_ini_file "cleo\positions.ini" section 0@ key "posX" 
        0AF3: write_float 2@ to_ini_file "cleo\positions.ini" section 0@ key "posY" 
        0AF3: write_float 3@ to_ini_file "cleo\positions.ini" section 0@ key "posZ" 

        
        CHATMSG "Marker position saved." -1
        018C: play_sound 1137 at 0.0 0.0 0.0
    ELSE
        CHATMSG "USAGE: /savemark <place name to ini>" -1
    END      
    
    SAMP.CmdRet
    GOTO @LOOP
    
:CMD_MARKPOS   
    WAIT 0 
                              
    Marker.Disable(26@)   
    Actor.StorePos($Player_actor, 1@, 2@, 3@)
    26@ = Marker.CreateIconAndSphere(56, 1@, 2@, 3@)
    
    CHATMSG "Position marked." -1
    018C: play_sound 1137 at 0.0 0.0 0.0

    SAMP.CmdRet
    GOTO @LOOP
When I do "/savemark new" it crashes but actually writes a blank section and part of a value, but not what is expected. When I do "/marker test" it crashes with no sign of any thing working (the ini for this is above).
 

0B36

Expert
Joined
Jan 6, 2014
Messages
1,324
Reaction score
8
If you're using any opcodes which read or write to/from INI files, then it requires external CLEO plugins to be loaded, for this one, namely IniFiles.cleo. Download that CLEO plugin for 4.1 and put it inside CLEO directory.
 

Crayder

Active member
Joined
Mar 6, 2014
Messages
148
Reaction score
0
0B36 link said:
If you're using any opcodes which read or write to/from INI files, then it requires external CLEO plugins to be loaded, for this one, namely IniFiles.cleo. Download that CLEO plugin for 4.1 and put it inside CLEO directory.
I already have it, doesn't everyone have that? XD

Ok, I got past those crashes earlier just by adding a v to the variables. Now I have an entirely new problem. The script loads random variables and saves under weird names. For example, this is the saving output for "farfarm":
Code:
[farf¸lrD×âC]
posX=969.699
posY=144.886
posZ=851
The coordinates are correct however. This makes it impossible to load. I can also load any name I type, even if it doesn't exist. This doesn't give saved coordinates obviously, but I thought it'd give 0's. I was wrong, it gives random numbers. This is the new script:
Code:
{$CLEO .cs}
0000: NOP

REPEAT 
    WAIT 50
UNTIL SAMP.Available()

0B34: samp register_client_command "marker" to_label @CMD_MARKER  
0B34: samp register_client_command "savemark" to_label @CMD_SAVEMARK  
0B34: samp register_client_command "markpos" to_label @CMD_MARKPOS
                                                                         
08A8: set_markers_to_long_distance 1
      
:LOOP
    WAIT 0
    GOTO @LOOP 
    
:CMD_MARKER   
    WAIT 0 
    SAMP.IsCommandTyped(5@)     
    
    IF
        0AD4: 31@ = scan_string 5@ format "%s" 0@v
    THEN                       
        0AF2: 1@ = get_float_from_ini_file "cleo\positions.ini" section 0@v key "posX" 
        0AF2: 2@ = get_float_from_ini_file "cleo\positions.ini" section 0@v key "posY" 
        0AF2: 3@ = get_float_from_ini_file "cleo\positions.ini" section 0@v key "posZ"  
        
        IF AND
            1@ == 0.0 
            2@ == 0.0 
            3@ == 0.0            
        THEN     
            CHATMSG "ERROR: Invalid position name." -1
        ELSE            
            Marker.Disable(25@)           
            25@ = Marker.CreateIconAndSphere(56, 1@, 2@, 3@)
            
            CHATMSG "Marker position loaded." -1
            018C: play_sound 1137 at 0.0 0.0 0.0
        END
    ELSE
        CHATMSG "USAGE: /marker <saved place name>" -1
    END      
    
    SAMP.CmdRet
    GOTO @LOOP
    
:CMD_SAVEMARK   
    WAIT 0 
    SAMP.IsCommandTyped(5@)     
    
    IF
        0AD4: 31@ = scan_string 5@ format "%s" 0@v
    THEN                          
        Actor.StorePos($Player_actor, 1@, 2@, 3@)
        0AF3: write_float 1@ to_ini_file "cleo\positions.ini" section 0@v key "posX" 
        0AF3: write_float 2@ to_ini_file "cleo\positions.ini" section 0@v key "posY" 
        0AF3: write_float 3@ to_ini_file "cleo\positions.ini" section 0@v key "posZ" 

        
        CHATMSG "Marker position saved." -1
        018C: play_sound 1137 at 0.0 0.0 0.0
    ELSE
        CHATMSG "USAGE: /savemark <name>" -1
    END      
    
    SAMP.CmdRet
    GOTO @LOOP
                      
:CMD_MARKPOS   
    WAIT 0 
                              
    Marker.Disable(26@)   
    Actor.StorePos($Player_actor, 1@, 2@, 3@)
    26@ = Marker.CreateIconAndSphere(56, 1@, 2@, 3@)
    Marker.SetColor(26@, 0xFF0000FF)
    
    CHATMSG "Position marked." -1
    018C: play_sound 1137 at 0.0 0.0 0.0

    SAMP.CmdRet
    GOTO @LOOP
 
Joined
Feb 18, 2005
Messages
2,965
Reaction score
273
Code:
:CMD_MARKER   
SAMP.IsCommandTyped(0@)  
IF 0AD4: $nul = scan 0@ fmt "%s" 15@v
THEN
    0AF2: 1@ = get_float_from_ini_file "cleo\positions.ini" section 15@v key "posX" 
    0AF2: 2@ = get_float_from_ini_file "cleo\positions.ini" section 15@v key "posY" 
    0AF2: 3@ = get_float_from_ini_file "cleo\positions.ini" section 15@v key "posZ"  
    IF AND
        1@ == 0
        2@ == 0
        3@ == 0
    THEN   
        CHATMSG "ERROR: Invalid position name." -1
    ELSE
        IF 075C: marker 25@ enabled
        THEN         
            Marker.Disable(25@)
        END          
        25@ = Marker.CreateIconAndSphere(56, 1@, 2@, 3@)
        CHATMSG "Marker position loaded." -1
        018C: play_sound 1137 at 0.0 0.0 0.0
    END
ELSE
    CHATMSG "USAGE: /mark <place name from ini>" -1
END      
SAMP.CmdRet()

Read your code before.
 

Crayder

Active member
Joined
Mar 6, 2014
Messages
148
Reaction score
0
springfield link said:
Code:
:CMD_MARKER   
SAMP.IsCommandTyped(0@)  
IF 0AD4: $nul = scan 0@ fmt "%s" 15@v
THEN
    0AF2: 1@ = get_float_from_ini_file "cleo\positions.ini" section 15@v key "posX" 
    0AF2: 2@ = get_float_from_ini_file "cleo\positions.ini" section 15@v key "posY" 
    0AF2: 3@ = get_float_from_ini_file "cleo\positions.ini" section 15@v key "posZ"  
    IF AND
        1@ == 0
        2@ == 0
        3@ == 0
    THEN   
        CHATMSG "ERROR: Invalid position name." -1
    ELSE
        IF 075C: marker 25@ enabled
        THEN         
            Marker.Disable(25@)
        END          
        25@ = Marker.CreateIconAndSphere(56, 1@, 2@, 3@)
        CHATMSG "Marker position loaded." -1
        018C: play_sound 1137 at 0.0 0.0 0.0
    END
ELSE
    CHATMSG "USAGE: /mark <place name from ini>" -1
END      
SAMP.CmdRet()

Read your code before.
You've read my code? Or are you telling me to read it? Your code has the same results, it still exactly the same. It still loads weird values. Also the saving needs fixed to as explained above.
 
Joined
Feb 18, 2005
Messages
2,965
Reaction score
273
It works fine for me.
Example used;
Code:
:marker 
SAMP.IsCommandTyped(0@)  
IF 0AD4: $nul = scan 0@ fmt "%s" 15@v
THEN
    0AF2: 1@ = get_float_from_ini_file "cleo\positions.ini" section 15@v key "posX" 
    0AF2: 2@ = get_float_from_ini_file "cleo\positions.ini" section 15@v key "posY" 
    0AF2: 3@ = get_float_from_ini_file "cleo\positions.ini" section 15@v key "posZ"  
    IF AND
        1@ == 0
        2@ == 0
        3@ == 0
    THEN   
        CHATMSG "ERROR: Invalid position name." -1
    ELSE
        0AF8: "marker pos %f %f %f" -1 1@ 2@ 3@
        IF 075C: marker 25@ enabled
        THEN         
            Marker.Disable(25@)
        END          
        25@ = Marker.CreateIconAndSphere(56, 1@, 2@, 3@)
        CHATMSG "Marker position loaded." -1
        018C: play_sound 1137 at 0.0 0.0 0.0
    END
ELSE
    CHATMSG "USAGE: /mark <place name from ini>" -1
END      
SAMP.CmdRet()

positions.ini
Code:
[shit]
posX=33.0
posY=44.0
posZ=55.0

result;
Code:
/mark shit
[16:11:47] marker pos 33.000000 44.000000 55.000000
[16:11:47] Marker position loaded.

About saving, that's why i told you need to read the code before, if you use a long variable @v you can't use the next 3 variables.
0@v = 0@ 1@ 2@ 3@
5@v = 5@ 6@ 7@ 8@
Code:
SAMP.IsCommandTyped(5@)     
IF 0AD4: 31@ = scan_string 5@ format "%s" 0@v
THEN                          
    Actor.StorePos($Player_actor, 11@, 12@, 13@)
    0AF3: write_float 11@ to_ini_file "cleo\positions.ini" section 0@v key "posX" 
    0AF3: write_float 12@ to_ini_file "cleo\positions.ini" section 0@v key "posY" 
    0AF3: write_float 13@ to_ini_file "cleo\positions.ini" section 0@v key "posZ"
 
Status
Not open for further replies.
Top