[Include] iCOO - CountOriginalObjects
#1

iCOO

iCOO - only one function, to count your CreateObject objects.

Function:
CountOriginalObjects();
Returns how many original objects are created.

Include it under #include <a_samp> line

Pastebin: http://pastebin.com/ge17bNFG
Reply
#2

You don't take into account that objects can be destroyed at any time.

Just make a function that loops through all id's from 1 to 1000. Check with 'IsValidObject(objectid)' and up the variable by one each time the statement is true.

Important note: this method will give an incorrect value when using a streamer.

EDIT: Fixed mistake pointed out by ******.
Reply
#3

Quote:
Originally Posted by ******
Посмотреть сообщение
That method will almost always give an incorrect value! If you create 5, destroy the first 2, then create a new one there's nothing stopping the system reusing the first ID meaning that looping to it will only return "1".
In that case you have to check from id 1 to 1000.
Reply
#4

Quote:
Originally Posted by ******
Посмотреть сообщение
What about when you've already hooked CreateObject? Or DestryObject? Or objects that don't get created for some reason? Or filterscripts? Or streamer objects?
Yep, you're right. I've never thought about that, because i haven't hooked CreateObject
Reply
#5

stock CountCreatedObjects() {
- new Objects = 0;
-
- for(new objectid = 0; objectid < MAX_OBJECTS; objectid++) {
- - if(IsValidObject(objectid)) Objects++;
- }
-
- return Objects;
}
Note: Every - is an indent.

Something like that... I guess.
Reply
#6

In my honest opinion, hooking > looping. This should of been posted in the useful functions thread anyway
Reply
#7

Nice job iWhiti.
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)