24.01.2019, 15:25
Do you mean the cmd which creates a tree?
Trees go through 3 processes only:
1. creation ( using cmd /createtree )
2. loading trees on server start
3. destroying trees on server shutdown
-freetreeID function:
Trees go through 3 processes only:
1. creation ( using cmd /createtree )
2. loading trees on server start
3. destroying trees on server shutdown
PHP код:
COMMAND:createtree(playerid, params[])
{
if(pInfo[playerid][Level] >= 4)
{
new Float: x, Float: y, Float: z;
GetPlayerPos(playerid, x, y, z);
new treeid = freeTreeID();
new string[260];
format(string, sizeof(string), "/Trees/%d.dini.save", treeid);
if(!dini_Exists(string))
{
treeData[treeid][tX] = x;
treeData[treeid][tY] = y;
treeData[treeid][tZ] = z - 3.1117; // remove this value to fix object bug
treeData[treeid][tObject] = CreateObject(617, treeData[treeid][tX], treeData[treeid][tY], treeData[treeid][tZ], 0.0000, 0.0000, 0.0000); // tree
treeData[treeid][woodReady] = false;
treeData[treeid][tHealth] = 100;
new string2[80];
format(string2, sizeof(string2), "{ffff00}Tree\n/cuttree\nHealth: %i", treeData[treeid][tHealth]);
treeData[treeid][tLabel] = Create3DTextLabel(string2, COLOR_YELLOW, treeData[treeid][tX], treeData[treeid][tY], treeData[treeid][tZ] + (0.2 + 3.1117) , 7.5, 0, 0);
treeData[treeid][tStatus] = true;
dini_Create(string);
dini_FloatSet(string, "tX", x);
dini_FloatSet(string, "tY", y);
dini_FloatSet(string, "tZ", z - 3.1117);
SSM(playerid, "You have successfully created a tree.");
}
}
else return 0;
return 1;
}
PHP код:
stock freeTreeID()
{
new Trees[64];
for(new g = 1; g < MAX_TREES; g++)
{
format(Trees, sizeof(Trees), "/Trees/%d.dini.save", g);
if(!dini_Exists(Trees)) return g;
}
return 1;
}