[Tutorial] Count Object on GM
#1

I will teach guys how to count the objects we have in our server.

-First we create a variable that stores the number of objects

pawn Код:
new OBJECT;
-Then we will call a function to move the objects to be counted CreateObject before

pawn Код:
forward ObjectCount(modelid, Float:X, Float:Y, Float:Z, Float:rX, Float:rY, Float:rZ, Float:DRAW_DISTANCE);
-Now create the function

pawn Код:
public ObjectCount(modelid, Float:X, Float:Y, Float:Z, Float:rX, Float:rY, Float:rZ, Float:DRAW_DISTANCE)
{
    OBJETC++;
    return CreateObject(modelid, X, Y, Z, rX, rY, rZ, DRAW_DISTANCE);
}
-Now we can see in a Dialogue

pawn Код:
new str[3];
format(str, sizeof(3), "%i", OBJECT);
ShowPlayerDialog(playerid, ID, DIALOG_STYLE_MSGBOX, "Object", str, "Ok", " ");
End xD.
Reply
#2

Or you could just use "CountDynamicObject" which comes with the streamer plugin...
Reply
#3

I choose the native
Reply
#4

Much simpler and much easier version:
pawn Код:
public OnGameModeInit()
{
    //Objects here

    new dummyObject = CreateObject(1214, 0, 0, -10, 0, 0, 0);
    printf("Created %d objects!", dummyObject-1);
    DestroyObject(dummyObject);
}
Reply
#5

Simply use ObjectCount () As CreateObject in OnGameModeInit

pawn Код:
public OnGameModeInit()
{
    ObjectCount (1489, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
instead

pawn Код:
public OnGameModeInit()
{
    CreateObject(1489, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)