CLEO Help Detect when i talk in chat

CLEO related
Status
Not open for further replies.

Ravenous

Active member
Joined
Jan 21, 2016
Messages
61
Reaction score
4
I want to perform an action when i talk in the normal chat, is there any way to detect that i sent a message in normal chat?

I want to exclude all commands from this detection for example: If i say "hello" i want to trigger the detection but "/r hello" which sends a message trough the radio on my server to not trigger anything.
 
Joined
Dec 31, 2015
Messages
712
Reaction score
27
Ravenous said:
I want to perform an action when i talk in the normal chat, is there any way to detect that i sent a message in normal chat?

I want to exclude all commands from this detection for example: If i say "hello" i want to trigger the detection but "/r hello" which sends a message trough the radio on my server to not trigger anything.

1. Func hook
2. Simple chat line scanning

First is easier way but requires some knowlege in this sphere, but I can't really say if it's possible in cleo, and if it's possible, then it's probably requires some asm\byte shiet
Second requires some deep-shit-string scanning, especially if it's RP server

For example here I did simple script that parses an ID of player out of chat line if he says something in normal chat (works only on the server where I'm playing but if edit this a bit, could work on server that you want)

Code:
if and
13@ == 1 //activation var
3@ == -1644826 //opcode 0B75: gets chat line with it's color and prefix, so I check if this line colored in the color I need
0C18: 0@ = strstr string1 11@ string2 "] говорит: +"  //trigger, the normal chat phrase here looks like "%Nickname%[%ID%] говорит: %message%"
then
0C19: 0@ = strcspn string1 11@ string2 ":" //get's the position of ":" symbol
0@ -= 9 //takes 9 out of number with the position of ":" in line
0C24: strncpy destination 11@ source 11@ size 0@ //simply replaces itself with the string with size of 0@ so now it's looks like %Nickname%[%ID%
0C2D: strrev in 11@ out 11@ //reverses string, i did this in case nickname will contains [ ]
0C19: 0@ = strcspn string1 11@ string2 "[" //gets entry of the "[" symbol, because string now looks like %reversed_ID%[%reversed_nickname%
0C24: strncpy destination 11@ source 11@ size 0@ //replaces itself with everything that comes before "["
0C2D: strrev in 11@ out 11@ //reverses it again, i could add 0C1A opcode, but i still need this number as a string

//forget about this code, this is part of my script
0AC8: 15@ = 64
format 15@ "/selldrugs %s %s %s" 11@ 12@ 14@
0AF9: samp say_msg 15@ 
0AC9: 15@
//
wait 50
end

I shared this in order you want to see how to work with strings, you can simply edit it for yourself, and as I remember this isn't request section, right?
Of course it's a bit buggy and hard to do but I don't know any other ways to scan string, so I think @springfield will throw even simpliest method than mine

UPD: If you don't know, these Opcodes requires SAMPFUNC
UPD2: If on your server normal chat phrase has unique color (a color that is not involved in other messages) so you can simply get this color by debugging with 0B75 opcode and check if it's the color of normal phrase whenever you say something in chat

Code:
0AC8: 0@ = 256
0B75: samp get_chat_string 99 text_to 0@ prefix_to 0 color_to 1@ prefix_color_to 0
if and
0C18: 2@ = strstr string1 0@ string2 "%your_nickname%"
1@ == %color%
then
//ACTION!
end
0AC9: 0@ 
 
Status
Not open for further replies.
Top