const int player = 1; const int threshold = 5; const int cObjBombardCannon = 36; int cannonsCount = 0; bool cannonsCondition () { return (cannonsCount >= threshold); } rule cannonsUpdateCount { static int playerId = -1; static int cannonArr = -1; static int uidArr = -1; if (playerId == -1) { playerId = xsGetWorldPlayerId(player); cannonArr = xsArrayCreateInt(0, -1); uidArr = xsArrayCreateInt(0, -1); } uidArr = xsGetPlayerUnitIds(playerId, cObjBombardCannon, uidArr); for (i = 0; < xsArrayGetSize(uidArr)) { int uid = xsArrayGetInt(uidArr, i); bool isNew = true; for (j = 0; < cannonsCount) { if (xsArrayGetInt(cannonArr, j) == uid) { isNew = false; break; } } if (isNew) { cannonsCount++; xsArrayResizeInt(cannonArr, cannonsCount); xsArraySetInt(cannonArr, cannonsCount-1, uid); xsChatData(fstr("Cannons owned so far: {cannonsCount}/{threshold}")); } } if (cannonsCondition()) xsDisableSelf(); }