CLEO Help Timing Issues

CLEO related
Status
Not open for further replies.

ItsRobinson

Active member
Joined
Nov 16, 2017
Messages
105
Reaction score
20
So basically I have a section of code inside my while true loop that is supposed to check if a variable is less than 3, if it is then delete a textdraw if it matches the specific criteria, it is only supposed to do this 3 times.
(Basically trying to delete 3 textdraws that make up a server-side healthbar on HZG)

I could delete them via the textdraw specific ID's, but as I have tried that before, the IDs changed on rare occasions. So it isn't an option, the textdraw isn't a valid character either so I can't use the exact string match.

PHP:
while true
wait 0

    if
        3@ < 3
    then
        alloc 2@ 125
        FOR 1@ = 0 TO 2500
            0C5A: samp textdraw 1@ get_string_to 2@
            0C17: 0@ = strlen 2@
            if 0@ < 2
            then
                if 
                    0C14: strcmp string1 2@ string2 "'"
                then
                    continue
                else
                    0C5E: samp textdraw 1@ delete
                    000A: 3@ += 1  
                end
            end
               
        END
        free 2@
    end
//rest of my code follows

If I'm not wrong, this should try and execute this until the 3@ = 3, however, if I don't log in quick enough, it stops looping this, as you can see in the video below.




Any ideas?
 

monday

Expert
Joined
Jun 23, 2014
Messages
1,125
Reaction score
149
there is a range of sampfuncs opcodes that could help you to select and delete the right textdraws, for example:
0C5B: samp textdraw 0@ get_pos 1@ 2@
0C53: samp textdraw 0@ get_box_enabled 1@ color 2@ size 3@ 4@

You could create a mod (e.g. activated by key press) that will print the position (add to chat opcode), "box_enabled", color and size of all textdraws.
Then check the chatlog trying to find the ones that create the HP bar. Then keep the loop going instead of stopping it if 3@ gets over some value, do something like:

Code:
while true
    for all_textdraws
        if and
            x_size == 1st_HP_TEXTDRAW_X_SIZE
            y_size == 1st_HP_TEXTDRAW_y_SIZE
            x_pos == 1st_HP_TEXTDRAW_X_POS
            y_pos == 1st_HP_TEXTDRAW_Y_POS
            color = 1st_HP_TEXTDRAW_COLOR
        then
            delete textdraw
        end
       
        if and
            x_size == 2nd_HP_TEXTDRAW_X_SIZE
            y_size == 2nd_HP_TEXTDRAW_y_SIZE
            x_pos == 2nd_HP_TEXTDRAW_X_POS
            y_pos == 2nd_HP_TEXTDRAW_Y_POS
            color = 2nd_HP_TEXTDRAW_COLOR
        then
            delete textdraw
        end
    end
end

This way you won't accidentally delete some other useful textdraw, also you'll delete the desired textdraws even if they're "respawned".

Btw I guess that the position check itself would be sufficient (no need for 5 checks) but you get the idea
 

Parazitas

God
Joined
Jan 2, 2017
Messages
3,112
Solutions
5
Reaction score
878
Location
Lithuania
By @monday
PHP:
{$CLEO .cs}

0000: NOP

wait 10000

while true
wait 0

for 1@ = 0 to 2304
if 0C5D: samp textdraw 1@ is_exists
then
    0C5B: samp textdraw 1@ get_pos 2@ 3@
    0C53: samp textdraw 1@ get_box_enabled 4@ color 5@ size 6@ 7@
    0AF8: "XY: %f %f Color: %x Size: %f %f" -1 2@ 3@ 5@ 6@ 7@
    if and
    2@ == 250
    3@ == 370
    5@ == 0xFF00FF00
    6@ == 2.5
    7@ == 6.4
    then
        0C5E: samp textdraw 1@ delete
    end
end
end

end
 
Last edited:

ItsRobinson

Active member
Joined
Nov 16, 2017
Messages
105
Reaction score
20
there is a range of sampfuncs opcodes that could help you to select and delete the right textdraws, for example:
0C5B: samp textdraw 0@ get_pos 1@ 2@
0C53: samp textdraw 0@ get_box_enabled 1@ color 2@ size 3@ 4@

You could create a mod (e.g. activated by key press) that will print the position (add to chat opcode), "box_enabled", color and size of all textdraws.
Then check the chatlog trying to find the ones that create the HP bar. Then keep the loop going instead of stopping it if 3@ gets over some value, do something like:

Code:
while true
    for all_textdraws
        if and
            x_size == 1st_HP_TEXTDRAW_X_SIZE
            y_size == 1st_HP_TEXTDRAW_y_SIZE
            x_pos == 1st_HP_TEXTDRAW_X_POS
            y_pos == 1st_HP_TEXTDRAW_Y_POS
            color = 1st_HP_TEXTDRAW_COLOR
        then
            delete textdraw
        end
      
        if and
            x_size == 2nd_HP_TEXTDRAW_X_SIZE
            y_size == 2nd_HP_TEXTDRAW_y_SIZE
            x_pos == 2nd_HP_TEXTDRAW_X_POS
            y_pos == 2nd_HP_TEXTDRAW_Y_POS
            color = 2nd_HP_TEXTDRAW_COLOR
        then
            delete textdraw
        end
    end
end

This way you won't accidentally delete some other useful textdraw, also you'll delete the desired textdraws even if they're "respawned".

Btw I guess that the position check itself would be sufficient (no need for 5 checks) but you get the idea
I tried simply just a position check and it seemed to crash or just not delete the text draw, but I’ll give this idea a try in a little while and let you know how I get on
 

ItsRobinson

Active member
Joined
Nov 16, 2017
Messages
105
Reaction score
20
Server ip?

samp.hzgaming.net:7777

Basically the server has a server-sided health bar that messes up and covers your full HUD or just looks terrible for people with different resolutions and widescreen, so I made a LUA mod for the server a few months back and now I'm simply translating that mod to CLEO as many people have struggled to get the LUA mod to work.

PHP:
    for 1@ = 0 to 2304
        if 0C5D: samp textdraw 1@ is_exists
        then
            0C5B: samp textdraw 1@ get_pos 2@ 3@
            0C53: samp textdraw 1@ get_box_enabled 4@ color 5@ size 6@ 7@
            if and
            0043: 2@ == 610.010010
            0043: 3@ == 68.250000
            5@ == 0xFF000000
            then
                0C5E: samp textdraw 1@ delete
            end
            if and         
            0043: 2@ == 608.010010
            0043: 3@ == 70.250000
            5@ == 0xFF5a0c10
            then
                0C5E: samp textdraw 1@ delete
            end
            if and
            0043: 2@ == 563.367126
            0043: 3@ == 70.250000
            5@ == 0xFFb51821
            then
                0C5E: samp textdraw 1@ delete
            end
        end
    end

This worked perfectly.

Many thanks to you both @monday @Parazitas
 
Status
Not open for further replies.
Top