CLEO Help hello guyz

CLEO related
Status
Not open for further replies.

Rough

Active member
Joined
Mar 7, 2015
Messages
42
Reaction score
4
Hello, I'm starting this topic because I kinda started "programming" in Sanny Builder and I want to learn more and do more complicated things.. So I kinda need a headstart, and by headstart I'm talking about your help guys.. So here is my question,

I want to make a mod that will scan a box. For example, this box

image.png


This box is showing a list of players who have wanted and their time till it's gone and the city they are located in + their wanted level.

Now all i need is like a snippet or some idea which could help me to autoscan this box, (command for this box is /nearwanted) and show me on chat if some one of them is near me, like this

image.png

for ex, if i type /scan
the script will scan that box and show me on chat what is in that box.. or if you have another idea it's welcomed.

All i want to is to learn how to scan and be able to take the thing i scanned and forword it into text.. on line.. like i told you.. or something like that..

with that knowledge i can develop the script more and add like the distance, how much hp he has, and more things like this.

If you could help me or give me an idea i'd be gratefull, so please, help me if you can. Thank you very much and wish you the best.
 
Joined
Dec 31, 2015
Messages
712
Reaction score
27
Rough said:
All i want to is to learn how to scan and be able to take the thing i scanned and forword it into text.. on line.. like i told you.. or something like that..

Register custom command that you need with : 
0B34: samp register_client_command "pew-pew-pew" to_label @cmd_label

Then send command you need to open this dialog to server with :

0AF9: samp say_msg "/i_sleep_with_0x688"

Not sure about this part but create a 3 seconds living loop that will check if dialog has appeared :

Code:
for 5@ = 0 to 30
if 5@ == 30
then
  SAMP.CmdRet()
end
wait 100
if 0B4C: samp is_dialog_active 0@ //0@ = ID
then
  break
end
end

If you don't know where to get dialog ID, use my fresh snippet to debug it (I may be wrong that there's no current dialog ID opcodes) :

Code:
//loop
0AB1: call_scm_func @get_current_dialog_id 0
//loop

:get_current_dialog_id
0AF7: samp 0@ = get_base
0@ += 0x21A0B8
0A8D: 0@ = 0@ 4 1
0@ += 0x28
0A8D: 1@ = 0@ 4 1   //is dialog window active
if 1@ == 0
then
  0AF8: samp add_message_to_chat "> I think you've got the wrong door" 120007 
  0000: NOP "THE LEATHER CLUB IS 2 BLOCKS DOWN, AHHAHAHHAHH..Funny? No? :("  
  ret 0
end 
0@ += 0x8
0A8D: 2@ = 0@ 4 1
0AF8: samp add_message_to_chat "> Current dialog ID : %i" 120007 2@    
0AB2: ret 0

Finally dialog has appeared, get its text and caption with : 

0BD7: samp get_dialog_text 0@
0BD8: samp get_dialog_caption 1@

Since I don't know the server where you playing - you'll have to format output text yourself

Once you done formating, use 0AF8: samp add_message_to_chat 0@v color 1@

Post when you will achieve something with this info so far, I may be wrong, so there's a chance someone will post a better solution and explanation (maybe, this superhero will : @springfield)

P.S. This is not a complete info about your request or whatever you can call it, complete at least this to be able to get just some text from dialog info, then you probably will be ready to move to the next part, however not sure if I will explain other part, cuz it wont be interesting if I'll simply throw the code here
 

Rough

Active member
Joined
Mar 7, 2015
Messages
42
Reaction score
4
Thanks you very much for ideas and explanations. I'll try to make it and see how things are working.

stay cool and thank you again!
 
Joined
Feb 18, 2005
Messages
2,965
Reaction score
273
Welcome to our forum. Normally you should post what you've tried so far, but since you're new we'll make an exception. 
Here's a rather shitty implementation i hastily put together. It should 'tehnically' work, it's an example only, you can extend it yourself.

[shcode=cpp]
{$CLEO}
0000:

repeat  
    wait 100
until 0AFA: samp_loaded

31@ = 0
0B34: "scan" @tryscan

while true
    wait 0
    
    if 31@ == true
    then
        if 0B4C:  samp is_dialog_active -1 
        //-1 == any, we don't really need a specific id 
        then
            alloc 0@ = 64 //max caption text size
            0BD8: samp get_dialog_caption 0@
            //because we're gonna check the dialog title
            if 0AD4: 1@ = scan 0@ format "Suspects: %d" 2@ 
            //this checks if it's the dialog we want, and it also gets us the number of suspects
            // 2@ = num of suspects
            then
                free 0@
                alloc 0@ = 4096 //max dialog text size
                0BD7: samp get_dialog_text 0@
                
                0C17: 1@ = strlen 0@
                if 1@ > 25 // strlen("Wanted\tSuspect\tTime\tZone\n") == 25
                //if the text is less than 25 chars, it means the dialog is empty
                //except the headers -> wanted, suspect etc.
                then
                    0@ += 25 //skip headers
                    1@ -= 25
                    
                    //very shitty implementation 
                    //for each line we have 4 shits(wanted, name, time, zone)
                    //each is delimited by a '\t' char, so that means 3 '\t' per line
                    
                    0AF8: "%d bitches running from da' police" -1 2@
                    
                    for 3@ = 1 to 2@  
                        wait 0
                        
                        if 3@ == 2@
                        then 0C2A: 5@ = strchr 0@ char 0x00 // last line should end with a null char.
                        else 0C2A: 5@ = strchr 0@ char 0x0A // 0x0A = \n each dialog line ends with this.  
                        end
                        
                        if 5@ <> 0
                        then
                            alloc 6@ = 128  
                            0A8F: 7@ = 5@ - 0@
                            0C24: strncpy destination 6@ source 0@ size 7@

                            if 0AD4: 8@ = scan 6@ "%d%*c%*s (%d)%*c%d min%*c%s" 9@ 10@ 11@ 12@s
                            then
                                0AF8: "Player with id %d has %d wanted stars, %d min. until he gtfo, he's in %s" -1 10@ 9@ 11@ 12@s
                                //check if the player is connected with 0B23: samp is_player_connected 10@
                                //then get his name with 0B36: samp 15@ = get_player_nickname 10@                               
                                //check if this player is in the stream zone
                                if 0B20: samp 16@ = actor_handle_by_samp_player_id 10@
                                then
                                    0AF8: "%d is in stream zone" -1 10@
                                    //now you can get his position, vehicle, health, armor etc.
                                end
                            end
                            
                            free 6@                            
                            0A8E: 0@ = 5@ + 1
                        end  
                    end
                end
            else
               31@ = FALSE
            end
            free 0@
        end
    end   
end

:tryscan
0AF9: "/nearwanted" //make server show us the dialog
31@ = 1
0b43: 
[/shcode]

I commented what i thought important, reply if you have any questions about parts of the code.
 

shanker

Well-known member
Joined
Sep 18, 2016
Messages
291
Reaction score
17
Location
Romania
@Springefield,
Code:
 0AF8: "%d bitches running from da\' police" -1 2@
da fck :))

I asked you one time and u didn't told me, probably u didn't saw, how do you make this "
Code:
" looking like that? look these screens: http://imgur.com/a/JJqid

EDIT:[shcode=cpp]NP rough told me how to do it *laugh[/shcode]
 
Status
Not open for further replies.
Top