CLEO Help How to fix bad fps?

CLEO related
Status
Not open for further replies.

niume123456

Member
Joined
Oct 24, 2014
Messages
18
Reaction score
0
I get very bad fps with this. Any way to fix it? This script arrest neareast player.

Code:
{$CLEO .cs}

0000:

repeat
wait 0
until 0AFA:

while true
wait 0

for 0@ = 0 to 1000
    if
    0B23:  samp is_player_connected 0@
    then
        0B36: samp 2@ = get_player_nickname 0@
        0AB1: @GetSurname 1 FullName 2@ _Return: Surname 3@
        if
        0B20: samp 4@ = actor_handle_by_samp_player_id 0@
        then
            if
            056D:   actor 4@ defined
            then
                0AB1: @DistanceBetweenTwoPoints 1 ActorHandle 4@ _Return: Distance 5@
                if
                5@ <= 20.0
                then
                    if
                    0AB0: key_pressed 104 // 104 = Num8
                    then
                        repeat
                        wait 0
                        until 8AB0: key_not_pressed 104 // 104 = Num8
                        say "/isodinti %s" 3@
                    end
                end
            end
        end
    end
end

end


:DistanceBetweenTwoPoints                      
04C4: store_coords_to 1@ 2@ 3@ from_actor 0@ with_offset 0.0 0.0 0.0    
04C4: store_coords_to 4@ 5@ 6@ from_actor $PLAYER_ACTOR with_offset 0.0 0.0 0.0    
0509: 7@ = distance_between_XY 1@ 2@ and_XY  4@ 5@  
0AB2: ret 1 7@
   
:GetSurname
0085: 28@ = 0@ // (int)
0085: 27@ = 0@ // (int)
29@ = 0
for 31@ = 0 to 200
0A8D: 30@ = read_memory 28@ size 1 virtual_protect 1
    if 30@ == 0
    then
    break
    else
    28@++
    29@++
    end

    if 31@ == 200
    then
    //chatmsg "string seems to be over 200 chars" -1
    end
end

for 31@ = 1 to 29@
0A8D: 30@ = read_memory 0@ size 1 virtual_protect 1
    if 30@ == 95 // if the character is "_" (ASCII table)
    then
    0@++
    //chatmsg 0@ -1
    0AB2: ret 1 0@
    else
    0@++
    end  
end
0AB2: ret 1 27@
 

Zin

Expert
Joined
Aug 1, 2013
Messages
1,719
Solutions
1
Reaction score
111
You should put activation before the "FOR" loop else you are constantly looping through and processing the names of every player even if you haven't pressed num8. Infact you'd be better of looping through the ped pool or (GetClosestPed) so you don't loop through the names of like 1000 people.
C++:
{$CLEO .cs}

0000:

REPEAT
    WAIT 0
UNTIL 0AFA:

WHILE TRUE
    WAIT 0

    IF
        0AB0: 104 // NUM8
    THEN
        CALL @GetClosestPed 0 0@
        IF 056D:   actor 0@ defined
        THEN
            0B2B: samp 0@ = get_player_id_by_actor_handle 0@
            0B36: samp 0@ = get_player_nickname 0@
            0AB1: @GetSurname 1 FullName 0@ _Return: Surname 0@
            SAY "/isodinti %s" 0@
            WAIT 1500
        END
    END
    
END


:GetClosestPed // Courtesy of monday
var
0@ : float
5@ : float
end
0@ = 600.0
1@ = -1
 
00A0: $PLAYER_ACTOR 2@ 3@ 4@
 
0A8D: 29@ = read_memory 0xB74490 size 4 virtual_protect 0
000A: 29@ += 0x4
0A8D: 29@ = read_memory 29@ size 4 virtual_protect 0
for 30@ = 0 to 35584 step 0x100
    0A8D: 31@ = read_memory 29@ size 1 virtual_protect 0
    000A: 29@ += 0x1
    if and
        0029:  31@ >= 0x00
        001B:  0x80 > 31@
    then
        005A: 31@ += 30@
        
        if 003B: 31@ == $PLAYER_ACTOR
        then continue
        end
        
        00A0: 31@ 6@ 7@ 8@
        0509: 5@ = distance_between_XY 2@ 3@ 6@ 7@
 
        if 5@ < 0@
        then
            0087: 0@ = 5@
            0085: 1@ = 31@
        end
    end
end
 
0AB2: ret 1 1@
  
:GetSurname
0085: 28@ = 0@ // (int)
0085: 27@ = 0@ // (int)
29@ = 0
for 31@ = 0 to 200
0A8D: 30@ = read_memory 28@ size 1 virtual_protect 1
    if 30@ == 0
    then
    break
    else
    28@++
    29@++
    end

    if 31@ == 200
    then
    //chatmsg "string seems to be over 200 chars" -1
    end
end

for 31@ = 1 to 29@
0A8D: 30@ = read_memory 0@ size 1 virtual_protect 1
    if 30@ == 95 // if the character is "_" (ASCII table)
    then
    0@++
    //chatmsg 0@ -1
    0AB2: ret 1 0@
    else
    0@++
    end 
end
0AB2: ret 1 27@
 

niume123456

Member
Joined
Oct 24, 2014
Messages
18
Reaction score
0
Thank you very much. Other small detail. How to make the script so that it would write Full name? Because sometimes the script doesint work because there are 2 players with same surname
 

Zin

Expert
Joined
Aug 1, 2013
Messages
1,719
Solutions
1
Reaction score
111
Thank you very much. Other small detail. How to make the script so that it would write Full name? Because sometimes the script doesint work because there are 2 players with same surname
Just remove the "GetSurname" part.
 

niume123456

Member
Joined
Oct 24, 2014
Messages
18
Reaction score
0
Then the command doesint work then i write full name would it be possible to make that the script writes the players full name but deletes the last letter of the surname?
 

Zin

Expert
Joined
Aug 1, 2013
Messages
1,719
Solutions
1
Reaction score
111
For example I want to arrest player named Bob_Bobinson I want that the program writes /ant Bob_Bobinso
That snippet removes the last characters from a string. So say you have "Bob_Bobinson" which is 12 characters you put "5" characters into the 0AB1 opcode to get the last 5 characters which would be "inson". But if you want 1 character everytime you use the 0C17 "strlen" opcode to get the length of the players name and then -1 from that length and then use it in the 0AB1 input.
C++:
alloc 0@ 256
0B2B: samp 0@ = get_player_id_by_actor_handle 0@
0B36: samp 0@ = get_player_nickname 0@
0C17: 1@ = strlen 0@
1@ -= 1
0AB1: @GetLastCharacters 2 String 0@ Characters 1@ rnt 0@
SAY "/isodinti %s" 0@
free 0@


:GetLastCharacters
{
    0AB1: @GetLastCharacters 2 String 0@ Characters 5 rnt 1@
}
0AB1: @strlen 1 String 0@ Lenght 2@
0062: 2@ -= 1@
005A: 0@ += 2@
0AB2: ret 1 0@
 
Status
Not open for further replies.
Top