CLEO Help How to count actors?

CLEO related
Status
Not open for further replies.

monday

Expert
Joined
Jun 23, 2014
Messages
1,127
Solutions
1
Reaction score
158
I'm trying to find a way to count how many actors are around but I have no idea how to do it
 

monday

Expert
Joined
Jun 23, 2014
Messages
1,127
Solutions
1
Reaction score
158
I tried to use the code below but it shows few thousands streamed players on the server with only 40 people online

Code:
 {$CLEO .cs}

0000: NOP

:Main
wait 0
if
0AB0:   key_pressed 49
jf @Main
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@
// GOT THE PED.

        for 0@ = 0 to 999
     if 0B23: samp is_player_connected 0@
     then 
           if 0B20: samp 1@ = actor_handle_by_samp_player_id 0@
           then 31@++
           end
     end
end
0AD1: "%d streamed players" 1000 31@

    end
end
// FOR ALL PEDS END
jump @Main
 

PopandaulX

Active member
Joined
Jul 15, 2013
Messages
189
Reaction score
1
monday link said:
I tried to use the code below but it shows few thousands streamed players on the server with only 40 people online

Code:
 {$CLEO .cs}

0000: NOP

:Main
wait 0
if
0AB0:   key_pressed 49
jf @Main
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@
// GOT THE PED.

        for 0@ = 0 to 999
     if 0B23: samp is_player_connected 0@
     then 
           if 0B20: samp 1@ = actor_handle_by_samp_player_id 0@
           then 31@++
           end
     end
end
0AD1: "%d streamed players" 1000 31@

    end
end
// FOR ALL PEDS END
jump @Main

31@ will return the streamed actors' handle (each one, in the repetitive structure), so just add
1@ += 1 in that "for" of the snippet.

Btw, you have to give a starting value to your counter, (counter which is NOT 31@, but make a new variable, 1@) . So it will be like:

Code:
{$CLEO .cs}

0000: NOP

:Main
wait 0
1@ = 0
if
0AB0:   key_pressed 49
jf @Main
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@
    1@ += 1
    end
end
0AD1: "%d streamed players" 1000 1@
jump @Main

Oh, and I've answered you about that Draw Bar snippet, I fixed your code...Actually rewritten it...
 

monday

Expert
Joined
Jun 23, 2014
Messages
1,127
Solutions
1
Reaction score
158
Thank you both, both codes work properly:)
Btw just to make sure I didn't misunderstand it, could you tell me if that's right:
"for 0@ = 0 to 999" circles/loops all over again until it reaches 999 value and every time the conditions are fulfilled it "leaves" +1 to the value of the counter?
 

PopandaulX

Active member
Joined
Jul 15, 2013
Messages
189
Reaction score
1
monday link said:
Thank you both, both codes work properly:)
Btw just to make sure I didn't misunderstand it, could you tell me if that's right:
"for 0@ = 0 to 999" circles/loops all over again until it reaches 999 value and every time the conditions are fulfilled it "leaves" +1 to the value of the counter?

Yep...Just don't modify the "0@" while it's in loop.
 
Status
Not open for further replies.
Top