CLEO HELP writing string value to .ini

KamikazeSripterul

Well-Known Member
Joined
Jun 30, 2019
Messages
61
Likes
1
Points
8
#1
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 [email protected] 260
    0B75: samp get_chat_string 99 text_to [email protected] prefix_to [email protected] color_to [email protected] prefix_color_to [email protected]
    
    if or
    [email protected] == 0xffffd700
    [email protected] == 0xff4dad2b
    then
        if or
        0C29: $not_used = strstr string1 [email protected] string2 "Your account balance is now"
        0C29: $not_used = strstr string1 [email protected] string2 "Your current bank account balance is:"
    then   
        0AB1: @GetText 1 WriteStringPointer [email protected] rnt [email protected]
        0AF5: write_string [email protected] 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 [email protected]
END

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

    [email protected]++
    end
0AB2: ret 0
 
OP
OP
K

KamikazeSripterul

Well-Known Member
Joined
Jun 30, 2019
Messages
61
Likes
1
Points
8
#4
@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

Well-Known Member
Joined
Jan 2, 2017
Messages
1,409
Likes
153
Points
78
Location
Lithuania
Website
ugbase.eu
15
#9
PHP:
:GetText
{
    0AB1: @GetText 1 WriteStringPointer [email protected] rnt [email protected]
}
0C17: [email protected] = strlen [email protected]
[email protected] -= 1
    for [email protected] = 0 to [email protected]
    0A8D: [email protected] = read_memory [email protected] size 1 virtual_protect 1
 
        if
        [email protected] == 36 // 36 = $
        then
            [email protected]++ // counter - count how many exist with same symbol
            if
            [email protected] == 2 // second 
            then
                [email protected]++
                0AB2: ret 1 [email protected]
            end                                               
        end

    [email protected]++
    end
0AB2: ret 0
 
OP
OP
K

KamikazeSripterul

Well-Known Member
Joined
Jun 30, 2019
Messages
61
Likes
1
Points
8
#10
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
 
Top