Welcome!

Join our community of MMO enthusiasts and game developers! By registering, you'll gain access to discussions on the latest developments in MMO server files and collaborate with like-minded individuals. Join us today and unlock the potential of MMO server development!

Join Today!

[Tutorial] Add TP inside Safezone (InvasionMMO)

Initiate Mage
Joined
Sep 18, 2013
Messages
18
Reaction score
10
(sorry for my english)I added teleportation system between safezones, any user can teleport between them!

In WarZ_Server

Go to ServerGameLogic.h and find,

Code:
int        ProcessChatCommand(obj_ServerPlayer* plr, const char* cmd);

after add:

Code:
int          Cmd_Safezone(obj_ServerPlayer* plr, const char* cmd);

go to ServerGameLogic.cpp

Include:

Code:
#include "ObjectsCode/obj_ServerPostBox.h"

find:

Code:
int ServerGameLogic::ProcessChatCommand(obj_ServerPlayer* plr, const char* cmd)

inside this function, add:

Code:
if(strncmp(cmd, "/safezone", 9) == 0)
        return Cmd_Safezone(plr, cmd);

after the function, you add the function of teleportation:

Code:
int ServerGameLogic::Cmd_Safezone(obj_ServerPlayer* plr, const char* cmd)
{

        //this repetition checks if the player is within a safe zone
    int tp = 0;
    for(int i=0; i<gPostBoxesMngr.numPostBoxes_; i++)
    {
        obj_ServerPostBox* pbox = gPostBoxesMngr.postBoxes_[i];
        float dist = (plr->GetPosition() - pbox->GetPosition()).Length();
        if(dist < pbox->useRadius)
        {
            tp =1;
        }
    }
    
    if(tp == 1)
    {
        char buf[128];
        int tpName = 0;
        float x, z;
        
        if(3 != sscanf(cmd, "%s %f %f", buf, &x, &z))
        {
            if(2 != sscanf(cmd, "%s %i", buf, &tpName))
                return 2;
        }
    
        if(tpName == 1){
            x = 7500;
            z = 4500;
        }else if(tpName == 2){
            x = 5500;
            z = 6500;
        }else if(tpName == 3){
            x = 5400;
            z = 2475;
        
        }else 
                 if(tpName == -1){
            PKT_C2C_ChatMessage_s n2;
            n2.userFlag = 3;
            n2.msgChannel = 1;
            r3dscpy(n2.msg, "1 = Goblin Peak Settlement, 2 = Blue Ridge Settlement, 3 = Castle Pine Settlement");
            r3dscpy(n2.gamertag, "<system>");
            p2pSendToPeer(plr->peerId_, plr, &n2, sizeof(n2));


            return 0;
        }else
            return 2;


    /*
        you can add more safe zones, then just put the number in the choice condition!
    Goblin Peak Settlement - /tp 7500 4500
    Campos City - /tp 6500 4650
    Ridgeway Airport - /tp 2750 2750
    Massive Weatherstation - /tp 2650 6200
    Frosty Pines resort town - /tp 2450 5500
    Norad Military Base - /tp 4000 5750
    Blue Ridge settlement - /tp 5500 6500
    Loco mountain - /tp 6500 7000
    */


    
    PxRaycastHit hit;
    PxSceneQueryFilterData filter(PxFilterData(COLLIDABLE_STATIC_MASK, 0, 0, 0), PxSceneQueryFilterFlag::eSTATIC);
    if(!g_pPhysicsWorld->raycastSingle(PxVec3(x, 1000.0f, z), PxVec3(0, -1, 0), 2000.0f, PxSceneQueryFlag::eIMPACT, hit, filter))
    {
        r3dOutToLog("unable to teleport - no collision\n");
        return 2;
    }
    
    r3dPoint3D pos = AdjustPositionToFloor(r3dPoint3D(x, 0, z));
        
    PKT_S2C_MoveTeleport_s n;
    n.teleport_pos = pos;
    p2pBroadcastToActive(plr, &n, sizeof(n));
    plr->SetLatePacketsBarrier("teleport");
    plr->TeleportPlayer(pos);
    r3dOutToLog("%s moved to %f, %f, %f\n", plr->userName, pos.x, pos.y, pos.z);
    return 0;
    }
    else
    {
        r3dOutToLog("You can only teleport from inside a SafeZone\n");
        return 2;
    }
    
}


Thanks to Hypoflex for the help =D
 
Last edited:
Experienced Elementalist
Joined
May 26, 2012
Messages
255
Reaction score
146
funny to see that a idea I had for real infestation got chosen by hammerpoint and now got released here :p
very nice mate :)

---------------------------------------------
Error D;

iMl76qd - [Tutorial] Add TP inside Safezone (InvasionMMO) - RaGEZONE Forums
 

Attachments

You must be registered for see attachments list
Last edited:
Initiate Mage
Joined
Sep 18, 2013
Messages
18
Reaction score
10
i just want to help .... in my game (Infekted Z) works perfectly!

you are using the invasionMMO?
 
Initiate Mage
Joined
Sep 18, 2013
Messages
18
Reaction score
10
add in ServerGameLogic.cpp this include:

#include "ObjectsCode/obj_ServerPostBox.h"
 
Experienced Elementalist
Joined
May 26, 2012
Messages
255
Reaction score
146
add in ServerGameLogic.cpp this include:

#include "ObjectsCode/obj_ServerPostBox.h"

aaah yea nice :) btw you made a little typo

{
r3dOutToLog(You can only teleport from inside a SafeZone\n");
return 2;
}

sould be

{
r3dOutToLog("You can only teleport from inside a SafeZone\n");
return 2;
}

+1 for this man :)
 
Junior Spellweaver
Joined
Dec 25, 2005
Messages
194
Reaction score
20
Yea, compiles just fine with the additional include and the fixed "You can only teleport from inside a SafeZone".
 
Junior Spellweaver
Joined
May 13, 2013
Messages
160
Reaction score
14
i think this command may have a problem, cause wouldnt it be possible to use this command in spawn protection.
 
Initiate Mage
Joined
Sep 18, 2013
Messages
18
Reaction score
10
This command should only be used within the safe zones
 
Custom Title Activated
Member
Joined
May 18, 2006
Messages
1,425
Reaction score
119
how to add delay time to teleport
30 sec
10 sec
or 5 sec
before goto new location
 
Initiate Mage
Joined
Jan 6, 2016
Messages
3
Reaction score
0
Error 10 error C2601: 'ServerGameLogic::Cmd_Safezone' : local function definitions are illegal c:\WarZ\server\src\WO_GameServer\Sources\ServerGameLogic.cpp 2741 WarZ Game Server
 
Initiate Mage
Joined
Jan 10, 2018
Messages
46
Reaction score
13
Error 10 error C2601: 'ServerGameLogic::Cmd_Safezone' : local function definitions are illegal c:\WarZ\server\src\WO_GameServer\Sources\ServerGameLogic.cpp 2741 WarZ Game Server
Show the code. This error "local function definitions are illegal" can be many things, like missing a }, undefined functions, 2 functions in 1 i believe...
 
Back
Top