CLEO Help remove space after strpbrk

CLEO related
Status
Not open for further replies.

monday

Expert
Joined
Jun 23, 2014
Messages
1,127
Solutions
1
Reaction score
158
strpbrk opcode (0C2B) returns pointer to the first occurence of given character, what space has to be removed?
 

shanker

Well-known member
Joined
Sep 18, 2016
Messages
291
Reaction score
17
Location
Romania
see this screen

https://i.imgur.com/0TplHKS.jpg

deleted char is ":" so that means instead of ":" i have a 'space'

how can i delete that mada fakar space?


[shcode=cpp]
if
0AD4: 33@ = scan_string 4@ format "Event organizer %s" 10@v
then
chatmsg "{9b1414}Debug 1" -1
if
0C29: 33@ = stristr string1 4@ string2 "Event organizer"
then
chatmsg "{9b1414}Debug 2 | {a5107d}Organizer Name: {3d7a71}%s [unextracted]" -1 10@v
alloc 3@ = 600
alloc 5@ = 600
0C13: strcpy destination 3@ source 4@ // we extract event text
0C13: strcpy destination 5@ source 4@ // we extract organizer name

if
0C2B: 6@ = strpbrk string 3@ control ":"
then
0A8C: write_memory 6@ size 1 value 0x0D virtual_protect 0
chatmsg "{8e8987}Probably Organizer text is: {41d379}%s" -1 6@
chatmsg "" -1

if
0C2B: 7@ = strpbrk string 5@ control ":"
then
0A8C: write_memory 7@ size 1 value 0x0D virtual_protect 0 // 27@ text
chatmsg "{a35c1f}String that contains organizer name: {3bd66c}%s" -1 5@
chatmsg "{909326}now trying to extract organizer name" -1
chatmsg "" -1

if
0AD4: 33@ = scan_string 5@ format "Event organizer %s" 8@v
then
chatmsg "{708e7a}Organizer name should be: {3bd66c}%s" -1 8@v
end
end
end
free 3@
free 5@
end
end
[/shcode]
 

monday

Expert
Joined
Jun 23, 2014
Messages
1,127
Solutions
1
Reaction score
158
I am not sure if that's what you're looking for but instead of using 0x0D just write 0 to the pointer of ":" (because strings are null-terminated)
0A8C: write_memory 7@ size 1 value 0 virtual_protect 0

Btw 32 and 33@ variables can be easily used for timing (they automatically increase by 1 every millisecond after being set to some value) so it's better to use 0@ - 31@ for other purposes whenever possible
 

shanker

Well-known member
Joined
Sep 18, 2016
Messages
291
Reaction score
17
Location
Romania
it's working ^^ Ty 4 ur help

do any1 know why i can't alloc manually memory to get any string into my variables with 0ad4?
[shcode=cpp]
// instead of
0AD4: 4@ = scan_string 0@ format "%s" 5@v //IF and SET

// i'd like to use
alloc 5@ = 69
0AD4: 4@ = scan_string 0@ format "%s" 5@
free 5@
but it crashes my game, unknown reason

5@v uses 4 of my upcoming variables, that's so annoying,  although new methods have emerged for more variables which the 
real good part in it is that i can use them anywhere in my script even in a new thread which is in same cleo script ..
[/shcode]
 

shanker

Well-known member
Joined
Sep 18, 2016
Messages
291
Reaction score
17
Location
Romania
monday said:
strpbrk opcode (0C2B) returns pointer to the first occurence of given character, what space has to be removed?

monday said:
I am not sure if that's what you're looking for but instead of using 0x0D just write 0 to the pointer of ":" (because strings are null-terminated)
0A8C: write_memory 7@ size 1 value 0 virtual_protect 0

Btw 32 and 33@ variables can be easily used for timing (they automatically increase by 1 every millisecond after being set to some value) so it's better to use 0@ - 31@ for other purposes whenever possible

i have found a better way to remove first space
check here https://imgur.com/a/f37Jb // use strchr and search for 0x20 and read the returned pointer
 
Status
Not open for further replies.
Top