• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

RevScripts Spawntime based on players online

Solution
I have not tried it but the place would be this: spawn.cpp
C++:
        // Adjust spawn time based on amount of player online.
        const uint8_t maxReduction = 90;
        const size_t reduction = std::min<size_t>(maxReduction, g_game.getPlayersOnline());
        const uint32_t spawnTime = sb.interval - (sb.interval * reduction / 100);
        if (OTSYS_TIME() >= sb.lastSpawn + spawnTime) {
This example uses a simple formula, count players up to a maximum of 90, so the time will be reduced by 90%, you can adjust it to your liking.
To make it look nicer maybe you should use constants defined in configmanager so you can configure this in config.lua... but that's up to you.
I have not tried it but the place would be this: spawn.cpp
C++:
        // Adjust spawn time based on amount of player online.
        const uint8_t maxReduction = 90;
        const size_t reduction = std::min<size_t>(maxReduction, g_game.getPlayersOnline());
        const uint32_t spawnTime = sb.interval - (sb.interval * reduction / 100);
        if (OTSYS_TIME() >= sb.lastSpawn + spawnTime) {
This example uses a simple formula, count players up to a maximum of 90, so the time will be reduced by 90%, you can adjust it to your liking.
To make it look nicer maybe you should use constants defined in configmanager so you can configure this in config.lua... but that's up to you.
 
Solution
Back
Top