CLEO Help Please help

CLEO related
Status
Not open for further replies.

YcE

New member
Joined
Jan 12, 2018
Messages
4
Reaction score
0
Hi, I need your help with the following script:
Code:
{$CLEO .cs}

0000:
repeat
wait 0
until 0AFA: samp_is_ready

0B34: samp register_client_command "test" to_label @99

:98
wait 0
jump @98

:99
wait 0
6@ = File.Open("cleo\test.ini", "rt")
else_jump @100
wait 0
jump @99

:100
wait 0
alloc 8@ 260 
Samp.IsCommandTyped(0@)
if
0AD4: 11@ = scan_string 0@ format "%d" 13@
else_jump @103

:101
wait 0
repeat
File.ReadString(6@, 8@, 260)
0AD4: 14@ = scan_string 8@ format "%d" 15@
until 003B: 13@ == 15@
File.ReadString(6@, 8@, 260)
0AF4: 16@ = scan_string 8@ format "%s" 17@
if
not 17@ == ""
else_jump @102
chatmsg "Text: %s" -1 17@

:103
wait 0
free 6@
File.Close(6@)
Samp.CmdRet
The test.ini file:
Code:
1
Text1

2
Text2

3
Text3
When I type /test 2 it should show on the chat "Text: Text2". But instead it crashes. :(
 

shanker

Well-known member
Joined
Sep 18, 2016
Messages
291
Reaction score
16
Location
Romania
@YcE,

[shcode=cpp]while true
   wait 0
   if
       0@ == 1
   then
       1@ = File.Open("CLEO\File.txt", "rt")
       
       repeat
       wait 0
       alloc 2@ = 1000
       File.ReadString(1@, 2@, 1000)
       if
           0C29: 33@ = stristr string1 2@ string2 "[Text]"
       then
           3@ += 1
           File.ReadString(1@, 2@, 1000)
           chatmsg "Text %d: %s" -1 3@ 2@
       end
       free 2@
       
       until File.EOF(1@)
       File.Close(1@)
       0@ = 0
       3@ = 0
   end  
end[/shcode]

And the file

[shcode=cpp][Text]
Textul 1 este acesta

[Text]
Textul 2 este acesta

[Text]
Textul 3 este acesta[/shcode]

There is an example how to read a specific text

[shcode=cpp]while true
    wait 0
    if
        0@ == 1
    then
        1@ = File.Open("CLEO\File.txt", "rt")
        
        repeat
        wait 0
        alloc 2@ = 1000
        File.ReadString(1@, 2@, 1000)
        if
            0C29: 33@ = stristr string1 2@ string2 3@
        then
            File.ReadString(1@, 2@, 1000)
            chatmsg "Textul %d este urmatorul: %s" -1 4@ 2@
        end
        free 2@
        
        until File.EOF(1@)
        File.Close(1@)
        0@ = 0
        free 3@
    end  
end[/shcode]

Command should look like:

[shcode=cpp]:TEST
SAMP.IsCommandTyped(0@)
if
    0AD4: 33@ = scan_string 0@ format "%d" 4@
then
    alloc 3@ = 260
    format 3@ = "[Text %d]" 4@
    0@ = 1
end 
cmdret[/shcode]

And the file

[shcode=cpp][Text 1]
Textul 1 este acesta

[Text 2]
Textul 2 este acesta

[Text 3]
Textul 3 este acesta[/shcode]
 
Status
Not open for further replies.
Top