CLEO Help writing string value to .ini

CLEO related
Status
Not open for further replies.

KamikazeSripterul

Well-known member
Joined
Jun 30, 2019
Messages
353
Reaction score
23
So I've done this code, with the help of one of the members of this community, BUT it doesn't work rlly well and it crashes. I'm not sure if i need to allocate any memory or anything. Can someone help?
--> Here's some videos to show the problem
- /balance (it writes the right value in .ini file but crashes) https://streamable.com/fpsj0
- /transfer (it writes the whole string to .ini file and it crashes) https://streamable.com/lttmv
Here's the code
-->
Code:
While true   
wait 0

    alloc 2@ 260
    0B75: samp get_chat_string 99 text_to 2@ prefix_to 3@ color_to 4@ prefix_color_to 5@
    
    if or
    4@ == 0xffffd700
    4@ == 0xff4dad2b
    then
        if or
        0C29: $not_used = strstr string1 2@ string2 "Your account balance is now"
        0C29: $not_used = strstr string1 2@ string2 "Your current bank account balance is:"
    then   
        0AB1: @GetText 1 WriteStringPointer 2@ rnt 15@
        0AF5: write_string 15@ to_ini_file "cleo\ServerCMD.ini" section "Bank" key "balance"
        chatmsg "{000089}[{770089}Bank Manager{000089}]: {e0388f}Account Balance Changed."
        chatmsg "{000089}[{770089}Bank Manager{000089}]: {e0388f}You can check your new balance using {ffffff}[/bankmenu] {e0388f}> {ffffff}Check your balance"
        wait 1000
        end 
    end   
    free 2@
END

:GetText
{
    0AB1: @GetText 1 WriteStringPointer 0@ rnt 1@
}
0C17: 31@ = strlen 0@
31@ -= 1
    for 30@ = 0 to 31@
    0A8D: 29@ = read_memory 0@ size 1 virtual_protect 1
 
        if
        29@ == 36 // 36 = $
        then
            0@++
            0AB2: ret 1 0@                                               
        end

    0@++
    end
0AB2: ret 0
 

KamikazeSripterul

Well-known member
Joined
Jun 30, 2019
Messages
353
Reaction score
23
@Parazitas ok so the crash its gone, it was indeed from the chat message but now theres another problem... Bcoz there is another $ that says the amount that u have transferred or deposited, it writes the whole string... do u know how i can fix that?
 

Parazitas

God
Joined
Jan 2, 2017
Messages
3,113
Solutions
5
Reaction score
878
Location
Lithuania
PHP:
:GetText
{
    0AB1: @GetText 1 WriteStringPointer 0@ rnt 1@
}
0C17: 31@ = strlen 0@
31@ -= 1
    for 30@ = 0 to 31@
    0A8D: 29@ = read_memory 0@ size 1 virtual_protect 1
 
        if
        29@ == 36 // 36 = $
        then
            1@++ // counter - count how many exist with same symbol
            if
            1@ == 2 // second 
            then
                0@++
                0AB2: ret 1 0@
            end                                               
        end

    0@++
    end
0AB2: ret 0
 

KamikazeSripterul

Well-known member
Joined
Jun 30, 2019
Messages
353
Reaction score
23
Oh okay. Thanks a lot. I thought of the idea that u had to add one as you've found the first one, but it didnt rlly worked.. but thanks a lot
 
Status
Not open for further replies.
Top