CLEO Help [SA:MP] Read chat and auto reply

CLEO related
Status
Not open for further replies.

RewardK

Member
Joined
Jun 2, 2018
Messages
13
Reaction score
0
Hello UG-Base!

From now, sorry for my bad english.

What i want to do: 
- when a faction member connects, in chat appears next message: "(Group): x from your group has just logged in.".
So, i want to select x's name and auto type (/r is faction chat) "/r Hello, @x. Welcome to the server!", x being user that logged.


Can i do that? I tried 2-3 days, with another forums, but i can't.

I tried a lot and this script came out: 

Code:
{$CLEO .cs}
{$INCLUDE SF}
0000:
repeat
wait 0
until 0AFA:  is_samp_available
0B34: samp register_client_command "activate" to_label @activate


0BE3: raknet setup_incoming_rpc_hook @on_new_chatline

:First
wait 0  

if and
31@ == 1
30@ == 1
then
31@ = 0
0AC8: 0@ = allocate_memory_size 260
0AB1: @GETCHATENTRYTEXT 1 id 99 to 0@  

   if
   0AD4: 2@ = scan_string 0@ format "(Group): Reward from your group has just logged in." 1@
   then
   0AF9: samp say_msg "test" 
   end
0AC9: free_allocated_memory 0@   
end
jump @First

:activate
0B12: 30@ = 30@ XOR 1
samp.CmdRet

:on_new_chatline
0BE5: raknet 29@ = get_hook_param PARAM_PACKETID
if 29@ == RPC_ScrClientMessage
then
31@ = 1
end
0BE0: raknet hook_ret true


:getChatEntryText
0AF7: samp 1@ = get_base
1@ += 0x212A6C
0A8D: 1@ = read_memory 1@ size 4 virtual_protect 0
1@ += 0x136
0@ *= 252 // size of stChatEntry
005A: 1@ += 0@ // (int)
1@ += 28
0AB2: 1 1@

And gives me that error: https://imgur.com/a/AkXNku7

Thanks in advice!

@springfield
 

Krc

Active member
Joined
Mar 30, 2018
Messages
193
Reaction score
25
Location
Lithuania
Code:
{$CLEO .cs}
0000: NOP
REPEAT
Wait 0
Until 0AFA: is_samp_structures_available
0B34: "activate" @ACTIVE
1@ = FALSE

While True
Wait 0
If and
1@ == TRUE
0B61: samp is_local_player_spawned
Then
0AC8: 2@ = allocate_memory_size 260
0AC8: 3@ = allocate_memory_size 260 
0B75: samp get_chat_string 99 text_to 2@ prefix_to 3@ color_to 4@ prefix_color_to 5@  
If                                                              
0AD4: $NOT_USED = scan_string 2@ format "(Group): %s from your group has just logged in." 6@                      
then                                
0AD4: $NOT_USED = scan_string 6@ format "%[^_]_%[^_]" 10@v 20@v // 10@v - First name | 20@v - Last name
wait 200 
say "/r Hello, %s Welcome to the server!" 10@v
end 
end 
END  

:ACTIVE
0B12: 1@ = 1@ XOR TRUE
If
1@ == TRUE
Then
0ACD: show_text_highpriority "~W~Auto Hello: ~G~ON~W~" time 1000
else
0ACD: show_text_highpriority "~W~Auto Hello: ~R~OFF~W~" time 1000
end
CmdRet
 

RewardK

Member
Joined
Jun 2, 2018
Messages
13
Reaction score
0
kazkaS said:
Code:
{$CLEO .cs}
0000: NOP
REPEAT
Wait 0
Until 0AFA: is_samp_structures_available
0B34: "activate" @ACTIVE
1@ = FALSE

While True
Wait 0
If and
1@ == TRUE
0B61: samp is_local_player_spawned
Then
0AC8: 2@ = allocate_memory_size 260
0AC8: 3@ = allocate_memory_size 260 
0B75: samp get_chat_string 99 text_to 2@ prefix_to 3@ color_to 4@ prefix_color_to 5@  
If                                                              
0AD4: $NOT_USED = scan_string 2@ format "(Group): %s from your group has just logged in." 6@                      
then                                
0AD4: $NOT_USED = scan_string 6@ format "%[^_]_%[^_]" 10@v 20@v // 10@v - First name | 20@v - Last name
wait 200 
say "/r Hello, %s Welcome to the server!" 10@v
end 
end 
END  

:ACTIVE
0B12: 1@ = 1@ XOR TRUE
If
1@ == TRUE
Then
0ACD: show_text_highpriority "~W~Auto Hello: ~G~ON~W~" time 1000
else
0ACD: show_text_highpriority "~W~Auto Hello: ~R~OFF~W~" time 1000
end
CmdRet

thank you very much dude! my respect!
 

monday

Expert
Joined
Jun 23, 2014
Messages
1,127
Solutions
1
Reaction score
158
btw isn't 20@v going to contain all 16 chars regardless of surname length?

I guess it should have [^ ] instead of [^_] in order to match all characters that are not an empty space (instead of matching all characters that are not an underscore)

so it would be something like "%[^_]_%[^ ]"
 

RewardK

Member
Joined
Jun 2, 2018
Messages
13
Reaction score
0
kazkaS said:
Code:
{$CLEO .cs}
0000: NOP
REPEAT
Wait 0
Until 0AFA: is_samp_structures_available
0B34: "activate" @ACTIVE
1@ = FALSE

While True
Wait 0
If and
1@ == TRUE
0B61: samp is_local_player_spawned
Then
0AC8: 2@ = allocate_memory_size 260
0AC8: 3@ = allocate_memory_size 260 
0B75: samp get_chat_string 99 text_to 2@ prefix_to 3@ color_to 4@ prefix_color_to 5@  
If                                                              
0AD4: $NOT_USED = scan_string 2@ format "(Group): %s from your group has just logged in." 6@                      
then                                
0AD4: $NOT_USED = scan_string 6@ format "%[^_]_%[^_]" 10@v 20@v // 10@v - First name | 20@v - Last name
wait 200 
say "/r Hello, %s Welcome to the server!" 10@v
end 
end 
END  

:ACTIVE
0B12: 1@ = 1@ XOR TRUE
If
1@ == TRUE
Then
0ACD: show_text_highpriority "~W~Auto Hello: ~G~ON~W~" time 1000
else
0ACD: show_text_highpriority "~W~Auto Hello: ~R~OFF~W~" time 1000
end
CmdRet

But it's a problem. This is not a RP server. Names aren't like First_Second. Only name, like my nickname, "Reward".
Does not work, crash my game, can u make one for only one name?


monday said:
btw isn't 20@v going to contain all 16 chars regardless of surname length?

I guess it should have [^ ] instead of [^_] in order to match all characters that are not an empty space (instead of matching all characters that are not an underscore)

so it would be something like "%[^_]_%[^ ]"

But it's a problem. This is not a RP server. Names aren't like First_Second. Only name, like my nickname, "Reward".
Does not work, crash my game, can u make one for only one name?



It's a Role-Play Gaming server.
 

monday

Expert
Joined
Jun 23, 2014
Messages
1,127
Solutions
1
Reaction score
158
is there nicknames with multiple words on this server? In other words, can nickname contain a space character?


Code:
{$CLEO}
{$INCLUDE SF}
0000:
repeat
wait 50
until 0AFA:  is_samp_available
0B34: samp register_client_command "activate" to_label @activate
0BE3: raknet setup_incoming_rpc_hook @on_new_chatline

0AC8: 31@ = allocate_memory_size 260 //chatline
0AC8: 30@ = allocate_memory_size 64 //name
 
27@ = 1 // makes the mod activated after launching the game
 
while true
wait 0
    if and
    27@ == 1
    24@ == 1
    then
    24@ = 0 
    samp.GetChatString(99, 31@, 0, 0, 0)     
        if and
        0C18: $NOT_USED = strstr string1 31@ string2 "(Group): "
        0C18: $NOT_USED = strstr string1 31@ string2 "from your group has just logged in." 
        then
        0AA5: call 0x8220AD num_params 3 pop 3 30@ "(Group): %[^ ] from your group has just logged in." 31@
        say "/r Hello, %s Welcome to the server!" 30@ 
        end
    end
end

:activate
0B12: 27@ = 27@ XOR 1
if 27@ == 1
then
0AD1: show_formatted_text_highpriority "activated" time 700 
else
0AD1: show_formatted_text_highpriority "deactivated" time 700
end
samp.CmdRet

:on_new_chatline
0BE5: raknet 23@ = get_hook_param PARAM_PACKETID
if 23@ == RPC_ScrClientMessage
then
24@ = 1
end
0BE0: raknet hook_ret true
idk if it will work but it's worth a try

@kazkaS
Code:
If                                                              
 0AD4: $NOT_USED = scan_string 2@ format "(Group): %s from your group has just logged in." 6@  
if I remember correctly the %s in this line is "character hungry", it will "eat" all the characters after the name, that's why regular expression like %[^ ] could be used to "stop" before empty space
 

Edvincik

Well-known member
Joined
Mar 15, 2016
Messages
399
Reaction score
26
@RewardK

{$CLEO .cs}
0000:

REPEAT
   WAIT 0
UNTIL 0AFA:  SAMP_IS_READY
 
WHILE TRUE
WAIT 0

0AC8: 0@ = allocate_memory_size 260
0AC8: 1@ = allocate_memory_size 260
0AC8: 5@ = 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: $NOT_USED = scan_string 0@ format "%s: %s from your group has just logged in." $NOT_USED 4@v
THEN
wait 1000
format 5@ "/r Hello, %s. Welcome to the server!" 4@v
say 5@
wait 1000
END

0AC9: free_allocated_memory 0@
0AC9: free_allocated_memory 1@
0AC9: free_allocated_memory 5@

END
 
Status
Not open for further replies.
Top