Help Cleo %s not print text

pwpwpwn

Member
Joined
May 4, 2024
Messages
19
Reaction score
0
:text
wait 0
0AC8: 1@ = ALLOCATE_MEMORY_SIZE 300
0B35: samp 0@ = get_last_command_params
0AD4: 0@ = scan_string 0@ format "%s" 1@
0AF8: samp add_message_to_chat "your text: %s" color -1 1@
free_memory 1@
0B43: samp cmd_ret

When i use this /text hello for example prints in chat your text: and then empty nothing
But when i use %d for number works ok, what is the problem? thank you
 

Parazitas

God
Staff member
Joined
Jan 2, 2017
Messages
3,315
Solutions
7
Reaction score
935
Location
Lithuania
When i use this /text hello for example prints in chat your text: and then empty nothing
But when i use %d for number works ok, what is the problem? thank you
PHP:
:text
wait 0
0B35: samp 0@ = get_last_command_params
IF 0AD4: $NOT_USED = scan_string 0@ format "%s" 31@
THEN
    0AF8: samp add_message_to_chat "your text: %s" color -1 31@
END
0B43: samp cmd_ret
 

GoodMan

Active member
Joined
Jun 4, 2014
Messages
151
Reaction score
0
try this, it will show only the first 16 letters.
:text
0B35: samp 0@ = get_last_command_params
IF 0AD4: $NOT_USED = scan_string 0@ format "%s" v$PLAYER_NAME // 16 byte string
THEN
alloc 16@ 24
0AD3: 16@ = format "%s" v$PLAYER_NAME
0AF8: samp add_message_to_chat "your text: %s" color -1 16@
free 16@
END
0B43: samp cmd_ret
 

Zin

Expert
Joined
Aug 1, 2013
Messages
1,720
Solutions
1
Reaction score
111
C++:
{$CLEO .cs}
{$CLEO .cs}

THREAD 'STRING'

0B34: samp register_client_command "TEXT1" to_label @TEXT1
0B34: samp register_client_command "TEXT2" to_label @TEXT2

REPEAT
    WAIT 0
UNTIL 0AFA:

WHILE TRUE
    WAIT 0
    0B35: samp 0@ = get_last_command_params
    LOG 0@
END


:TEXT1
0B35: samp 0@ = get_last_command_params
0AF8: samp add_message_to_chat 0@ -1
SAMP.CmdRet()

:TEXT2
0B35: samp 0@ = get_last_command_params
0AC8: 1@ = allocate_memory_size 260
0AD3: 1@ = format "YOUR TEXT IS %s" 0@
0AF8: samp add_message_to_chat 1@ -1
free 1@
SAMP.CmdRet()
I see why you did it like you did but you need to consider how 0B35 opcode works.
Returns the pointer to the line with the parameters of the last command entered.
IDK if you can even use 0AD4 like the noobs have above (Not entirely sure how it would work in regards to scanning substrings etc). But basically it seems "last_command_params" are already allocated through register client command (proven through "TEXT1" in above code. Combining that string can be done with 0AD3 opcode but does require memory allocation as you're creating a new string.
 
Top