CLEO Help %s & %d in a dialog

CLEO related

KamikazeSripterul

Well-known member
Joined
Jun 30, 2019
Messages
353
Reaction score
23
Hey. So ive tried to make a new script or something that i'd be able to use in a project i'm working on even though i'm not sure how to solve this.
So here's the script:
Code:
if SAMP.DialogRespond(830, 20@, 0, 25@)
    then
        if 20@ == 1
        then
            0C1A: 26@ = atoi 25@
            0AF1: write_int 26@ to_ini_file "cleo\ServerCMD.ini" section "Bank" key "idtransfer"
            if SAMP.IsPlayerConnected(19@)
            then
                0B36: samp 1@ = get_player_nickname 19@
            SAMP.ShowDialog(840, "{000089}[{770089}Bank Manager{000089}]: Transferring to %s [ID: %d]", "Please insert the amount of money you'd like to transfer", "Transfer", "Back", 1) 19@ 1@
        else
            if 20@ == 0
            then
                chatmsg "{000089}[{770089}Bank Manager{000089}]: {ff9000}Transaction has been cancelled." -1
                end
            end
        end
        0C11: memset destination 25@ value 0 size 50
    end
I'm not sure how to make %s and %d in the Dialog to work... I've tried writing the variables between the " Transferring to %s [ID: %d]"" and the comma but it still didnt work...
Can anyone help me please? Thanks.
 

shanker

Well-known member
Joined
Sep 18, 2016
Messages
291
Reaction score
16
Location
Romania
This is what you are looking for?

Code:
2@ = 3
0AC8: 1@ = allocate_memory_size 666
0AD3: 1@ = format "This is a test %cThat's my second line %cLine number: %d" 0x0A 0x0A 2@
SAMP.ShowDialog(040, "Title", 1@, "Button 1", "Button 2", 1)
 

KamikazeSripterul

Well-known member
Joined
Jun 30, 2019
Messages
353
Reaction score
23
This is what you are looking for?

Code:
2@ = 3
0AC8: 1@ = allocate_memory_size 666
0AD3: 1@ = format "This is a test %cThat's my second line %cLine number: %d" 0x0A 0x0A 2@
SAMP.ShowDialog(040, "Title", 1@, "Button 1", "Button 2", 1)
Would it work to do that to the title?
 

shanker

Well-known member
Joined
Sep 18, 2016
Messages
291
Reaction score
16
Location
Romania
Would it work to do that to the title?

Code:
:WeTest
3@ = 3

0AC8: 1@ = allocate_memory_size 666
0AC8: 2@ = allocate_memory_size 260

0AD3: 1@ = format "This is a test %cThat's my second line %cLine number: %d" 0x0A 0x0A 3@
0AD3: 2@ = format "I love %d" 69

SAMP.ShowDialog(040, 2@, 1@, "Button 1", "Button 2", 1)
cmdret

It works
 

Attachments

  • 1565350597201.png
    1565350597201.png
    130.6 KB · Views: 25

KamikazeSripterul

Well-known member
Joined
Jun 30, 2019
Messages
353
Reaction score
23
Code:
:WeTest
2@ = 3

0AC8: 1@ = allocate_memory_size 666
0AC8: 2@ = allocate_memory_size 260

0AD3: 1@ = format "This is a test %cThat's my second line %cLine number: %d" 0x0A 0x0A 2@
0AD3: 2@ = format "I love %d" 69

SAMP.ShowDialog(040, 2@, 1@, "Button 1", "Button 2", 1)
cmdret

It woorks
Thank you sooo muchhhh <3
Edit: How do you know how many bytes you need for allocate?
 

KamikazeSripterul

Well-known member
Joined
Jun 30, 2019
Messages
353
Reaction score
23
Code:
if SAMP.DialogRespond(830, 20@, 0, 25@)
    then
        if 20@ == 1
        then
            0C1A: 26@ = atoi 25@
            0AF1: write_int 26@ to_ini_file "cleo\ServerCMD.ini" section "Bank" key "idtransfer"
            if SAMP.IsPlayerConnected(19@)
            then
                0B36: samp 1@ = get_player_nickname 19@
                0AC8: 2@ = allocate_memory_size 260

                0AD3: 2@ = format "{000089}[{770089}Bank Manager{000089}]: Transferring to %s [ID: %d]" 1@ 19@
                SAMP.ShowDialog(840, 2@, "Please insert the amount of money you'd like to transfer", "Transfer", "Back", 1)
            else
                if 20@ == 0
                then
                    chatmsg "{000089}[{770089}Bank Manager{000089}]: {ff9000}Transaction has been cancelled." -1
                    end
                end
            end
            0C11: memset destination 25@ value 0 size 50
        end

I think I did something wrong but it doesn't work as i expected :<
 

shanker

Well-known member
Joined
Sep 18, 2016
Messages
291
Reaction score
16
Location
Romania
First of all, if your code is in a loop, make sure you free your allocated memory.
Can you give me a pic with your result?
 

shanker

Well-known member
Joined
Sep 18, 2016
Messages
291
Reaction score
16
Location
Romania
In your example code I don't see any problem.

Use chatmsg 2@ -1 right before SAMP.ShowDialog to see if string looks like you expect to.
 
Top