New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
code to new spam at join game, but how to if there is an already pointed #1
Comments
Your code for newly joining players looks good. I don't think the random_spawn.bedspawn line will even work. ~= means does not equal, but you're reading the value of enable_bed_respawn and not comparing it with anything. You could use the bed code for setting the respawn, something like this probably. The beds mod would handle respawning then so you wouldn't need to do any of that. I'm not sure exactly what happens for people that have already joined before adding the code but haven't slept in a bed yet.
All I've done is add the beds.spawn line. This would require you to add beds into the dependencies for this mod. It would treat the first spawn position as a saved bed spot. The first time sleeping in another bed would reset the position of course. |
thanks a lot! yes the code does not work inclusively it crash.. so i removed the for people that have already joined before, i research a little and my code for i have two question:
this recursively will loop and could happened a mem exhaustion? and second.. you here suggest to use that |
The code bit you copied runs in a loop, preventing the loop from executing more than thirty times. After the 30th attempt it will restart the searching process in another area. I don't think there is any way this could run out of memory as it's not actually storing anything. I did forgot to put the line of code with the bed spawn portion in the first main if chunk of code. You can probably check if a player has a bed.spawn point save on joining, and if they don't give them a random spawn location. |
i am noted that is best to check if player already has bed
umm i reefers that if there's no found a possible area...
yeah i noted.. that's why i ask .. ok got it
ug that's is the missing part i noted .. in my code part.. also noteh you provide a |
If the code doesn't find a suitable area it will get another random selection on the map and check for an area again, and keep doing this until it finds an area. I developed this for a server that Cat5 was running, and I don't know of it ever causing any issues. I guess it's possible that it could try finding an area for hundreds or thousands of cycles, but I doubt if that would happen. I wrote this four years ago so I don't recall how the testing worked out, but I expect it was fairly quick. There is a testing block provided that you can use to see how long it takes for a suitable location to be found. |
hi @NathanSalapat i test your code but it seems does not work.. that line after a while will re-respawn the players again... i found a nasty solution and made a fork: https://git.minetest.org/minenux/minetest-mod-spawnrand marked solved at https://codeberg.org/minenux/minetest-mod-spawnrand/issues/1 heres is the code: https://git.minetest.org/minenux/minetest-mod-spawnrand/commit/2b50e329f0ee339090de76146ee6b440ab53527b i not used the i take the freedown to rename the namespace of the mod (i guess is named as is, "namespaced") from ramdow_spawn to spawnrand .. so all the mods i set on my server related to spawn point will have spawn prefixed.. so the solution is nasty for now but solved at the VenenuX minetest repository, i will close this code when i clean and improve the code |
for people interesting in that.. the findgroun it takes 5MB memory.. so it will get so many resources on huge servers.. This mod works prefectly with a local game with few players.. but has a recursive findground function.. that will be a problem in huge amoutn of players, it load 5MB per find. i track the issue in my fork.. .
EDIT: i solved the situation in the codeberg fork and also at minenux one.. also it has bed detection. |
* mod is autodetected and also detect if are already enabled * fixed mod position when bed are available only if player has it * fixed player respawn on dead.. must have else for no beds of player * closed fixed close NathanSalapat#1 * close fixed closed https://codeberg.org/minenux/minetest-mod-spawnrand/issues/3 * property fixed adn closed https://codeberg.org/minenux/minetest-mod-spawnrand/issues/1
already done at minenux@004e8da, thanks for your help |
i find this lokking for a best option agains the low performance of rspawn mod..
after lokking at the code it seems that this mod does not makes nothing if there's no implementation.. so i added a function to generated a random spamn point of each player just at each login if there's no already spawn set:
but there's no code for respawn cos i dont know how to distinge around already set poi8nt of player spawn or a random one
for now i use to have beds compatibility :
random_spawn.bedspawn = minetest.setting_getbool("enable_bed_respawn") ~= false
the ~= this means if get the value will set or like to false or will use the analog one?
for already joined users..i guess this will be the code, please help me if i am wrong:
The text was updated successfully, but these errors were encountered: