G1R:MP Forum Alpha
Log in Join
Gothic 1 Remake Multiplayer

The Colony Forum

News, support, development discussions, server communities, and stories from beyond the Barrier.

Colony discussion

Random Number

Started by Xardas0327 in Suggestions

  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
09-13-2026, 05:04 PM
#1
It would be good if we have random number generator.

For example:
Quote:getRandomInt(includeMinInt, excludeMaxInt) -- Maybe it also should be fine if the top number is include too.

and
Quote:getRandomFloat (includeMinFloat, includeMaxFloat ) -- The top number should be included here.

Note:
I tried to use this code. But if I use this code, the server drop my character and the server reconnected it. (even on 0.1.3)
Moreover, this is not true random. I should use something similar like this math.randomseed(os.time()), but the os is not available from 0.1.3.
Quote:local startPositions = {
    { x = 1116.75, y = -1007.51, z = -36.66 },
    { x = 1106.01, y = -1049.35, z = -29.86 },
    { x = 1100.28, y = -1050.55, z = -35.44 },
    { x = 1115.40, y = -1049.39, z = -37.10 },
    { x = 1161.29, y = -1050.89, z = -42.04 },
    { x = 1154.55, y = -1011.29, z = -42.16 },
}

addCommandHandler("castle", function(playerId, commandName)
    local randomIndex = math.random(1, #startPositions)
    setPlayerPosition(
        playerId,
        startPositions[randomIndex].x,
        startPositions[randomIndex].y,
        startPositions[randomIndex].z
    )
end)
Forum Jump: