CLEO Help Read from chat

CLEO related
Status
Not open for further replies.

renko

Active member
Joined
Jul 8, 2014
Messages
58
Reaction score
0
I want to make a mod that when i recive a msg in chat send a command back.
Ex: Someone offers me a gun on a server and i have to type something like /accept gun ID and the server msg sounds like this "* Arms Dealer X offered you a M4 for 1$. User (/accept gun ID).".

So my question is how can i get the ID from that string.
 

pepeelpubero

Well-known member
Joined
Jan 21, 2014
Messages
433
Reaction score
1
Put EXACTLY what the server says when a player offers you a gun.

Here is a code to test it: it will read the last line on the chat, i don't know how to read other.

Writing "pepe" as a cheat for SP the cleo add a message to the chat (client not server). The cleo will read the last line (the message) then add other message and send the command.

Code:
{$CLEO .cs}

0000: NOP

:PEPE_26
wait 0
if 
0ADC:   test_cheat "pepe"
else_jump @PEPE_39
0AF8: "Arms dealer: pepeelpubero - ID 29 - offered you a M4 for 1$. Use (/accept gun)" 0xCF0300 //this will add a message to the chat simulating the 
server msg when a player offers you a gun
goto @PEPE_26

:PEPE_39
wait 500
0AC8: 0@ = allocate_memory_size 260
0AB1: call @getChatEntryText 1 id 99 to 0@
if 
0AD4: 30@ = scan_string 0@ format "Arms dealer: pepeelpubero - ID %d - offered you a M4 for 1$. Use (/accept gun id)" 5@ // this will read 
the message from the chat, the one we put above
else_jump @PEPE_26
0AF9: "/accept gun %d" 5@ //this will send the command with the id of the player who offers you a gun
0AF8: "You have accepted the gun from the player ID %d" 0xCF0300 5@  
0AC9: free_allocated_memory 0@
goto @PEPE_39

:getChatEntryText
wait 500
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@

Here is an example of what we are doing:
6n7vj96.png


below or above of "You have accepted the gun from the player ID" will send the command /accept gun id <- here is id 14.

But i don't know how to get the player name or read other line, if i put %s gives me two warnings.
 

Attachments

  • testtttt.cs
    18.4 KB · Views: 30

renko

Active member
Joined
Jul 8, 2014
Messages
58
Reaction score
0
pepeelpubero link said:
Put EXACTLY what the server says when a player offers you a gun.

Here is a code to test it: it will read the last line on the chat, i don't know how to read other.

Writing "pepe" as a cheat for SP the cleo add a message to the chat (client not server). The cleo will read the last line (the message) then add other message and send the command.

Code:
{$CLEO .cs}

0000: NOP

:PEPE_26
wait 0
if 
0ADC:   test_cheat "pepe"
else_jump @PEPE_39
0AF8: "Arms dealer: pepeelpubero - ID 29 - offered you a M4 for 1$. Use (/accept gun)" 0xCF0300 //this will add a message to the chat simulating the 
server msg when a player offers you a gun
goto @PEPE_26

:PEPE_39
wait 500
0AC8: 0@ = allocate_memory_size 260
0AB1: call @getChatEntryText 1 id 99 to 0@
if 
0AD4: 30@ = scan_string 0@ format "Arms dealer: pepeelpubero - ID %d - offered you a M4 for 1$. Use (/accept gun id)" 5@ // this will read 
the message from the chat, the one we put above
else_jump @PEPE_26
0AF9: "/accept gun %d" 5@ //this will send the command with the id of the player who offers you a gun
0AF8: "You have accepted the gun from the player ID %d" 0xCF0300 5@  
0AC9: free_allocated_memory 0@
goto @PEPE_39

:getChatEntryText
wait 500
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@

Here is an example of what we are doing:
6n7vj96.png


below or above of "You have accepted the gun from the player ID" will send the command /accept gun id <- here is id 14.

But i don't know how to get the player name or read other line, if i put %s gives me two warnings.
Yea, but i want it to work for all players and weapons name. I mean, if every player on that server gives me a weapon it will accept automatically.
My pattern is for example: "* Arms dealer Vennom offered you a M4 for 1$. User (/accept gun 533)."
This is our pattern
 

ThermaL

Expert
Joined
Oct 23, 2013
Messages
1,593
Reaction score
3
Replace the name, weapon name and price with %s or %d

Like this:
0AD4: 30@ = scan_string 0@ format "Arms dealer: %s - ID %d - offered you a %s for $%d. Use (/accept gun id)" 2@ 5@ 3@ 4@
else_jump @PEPE_26
0AF9: "/accept gun %d" 5@
 

renko

Active member
Joined
Jul 8, 2014
Messages
58
Reaction score
0
TH3RM4L link said:
Replace the name with %s

Like this:
0AD4: 30@ = scan_string 0@ format "Arms dealer: %s - ID %d - offered you a %s for $%d. Use (/accept gun id)" 2@ 5@ 3@ 4@
else_jump @PEPE_26
0AF9: "/accept gun %d" 5@

yes, i solved that and here is my code right now:

Code:
{$CLEO .cs}

0000: NOP
thread 'Accept'
7@ = 0

:PEPE_39
wait 0
//Verificare on/off
 if and
   7@ == 0
   0ADC: test_cheat "agun"  
   then
   7@ = 1
   0ACD: show_text_highpriority "Accept gun ~g~enabled~w~" time 3500
   else
      if and
      7@ == 1
      0ADC: test_cheat "dgun" 
      then
      7@ = 0
      0ACD: show_text_highpriority "Accept gun ~r~disabled~w~" time 3500
      end
   end

   if 7@ == 1 
   then
0AC8: 0@ = allocate_memory_size 260
0AB1: call @getChatEntryText 1 id 99 to 0@
if 
0AD4: 30@ = scan_string 0@ format "* Arms dealer %s offered you a M4 for 1$. Use (/accept gun %d)" 5@v 6@ 
else_jump @PEPE_39
0AF9: "/accept gun %d" 6@ //this will send the command with the id of the player who offers you a gun
//0AF8: "You have accepted the gun from %s ID %d" 0xCF0300 5@v 6@  
0AC9: free_allocated_memory 0@
end
goto @PEPE_39

:getChatEntryText
wait 500
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@
But when a player give me a weapon and the server sends that message it isn't working :-??

Maybe it will work better with samp funcs :-??
 

ThermaL

Expert
Joined
Oct 23, 2013
Messages
1,593
Reaction score
3
I think this should work:

Code:
{$CLEO .cs}

0000: NOP

:ON
wait 0
if
0ADC: test_cheat "agun"  
jf @ON
0ACD: show_text_highpriority "Accept gun ~g~enabled" time 3500
goto @MAIN

:MAIN
wait 0
0AC8: 0@ = allocate_memory_size 260
0AB1: call @getChatEntryText 1 id 99 to 0@
if 
0AD4: 30@ = scan_string 0@ format "* Arms dealer %s offered you a M4 for 1$. Use (/accept gun %d)" 5@v 6@ 
jf @OFF
0AF9: "/accept gun %d" 6@
0AC9: free_allocated_memory 0@
goto @OFF

:OFF
wait 0
if
0ADC: test_cheat "dgun" 
jf @MAIN
0ACD: show_text_highpriority "Accept gun ~r~disabled~w~" time 3500
goto @ON


:getChatEntryText
wait 500
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@
 

renko

Active member
Joined
Jul 8, 2014
Messages
58
Reaction score
0
TH3RM4L link said:
I think this should work:

Code:
{$CLEO .cs}

0000: NOP

:ON
wait 0
if
0ADC: test_cheat "agun"  
jf @ON
0ACD: show_text_highpriority "Accept gun ~g~enabled" time 3500
goto @MAIN

:MAIN
wait 0
0AC8: 0@ = allocate_memory_size 260
0AB1: call @getChatEntryText 1 id 99 to 0@
if 
0AD4: 30@ = scan_string 0@ format "* Arms dealer %s offered you a M4 for 1$. Use (/accept gun %d)" 5@v 6@ 
jf @OFF
0AF9: "/accept gun %d" 6@
0AC9: free_allocated_memory 0@
goto @OFF

:OFF
wait 0
if
0ADC: test_cheat "dgun" 
jf @MAIN
0ACD: show_text_highpriority "Accept gun ~r~disabled~w~" time 3500
goto @ON


:getChatEntryText
wait 500
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@
I used your code and....it isn't working here...Look:
aYTbdOt.jpg
 

Crokit

Active member
Joined
Jun 20, 2014
Messages
37
Reaction score
0
Vennom link said:
[quote author=TH3RM4L link=topic=8216.msg47196#msg47196 date=1405079697]
I think this should work:

Code:
{$CLEO .cs}

0000: NOP

:ON
wait 0
if
0ADC: test_cheat "agun"  
jf @ON
0ACD: show_text_highpriority "Accept gun ~g~enabled" time 3500
goto @MAIN

:MAIN
wait 0
0AC8: 0@ = allocate_memory_size 260
0AB1: call @getChatEntryText 1 id 99 to 0@
if 
0AD4: 30@ = scan_string 0@ format "* Arms dealer %s offered you a M4 for 1$. Use (/accept gun %d)" 5@v 6@ 
jf @OFF
0AF9: "/accept gun %d" 6@
0AC9: free_allocated_memory 0@
goto @OFF

:OFF
wait 0
if
0ADC: test_cheat "dgun" 
jf @MAIN
0ACD: show_text_highpriority "Accept gun ~r~disabled~w~" time 3500
goto @ON


:getChatEntryText
wait 500
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@
I used your code and....it isn't working here...Look:
aYTbdOt.jpg

[/quote]
It's missing dot at the end of sentenc

try
Code:
0AD4: 30@ = scan_string 0@ format "* Arms dealer %s offered you a M4 for 1$. Use (/accept gun %d)" 5@v 6@
should be
Code:
0AD4: 30@ = scan_string 0@ format "* Arms dealer %s offered you a M4 for 1$. Use (/accept gun %d)." 5@v 6@

myb idk
 

renko

Active member
Joined
Jul 8, 2014
Messages
58
Reaction score
0
Crokit link said:
[quote author=Vennom link=topic=8216.msg47210#msg47210 date=1405084026]
[quote author=TH3RM4L link=topic=8216.msg47196#msg47196 date=1405079697]
I think this should work:

Code:
{$CLEO .cs}

0000: NOP

:ON
wait 0
if
0ADC: test_cheat "agun"  
jf @ON
0ACD: show_text_highpriority "Accept gun ~g~enabled" time 3500
goto @MAIN

:MAIN
wait 0
0AC8: 0@ = allocate_memory_size 260
0AB1: call @getChatEntryText 1 id 99 to 0@
if 
0AD4: 30@ = scan_string 0@ format "* Arms dealer %s offered you a M4 for 1$. Use (/accept gun %d)" 5@v 6@ 
jf @OFF
0AF9: "/accept gun %d" 6@
0AC9: free_allocated_memory 0@
goto @OFF

:OFF
wait 0
if
0ADC: test_cheat "dgun" 
jf @MAIN
0ACD: show_text_highpriority "Accept gun ~r~disabled~w~" time 3500
goto @ON


:getChatEntryText
wait 500
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@
I used your code and....it isn't working here...Look:
aYTbdOt.jpg

[/quote]
It's missing dot at the end of sentenc

try
Code:
0AD4: 30@ = scan_string 0@ format "* Arms dealer %s offered you a M4 for 1$. Use (/accept gun %d)" 5@v 6@
should be
Code:
0AD4: 30@ = scan_string 0@ format "* Arms dealer %s offered you a M4 for 1$. Use (/accept gun %d)." 5@v 6@

myb idk
[/quote]
Still not working.. :-? it isn't other way to read from chat ? Maybe with sampfuncs
 
Status
Not open for further replies.
Top