CLEO Help Help reading chat lines in-game.

CLEO related
Status
Not open for further replies.

DavidRO99

Active member
Joined
Nov 5, 2017
Messages
60
Reaction score
8
I have been trying this for like 2 hours now. I dont care if it is in CLEO or SAMPFUNCS C++, I just want a working example, please. I want to read the chat using a script and then auto-respond with a text.
 

DavidRO99

Active member
Joined
Nov 5, 2017
Messages
60
Reaction score
8
[shcode=cpp]{$CLEO .cs}
0000:

while true
wait 0
0AC8: 0@ = allocate_memory_size 260
0AB1: call @getChatEntryText 1 id 99 to 0@
if 0AD4: 30@ = scan_string 0@ format "the phone number is %d" 5@
then
0AF8: "%d" -1 5@
end
0AC9: free_allocated_memory 0@
end

:getChatEntryText
0AA2: 1@ = "samp.dll"
1@ += 0x212A6C
0A8D: 1@ = read_memory 1@ size 4 virtual_protect 0
1@ += 0x136
0@ *= 252
005A: 1@ += 0@ /
1@ += 28
0AB2: ret 1 1@
[/shcode]
That makes my game run slowmotion and doesnt work.
 

Opcode.eXe

Expert
Joined
Feb 18, 2013
Messages
1,486
Reaction score
227
Location
( ͡° ͜ʖ ͡°)
[shcode=cpp]{$CLEO .cs}
0000:


REPEAT
WAIT 0
UNTIL 0AFA: SAMP_IS_READY



WHILE TRUE
WAIT 0
0AC8: 0@ = allocate_memory_size 260
0B75: samp get_chat_string 99 text_to 0@ prefix_to 1@ color_to 2@ prefix_color_to 3@
if 0AD4: 30@ = scan_string 0@ format "the phone number is %d" 5@
then
0AF8: "%d" -1 5@
end
0AC9: free_allocated_memory 0@

END
[/shcode]
 
Joined
Feb 18, 2005
Messages
2,965
Reaction score
271
Use strstr/stristr to get a pointer to the "number is" string, add to it the length, this sould get you the start of the number, then just copy a substring with the number length.
 

shanker

Well-known member
Joined
Sep 18, 2016
Messages
291
Reaction score
16
Location
Romania
[font='Source Sans Pro', Tahoma, 'Helvetica Neue', Arial, sans-serif]DavidRO99,[/font]

[shcode=cpp]

while true
wait 0

   0AC8: 0@ = allocate_memory_size 260
   0B75: samp get_chat_string 99 text_to 0@ -1 -1 -1  
   
   /* 0@ is the whole text every time a new line appear
      now i don't really know what you want to do but you can check if 0@ is equal it another string*/
     
   if 0AD4: 1@ scan string 0@ "Paine prajita. "  // if 0@ == "Paine Prajita" 
   then
       // do something
   end    
end

/* opcodeexe example works fine, im sure you writed in game the phone number is %d, aren't you?
   you forget about the first string that's before "the ...", may be this would be your name/id or idk?

[/shcode]

[shcode=cpp]
// there is an example if some one writes in game paine prajita then script will continue

for 2@ = 0 to 999
1@ = SAMP.GetPlayerNickname(2@)
// alloc, get chat string
 if 0AD4: 3@ scan string 0@ "%s says: Paine prajita. " 1@ // Nume says: Paine prajita.
then 
       // do smt
end
// free mem when you done w/ it
[/shcode]
 
Status
Not open for further replies.
Top