Count Object???
#1

Hey guys i want some help ......when i open my samp-server ....and when everything has loaded i see some lines written like -
Код:
Number Of Vehicles Models:113
Is this the vehicle count

How can i get it for objects so the total object are calculated and it shows like this-
Код:
Number Of Objects Loaded:123455
Help me please !

Thank you for your time !
Reply
#2

pawn Код:
// AT TOP
new objectcount;

// SOMEWHERE. NOT INSIDE A CALLBACK
CreateObjectEx(modelid,Float:X,Float:Y,Float:Z,Float:rX,Float:rY,Float:rZ,Float:DrawDistance = 0.0)
{
    objectcount++;
    CreateObject(modelid,X,Y,Z,rX,rY,rZ,DrawDistance);
}

// AFTER YOU HAVE CREATED ALL OBJECTS
printf("Number of objects created: %d",objectcount);
And change all CreateObject to CreateObjectEx
Reply
#3

Quote:
Originally Posted by Mike Garber
Посмотреть сообщение
pawn Код:
// AT TOP
new objectcount;

// SOMEWHERE. NOT INSIDE A CALLBACK
CreateObjectEx(modelid,Float:X,Float:Y,Float:Z,Float:rX,Float:rY,Float:rZ,Float:DrawDistance = 0.0)
{
    objectcount++;
    CreateObject(modelid,X,Y,Z,rX,rY,rZ,DrawDistance);
}

// AFTER YOU HAVE CREATED ALL OBJECTS
printf("Number of objects created: %d",objectcount);
hmm ....didn't understood nicely........i am using incognito's streamer so what can i do??
copy all the objects any example would be nice!
Reply
#4

There is a native function for that.
pawn Код:
native CountDynamicObjects();
Reply
#5

Quote:
Originally Posted by xRyder
Посмотреть сообщение
There is a native function for that.
pawn Код:
native CountDynamicObjects();
so where to put this?

will this count all my objects? and print it to the server window?
Reply
#6

Try it and you'll find out.

EDIT: But notice that if you create object after counting them like:
pawn Код:
CreateDynamicObject()....
    CreateDynamicObject()....
    CreateDynamicObject()....
    prinf("There are %d objects in your script", CountDynamicObjects());
    CreateDynamicObject()....
it will count like there are 3 objects.

You'll need to create them before calling CountDynamicObjects() function.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)