SA-MP Forums Archive
[Tutorial] Count Object on GM - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Tutorials (https://sampforum.blast.hk/forumdisplay.php?fid=70)
+---- Thread: [Tutorial] Count Object on GM (/showthread.php?tid=320330)



Count Object on GM - LuisGraph - 22.02.2012

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.


Re: Count Object on GM - Luis- - 22.02.2012

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


Respuesta: Count Object on GM - LuisGraph - 22.02.2012

I choose the native


Re: Count Object on GM - Vince - 22.02.2012

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);
}



Respuesta: Count Object on GM - LuisGraph - 22.02.2012

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);