Raised This Month: $51 Target: $400
 12% 

spawn player at random place


Post New Thread Reply   
 
Thread Tools Display Modes
DjSoftero
Veteran Member
Join Date: Nov 2014
Location: Lithuania
Old 11-10-2017 , 14:12   Re: spawn player at random place
Reply With Quote #11

i`m was using superspawns for supply boxes and one thing that bugged me was that boxes were spawning on top of the map, or on a tree... so what i ended up doing, was setting seperate min and max coordinates for every map.
__________________
retired chump

Last edited by DjSoftero; 11-10-2017 at 14:13.
DjSoftero is offline
indraraj striker
Veteran Member
Join Date: Mar 2014
Location: Under the water
Old 11-10-2017 , 14:25   Re: spawn player at random place
Reply With Quote #12

DjSoftero sad same here xD no solution
is there anyone willing to help me i think i have to find some other method to achieve this
sometime players spawn middle of the wall/behind the box/top
check screenshot
PHP Code:
#include <amxmodx>
#include <hamsandwich>
#include <superspawns>

public plugin_init()
{
   
GetSpawnPoints()
   
register_clcmd("say /spawn","spawn_player");
   
RegisterHam(Ham_Spawn"player""fwdPlayerSpawnPost"1);
   }
   
GetSpawnPoints()
{
    
SsInit(3500.0);
    
SsScan();
}

public 
fwdPlayerSpawnPost(id)
{
    if(
is_user_alive(id))
    {
        static 
Float:origin[3];
        for(;;)
        {
            if(
SsGetOrigin(origin))
            {
                
entity_set_vector(idEV_VEC_originorigin);
                break;
            }
            
GetSpawnPoints();
        }
    }
}

public 
spawn_player(id)
{
 
ExecuteHamB(Ham_CS_RoundRespawn,id);



This is B side and behind the box

Thanks everyone

Last edited by indraraj striker; 11-10-2017 at 14:31.
indraraj striker is offline
KiLLeR.
Senior Member
Join Date: Jul 2014
Location: Bulgaria
Old 11-10-2017 , 15:44   Re: spawn player at random place
Reply With Quote #13

aron9forever, already told you why this happens and I'm pretty sure there is almost no way to avoid this with random spawn generator... Best solution is to use predefined spawn positions. So, you can add an admin command which get current player origins, writes it to a file and when you want to spawn a player on random position, simply take random position from that file. You have to play a bit more with reading/writing data in files, but this gonna work better for your needs.

Last edited by KiLLeR.; 11-10-2017 at 15:52.
KiLLeR. is offline
D3XT3R
AlliedModders Donor
Join Date: Nov 2016
Location: Lithuania, Bomb A (Kauna
Old 11-10-2017 , 15:46   Re: spawn player at random place
Reply With Quote #14

So best way is by making manual spawn points or if you stile wanting this idea use superspawns
__________________
D3XT3R is offline
Send a message via Skype™ to D3XT3R
aron9forever
Veteran Member
Join Date: Feb 2013
Location: Rromania
Old 11-10-2017 , 18:27   Re: spawn player at random place
Reply With Quote #15

by the way CSDM also uses defined points, they are not auto-generated, but it comes with settings for common maps

you can fix blocked points by checking that there is enough space for the player to actually spawn

have a look at map spawns editor, especially the part with block safety. It has a feature that it will not let you make a spawn if it's too close to walls, ceiling floor or other spawns. You could "borrow" the code from there and apply it every time you check for a spawn


mind this, if you want this for a server with lots of respawns like csdm or gungame, I would suggest generating some spawns at load and saving them in memory, if u get a random one every time someone spawns and then check if its valid, that's a lot of cpu usage, because these sorts of checks rely on while loops to iterate through the world and see if you hit anything (like is_user_outside stock in weather plugins)
__________________
Meanwhile, in 2050:
Quote:
Originally Posted by aron9forever
useless small optimizations
Quote:
Originally Posted by Black Rose View Post
On a map that is 512x512x128 units you end up with 3,355,443,200,000 different "positions". To store each one of those positions individually in the variable "user_or" you need 12 terabytes of memory.

Last edited by aron9forever; 11-10-2017 at 18:27.
aron9forever is offline
indraraj striker
Veteran Member
Join Date: Mar 2014
Location: Under the water
Old 11-10-2017 , 23:41   Re: spawn player at random place
Reply With Quote #16

aron9forever Thank you so much for the advice i will look into csdm and will use
KiLLeR. Thanks i will try to use file as aron said it will consume more cpu as its going to calculate everytime you spawn
D3XT3R Thanks
indraraj striker is offline
DjSoftero
Veteran Member
Join Date: Nov 2014
Location: Lithuania
Old 11-11-2017 , 08:55   Re: spawn player at random place
Reply With Quote #17

Quote:
Originally Posted by indraraj striker View Post
DjSoftero sad same here xD no solution
is there anyone willing to help me i think i have to find some other method to achieve this
sometime players spawn middle of the wall/behind the box/top
yeah, i just told you the solution. set the maximal height for each map seperately
__________________
retired chump
DjSoftero is offline
indraraj striker
Veteran Member
Join Date: Mar 2014
Location: Under the water
Old 11-13-2017 , 05:36   Re: spawn player at random place
Reply With Quote #18

Quote:
Originally Posted by DjSoftero View Post
yeah, i just told you the solution. set the maximal height for each map seperately
but how ?
Thanks
indraraj striker is offline
klippy
AlliedModders Donor
Join Date: May 2013
Location: Serbia
Old 11-13-2017 , 05:59   Re: spawn player at random place
Reply With Quote #19

To check if the spawn point is in the playable area you would need to use pathfinding, with the starting point somewhere in the map. If you want to make it only generate spawn points once and save them, instead of generating a new one each time someone spawns, you could use Black Rose's A* to do it.

Anyway, it shouldn't be difficult and shouldn't take more than a few minutes per map if you create a plugin with a nice interface for adding spawn points.
klippy is offline
DjSoftero
Veteran Member
Join Date: Nov 2014
Location: Lithuania
Old 11-13-2017 , 08:16   Re: spawn player at random place
Reply With Quote #20

Quote:
Originally Posted by indraraj striker View Post
but how ?
Thanks
create a file which would hold that data, and on plugin launch, read it.
__________________
retired chump
DjSoftero is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 17:44.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode