public OnGameModeInit() {
CreateTile(TILE_TYPE_GRASS, 0, 0);
CreateTile(TILE_TYPE_GRASS, 1, 0);
CreateTile(TILE_TYPE_GRASS, 0, 1);
CreateTile(TILE_TYPE_GRASS, -1, -1);
return 1;
}
stock CreateTile(type, x, y) {
new id = CreateObject(TILE_MODEL_ID, (x >= 0)?(x*125):(x*(-125)), (y >= 0)?(y*125):(y*(-125)), 30.0, 0, 0, 0);
new string[144];
format(string, sizeof string, "Tile: %i\nPosition: %i - %i", id, (x >= 0)?(x*125):(x*(-125)), (y >= 0)?(y*125):(y*(-125)));
Create3DTextLabel(string, 0x1CC4FCFF, (x >= 0)?(x*125):(x*(-125)), (y >= 0)?(y*125):(y*(-125)), 30.0, 1000.0, 0, 0);
switch(type) {
case TILE_TYPE_GRASS: {
SetObjectMaterial(id, 0, 9495, "vict_sfw", "Grass", 0);
for(new Float:gYY = -62.5; gYY < 62.5; gYY += (float(random(50)+1)*0.1)+1)
for(new Float:gX = -62.5, Float:gY = float(random(50)+1)*0.1; gX < 62.5; gX += (float(random(50)+1)*0.1)+1, gY = float(random(50)+1)*0.1)
CreateDynamicObject(TILE_OBJECT_GRASS, ((x >= 0)?(x*125):(x*(-125)))+gX, (((y >= 0)?(y*125):(y*(-125)))+gY)-gYY, 30, 0, 0, 0);
}
}
staticTiles[id][staticTile_ID] = id;
staticTiles[id][staticTile_Type] = type;
}
-1Ч(-1)=+1
-1Ч1=-1 So your above calculations are always positive. You don't need to check if value of x and y is negative or positive. Just keep them as they are with Ч125. |