• Unfortunately, we have experienced significant hard drive damage that requires urgent maintenance and rebuilding. The forum will be a state of read only until we install our new drives and rebuild all the configurations needed. Please follow our Facebook page for updates, we will be back up shortly! (The forum could go offline at any given time due to the nature of the failed drives whilst awaiting the upgrades.) When you see an Incapsula error, you know we are in the process of migration.

[Tutorial] The player disconnects and back to the nearest spawn

Experienced Elementalist
Joined
May 4, 2013
Messages
269
Reaction score
129
Hello, I was seeing it on multiple servers (including mine) existed abuse the spawn protection, where the player unplugged in front and connected with protection, so I decided to make the players to disconnect return to spawn.


WarZ_Server.sln

ServerGameLogic.cpp

Find:
Code:
if(loadout.GameMapId && (loadout.GameMapId == ginfo_.mapId) && loadout.Alive == 1)
    {
        *pos = loadout.GamePos;
        *dir = loadout.GameDir;
        //r3dOutToLog("alive at position %f %f %f\n", pos->x, pos->y, pos->z);
        return;
    }

Make it look this:
Code:
/*if(loadout.GameMapId && (loadout.GameMapId == ginfo_.mapId) && loadout.Alive == 1)
    {
        *pos = loadout.GamePos;
        *dir = loadout.GameDir;
        //r3dOutToLog("alive at position %f %f %f\n", pos->x, pos->y, pos->z);
        return;
    }*/

Find:
Code:
if(loadout.GameMapId && loadout.Alive == 2)
    {
        GetSpawnPositionAfterDeath(loadout.GamePos, pos, dir);
        // move spawn pos at radius
        pos->x += u_GetRandom(-_glm_SpawnRadius, _glm_SpawnRadius);
        pos->z += u_GetRandom(-_glm_SpawnRadius, _glm_SpawnRadius);
        //r3dOutToLog("revived at position %f %f %f\n", pos->x, pos->y, pos->z);
        return;
    }

And make it look this:
Code:
if(loadout.GameMapId && loadout.Alive == 1 || loadout.Alive == 2)
    {
        GetSpawnPositionAfterDeath(loadout.GamePos, pos, dir);
        // move spawn pos at radius
        pos->x += u_GetRandom(-_glm_SpawnRadius, _glm_SpawnRadius);
        pos->z += u_GetRandom(-_glm_SpawnRadius, _glm_SpawnRadius);
        //r3dOutToLog("revived at position %f %f %f\n", pos->x, pos->y, pos->z);
        return;
    }

Compile in Release Build

PS: When the player character its revive is placed with Alive = 2, so we return to the nearest spawn, and we login to the map, is placed as Alive = 1. Thus, the function commented Alive = 1, he plugged in the same place, and add in Alive = 2, where returning to spawn :) If anything is missing, or found a bug, put in the comments so we can try to fix it together :)

Sorry for bad english :D
 
f793
Joined
May 5, 2013
Messages
827
Reaction score
160
Thanks for sharing, I'm pretty sure we will be seeing emulators using this teleport thing :)
 
Joined
Oct 22, 2013
Messages
421
Reaction score
176
nice easy tutorial works well on my new emulator stops the noobs keep logging out when they are being hunted then logging back in and having spawn protection right in the center of clearview whats a right pain :(
 
Newbie Spellweaver
Joined
May 1, 2014
Messages
24
Reaction score
2
Thanks for the tut, gonna add soon to fix ghosting in and server hops.
 
Newbie Spellweaver
Joined
Jul 19, 2013
Messages
30
Reaction score
2
How can i stop the teleport when I logout in a safezone ?
 
Experienced Elementalist
Joined
May 4, 2013
Messages
269
Reaction score
129
How can i stop the teleport when I logout in a safezone ?

Try this (not tested yet):

Code:
 bool isinSafe = false;          
            for(int i=0; i<gPostBoxesMngr.numPostBoxes_; i++)
            {
                obj_ServerPostBox* pbox = gPostBoxesMngr.postBoxes_[i];
                float dist = (loadout.GamePos - pbox->GetPosition()).Length();
                if(dist < pbox->useRadius)
                {
                    isinSafe = true;
                }
            }
            else if(loadout.GameMapId && loadout.Alive == 2 || loadout.Alive == 1 && !isinSafe)
            {
            GetSpawnPositionAfterDeath(loadout.GamePos, pos , dir);
            // move spawn pos at radius
            //pos->x += u_GetRandom(10, 120);
            //pos->z += u_GetRandom(10, 120);
            protect = 1;
            r3dOutToLog("revived at position %f %f %f\n", pos->x, pos->y, pos->z);


            return;
        }
 
Back
Top