CLEO Help Read string from dialog?

CLEO related
Status
Not open for further replies.

ThatTrollGuy

Member
Joined
Mar 25, 2017
Messages
7
Reaction score
0
Hello guys, is it possible to make a script that reads a string from a dialog and stores it?
If yes could someone please show me how?

For an example The number of kills is : *number*, and store that number.

Thanks!
 

ThatTrollGuy

Member
Joined
Mar 25, 2017
Messages
7
Reaction score
0
Alright, thank you very much for the fast responses! This may be locked.


Actually i need help again, i did it like this :

while true
wait 0
if
key_down 0x61
then
wait 200
0AF9: samp say_msg "/stats"
wait 200
0BD7: samp get_dialog_text 0@
0AD4: 33@ = scan_string 0@v format "Kills: %d" 5@ //IF and SET
wait 200
0B4B: samp set_current_dialog_editbox_text 5@
wait 200
0B47: samp close_current_dialog_with_button 1@
wait 200
jump @START
end
end

and i get
Warning(s007): Exception 0xC0000005 at 0x4077660
approx when the text is to be read and written that pops up.
Any help?
 
Joined
Dec 31, 2015
Messages
712
Reaction score
27
Allocate memory for 0@ before while true
alloc 0@ 256
Also 0B4B accepts only strings, I didn't test it but think it wont accept an int value
 

ThatTrollGuy

Member
Joined
Mar 25, 2017
Messages
7
Reaction score
0
Yep tested, the problem was in the memory. Now it won't enter the number, what you said, it doesn't accept integers. Is there any solution to this?
 
Joined
Dec 31, 2015
Messages
712
Reaction score
27
ThatTrollGuy said:
Yep tested, the problem was in the memory. Now it won't enter the number, what you said, it doesn't accept integers. Is there any solution to this?

format 0@ "%i" 5@
or
0C1C: 0@ = itoa 5@ radix 10
 

ThatTrollGuy

Member
Joined
Mar 25, 2017
Messages
7
Reaction score
0
Can i just put %i at this line instead of %d

0AD4: 33@ = scan_string 0@v format "Kills: %d" 5@ //IF and SET

so it'll be Kills: %i


How exactly will the code look when i add the format thing? I'm a bit confused
 
Joined
Dec 31, 2015
Messages
712
Reaction score
27
ThatTrollGuy said:
Can i just put %i at this line instead of %d

0AD4: 33@ = scan_string 0@v format "Kills: %d" 5@ //IF and SET

so it'll be Kills: %i

IIRC 'd' goes for decimal i.e. number system measurement = 10, might be wrong also
 

Edvincik

Well-known member
Joined
Mar 15, 2016
Messages
399
Reaction score
27
while true
wait 0 
if 
key_down 0x61
then
wait 200
0AF9: samp say_msg "/stats"
wait 200
0BD7: samp get_dialog_text 0@
0AD4: 33@ = scan_string 0@v format "Kills: %d" 5@ //IF and SET
wait 200
alloc 2@ 8
format 2@ "%d" 5@
0B4B: samp set_current_dialog_editbox_text 2@
wait 200
0B47: samp close_current_dialog_with_button 1@
wait 200
free 2@
jump @Start
end
end
 

ThatTrollGuy

Member
Joined
Mar 25, 2017
Messages
7
Reaction score
0
Alright, tried to debug, the problem occurs when I try to scan the string and withdraw the integer from the string. It just shows 0, any help?


FIXED, got it to work. Thank you so much Malchik and supahdupahnubah for your help!
 
Status
Not open for further replies.
Top