Newbie Spellweaver
- 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,
after add:
go to ServerGameLogic.cpp
Include:
find:
inside this function, add:
after the function, you add the function of teleportation:
Thanks to Hypoflex for the help =D
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: