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!

[Release] FairFight System for all sources

Skilled Illusionist
Joined
May 17, 2013
Messages
309
Reaction score
206
[Release] "FairFight" System for WeaponHack

Hey!

I would like to release this basic "FairFight" System, It is just an improvement of the original function
If someone uses NoSpread, NoRecoil... gets an auto ban, you don't need execute any procedure or function in database.

For exemple: when i use no spread, server ban me, kill me and broadcast on chat "FairFight Banned "Fdr".


In WarZ_Server.sln -> Server Solution

Search for That (In obj_ServerPlayer.cpp):

Add:

Code:
[URL="http://forum.ragezone.com/usertag.php?do=list&action=hash&hash=include"]#include[/URL]  "MasterServerLogic.h"

Code:
void obj_ServerPlayer::OnNetPacket(const PKT_C2S_FallingDamage_s& n)
{
    r3dOutToLog("Falling damage to %s, damage=%.2f\n", Name.c_str(), n.damage); CLOG_INDENT;
    //r3dOutToLog("Falling damage Disable\n", Name.c_str(), n.damage); CLOG_INDENT; // No Damage Enabled
    if (!profile_.ProfileData.isDevAccount)
    {
        gServerLogic.ApplyDamage(this, this, GetPosition(), n.damage, true, storecat_INVALID);
    }
}

And Add below:

Code:
void obj_ServerPlayer::OnNetPacket(const PKT_C2S_ValidateEnvironment_s& n)
{
    r3dOutToLog("%s lastCurTime %.2f , CurTime %.2f\n",userName,lastCurTime,n.CurTime);
    if (fabs(n.CurTime - lastCurTime) < 0.01f && !firstTime) // 
    {
        char msg[512];
        sprintf(msg,"lastCurTime %.2f , CurTime %.2f\n",lastCurTime,n.CurTime);
        gMasterServerLogic.SendNoticeMsg("FairFight Banned '%s'",userName);
        g_AsyncApiMgr->AddJob(new CJobBanID(profile_.CustomerID,msg));
        //gServerLogic.DisconnectPeer(peerId_,true,msg)
        gServerLogic.DoKillPlayer(this, this, storecat_INVALID, true);;
        return;
    }
    if (firstTime)
    {
        firstTime = false;
        lastCurTime = n.CurTime;
    }


    lastCurTime = n.CurTime;
}
void obj_ServerPlayer::OnNetPacket(const PKT_C2S_BulletValidateConfig_s& n)
{
    // not need to check weapons. this is for bullet , not weapon.


    const WeaponConfig* wc = g_pWeaponArmory->getWeaponConfig((uint32_t)n.m_itemId);
    bool heHaveWep = false; // the weapons need to sync with servers.
    for (int i = 0; i<2;i++)
    {
        ServerWeapon* wpn = m_WeaponArray[i];
        if (!wpn)
            continue;


        if (wpn->m_pConfig->m_itemID == (uint32_t)n.m_itemId && wc == wpn->m_pConfig) // yeah he have this weapon
        {
            heHaveWep = true;
            break;
        }
    }
    if (!wc && n.m_itemId != 0 || !heHaveWep) // itemDB.xml or weapon not sync with servers. disconnect him!
    {
        // i think he have a problem. not all % he cheats.
        gServerLogic.DisconnectPeer(peerId_,false,"BulletValidate: %s weapon not sync with servers. itemid %d",userName,n.m_itemId);
        return;
    }


    // used for debug.
    //r3dOutToLog("PKT_C2S_BulletValidateConfig_s from %s , speed %.2f , mass %.2f , svspeed %.2f , svmass %.2f\n",userName,n.m_AmmoSpeed,n.m_AmmoMass,(float)wc->m_AmmoSpeed,(float)wc->m_AmmoMass);
    char msg[512];
    if (fabs((float)wc->m_AmmoMass - n.m_AmmoMass) > 0.01f) // no bullet drop hack.
    {
        sprintf(msg,"m_AmmoMass not match itemid:%d sv:%.2f , cl:%.2f\n",n.m_itemId,(float)wc->m_AmmoMass,n.m_AmmoMass);
        g_AsyncApiMgr->AddJob(new CJobBanID(profile_.CustomerID,msg));
        r3dOutToLog(msg);
        gMasterServerLogic.SendNoticeMsg("FairFight Banned '%s'",userName);
        //gServerLogic.DisconnectPeer(peerId_,true,msg);
        gServerLogic.DoKillPlayer(this, this, storecat_INVALID, true);
        return;
    }
    else if (fabs((float)wc->m_AmmoSpeed - n.m_AmmoSpeed) > 0.01f) // instant hit hack.
    {
        sprintf(msg,"m_AmmoSpeed not match itemid:%d sv:%.2f , cl:%.2f\n",n.m_itemId,(float)wc->m_AmmoSpeed,n.m_AmmoSpeed);
        g_AsyncApiMgr->AddJob(new CJobBanID(profile_.CustomerID,msg));
        r3dOutToLog(msg);
        gMasterServerLogic.SendNoticeMsg("FairFight Banned '%s'",userName);
        //gServerLogic.DisconnectPeer(peerId_,true,msg);
        gServerLogic.DoKillPlayer(this, this, storecat_INVALID, true);
        return;
    }
}
void obj_ServerPlayer::OnNetPacket(const PKT_C2S_PlayerState_s& n)
{
    // NOTE: STATE NEED TO SYNC WITH SERVER!
    char msg[512];
    if (!profile_.ProfileData.isDevAccount)
    {
        if (n.state == PLAYER_MOVE_SPRINT)
        {
            // for this check only forward speed. cannot move backward.
            if (n.accel.z > 5.46f) 
            {
                sprintf(msg,"SpeedHack PLAYER_MOVE_SPRINT cl:%.2f\n",n.accel.z);
                g_AsyncApiMgr->AddJob(new CJobBanID(profile_.CustomerID,msg));
                r3dOutToLog(msg);
                gMasterServerLogic.SendNoticeMsg("FairFight Banned '%s'",userName);
                //gServerLogic.DisconnectPeer(peerId_,true,msg);
                gServerLogic.DoKillPlayer(this, this, storecat_INVALID, true);
                return;
            }
        }
        else if (n.state == PLAYER_MOVE_RUN)
        {
            if (n.accel.z > 3.64f || n.accel.z < -2.73f)
            {
                sprintf(msg,"SpeedHack PLAYER_MOVE_RUN cl:%.2f\n",n.accel.z);
                g_AsyncApiMgr->AddJob(new CJobBanID(profile_.CustomerID,msg));
                r3dOutToLog(msg);
                gMasterServerLogic.SendNoticeMsg("FairFight Banned '%s'",userName);
                //gServerLogic.DisconnectPeer(peerId_,true,msg);
                gServerLogic.DoKillPlayer(this, this, storecat_INVALID, true);
                return;
            }
        }
        else if (n.state == PLAYER_MOVE_WALK_AIM)
        {
            if (n.accel.z > 2.08f || n.accel.z < -1.56f)
            {
                sprintf(msg,"SpeedHack PLAYER_MOVE_WALK_AIM cl:%.2f\n",n.accel.z);
                g_AsyncApiMgr->AddJob(new CJobBanID(profile_.CustomerID,msg));
                r3dOutToLog(msg);
                gMasterServerLogic.SendNoticeMsg("FairFight Banned '%s'",userName);
                //gServerLogic.DisconnectPeer(peerId_,true,msg);
                gServerLogic.DoKillPlayer(this, this, storecat_INVALID, true);
                return;
            }
        }
        else if (n.state == PLAYER_MOVE_CROUCH)
        {
            if (n.accel.z > 1.46f || n.accel.z < -1.10f)
            {
                sprintf(msg,"SpeedHack PLAYER_MOVE_CROUCH cl:%.2f\n",n.accel.z);
                g_AsyncApiMgr->AddJob(new CJobBanID(profile_.CustomerID,msg));
                r3dOutToLog(msg);
                gMasterServerLogic.SendNoticeMsg("FairFight Banned '%s'",userName);
                //gServerLogic.DisconnectPeer(peerId_,true,msg);
                gServerLogic.DoKillPlayer(this, this, storecat_INVALID, true);
                return;
            }
        }
        else if (n.state == PLAYER_MOVE_CROUCH_AIM)
        {
            if (n.accel.z > 0.83f || n.accel.z < -0.65f)
            {
                sprintf(msg,"SpeedHack PLAYER_MOVE_CROUCH_AIM cl:%.2f\n",n.accel.z);
                g_AsyncApiMgr->AddJob(new CJobBanID(profile_.CustomerID,msg));
                r3dOutToLog(msg);
                gMasterServerLogic.SendNoticeMsg("FairFight Banned '%s'",userName);
                //gServerLogic.DisconnectPeer(peerId_,true,msg);
                gServerLogic.DoKillPlayer(this, this, storecat_INVALID, true);
                return;
            }
        }
        else if (n.state == PLAYER_MOVE_PRONE)
        {
            if (n.accel.z > 0.73f || n.accel.z < -0.55f)
            {
                sprintf(msg,"SpeedHack PLAYER_MOVE_PRONE cl:%.2f\n",n.accel.z);
                g_AsyncApiMgr->AddJob(new CJobBanID(profile_.CustomerID,msg));
                r3dOutToLog(msg);
                gMasterServerLogic.SendNoticeMsg("FairFight Banned '%s'",userName);
                //gServerLogic.DisconnectPeer(peerId_,true,msg);
                gServerLogic.DoKillPlayer(this, this, storecat_INVALID, true);
                return;
            }
        }
    }
}
void obj_ServerPlayer::OnNetPacket(const PKT_C2S_WpnLog_s& n)
{
    const WeaponConfig* wc = g_pWeaponArmory->getWeaponConfig((uint32_t)n.itemid);
    LastWpnLog = r3dGetTime();




    ServerWeapon* wpn = m_WeaponArray[n.slot];
    if (!wc && n.itemid != 0) // not match.
    {
        gServerLogic.DisconnectPeer(peerId_,true,"WpnLog not match. itemid:%d",n.itemid);
        return;
    }


    // NOTE : THIS IS VERY IMPORTANT CODE. IF FAILED THIS PLAYER WILL GET BANNED BY ERROR SYSTEM.
    float spread = (float)wc->m_spread;    spread = spread * (1.0f+n.m_spreadattm);
    spread *= 0.5f;


    // SKILL SYNC CODE
    if (loadout_->Stats.skillid9)
        spread *= 0.8f;




    float recoil = (float)wc->m_recoil;
    recoil = recoil * (1.0f+n.m_recoilattm);


    // SKILL SYNC CODE
    if (loadout_->Stats.skillid11)
        recoil *= 0.8f;


    recoil *= 0.05f;


    // copy from client.
    float fireDelay = (float)wc->m_fireDelay;
    int firerate = (int)ceilf(60.0f / fireDelay); // convert back to rate of fire
    firerate = (int)ceilf(float(firerate) * (1.0f+n.m_rateattm)); // add bonus , but i will use value by client. it's not sync with servers.
    fireDelay = 60.0f / firerate; // convert back to fire delay
    float fireRatePerc = 0.0f;
    float adjInPerc = (fireDelay / 100.0f) * fireRatePerc;
    fireDelay -= adjInPerc;






    //r3dOutToLog("PKT_C2S_WpnLog_s recieved itemid %d spread %.2f svspread %.2f\n",n.itemid,n.m_spread,spread);


    // CJobBanID(CustomerID , Reason , ...)
    // MasterServerLogic::SendNoticeMsg(msg , ...)
    char msg[512];
    if (fabs((float)spread - (float)n.m_spread) > 0.01f) // spread hack
    {
        sprintf(msg,"m_spread not match itemid:%d sv:%.2f , cl:%.2f\n",n.itemid,spread,n.m_spread);
        g_AsyncApiMgr->AddJob(new CJobBanID(profile_.CustomerID,msg));
        r3dOutToLog(msg);
        //gServerLogic.DisconnectPeer(peerId_,true,"m_spread not match itemid:%d sv:%.2f , cl:%.2f",n.itemid,wc->m_spread,n.m_spread);
        gServerLogic.DoKillPlayer(this, this, storecat_INVALID, true);
        return;
    }
    else if (fabs((float)recoil - (float)n.m_recoil) > 0.01f) // recoil hack.
    {
        sprintf(msg,"m_recoil not match itemid:%d sv:%.2f , cl:%.2f\n",n.itemid,recoil,n.m_recoil);
        r3dOutToLog(msg);
        g_AsyncApiMgr->AddJob(new CJobBanID(profile_.CustomerID,msg));
        //gServerLogic.DisconnectPeer(peerId_,true,"m_recoil not match itemid:%d sv:%.2f , cl:%.2f",n.itemid,wc->m_recoil,n.m_recoil);
        gServerLogic.DoKillPlayer(this, this, storecat_INVALID, true);
        return;
    }
    else if (fabs((float)fireDelay - (float)n.m_rateoffire) > 0.01f) // rapid fire hack.
    {
        sprintf(msg,"m_rateoffire not match itemid:%d sv:%.2f , cl:%.2f\n",n.itemid,fireDelay,n.m_rateoffire);
        r3dOutToLog(msg);
        g_AsyncApiMgr->AddJob(new CJobBanID(profile_.CustomerID,msg));
        gServerLogic.DoKillPlayer(this, this, storecat_INVALID, true);
        //gServerLogic.DisconnectPeer(peerId_,true,"m_rateoffire not match itemid:%d sv:%.2f , cl:%.2f",n.itemid,fireDelay,n.m_rateoffire);
        return;
    }


    // STEP 2 - TPROGAME NO RECOIL LOGIC
    // USED m_recoil2
    recoil *= 1.1f; // recoil = getRecoil()*1.1f;
    if (fabs((float)recoil - (float)n.m_recoil2) > 0.01f) // RECOIL HACK
    {
        sprintf(msg,"m_recoil2 not match itemid:%d sv:%.2f , cl:%.2f\n",n.itemid,recoil,n.m_recoil2);
        r3dOutToLog(msg);
        g_AsyncApiMgr->AddJob(new CJobBanID(profile_.CustomerID,msg));
        gServerLogic.DoKillPlayer(this, this, storecat_INVALID, true);
        //gServerLogic.DisconnectPeer(peerId_,true,msg);
        return;
    }


}

Now Search for This:

Code:
void obj_ServerPlayer::OnNetPacket(const PKT_C2S_PlayerWeapDataRep_s& n)

IMPORTANT: CHANGE FULL FUNCTION FOR THIS:

Code:
void obj_ServerPlayer::OnNetPacket(const PKT_C2S_PlayerWeapDataRep_s& n)
{
    lastWeapDataRep = r3dGetTime();


    // if weapon data was updated more that once it mean that updated happened in middle of the game
    // so skip validation
    if(gServerLogic.weaponDataUpdates_ >= 2)
        return;


    for(int i=0; i<2; i++)
    {
        if(m_WeaponArray[i] == NULL)
            continue;
        DWORD hash = m_WeaponArray[i]->getConfig()->GetClientParametersHash();


        if(hash == n.weaponsDataHash[i])
            continue;


        const WeaponConfig& wc1 = *m_WeaponArray[i]->getConfig();
        WeaponConfig wc2(n.debug_wid[i]); 
        wc2.copyParametersFrom(n.debug_winfo[i]);


        if(wc1.m_itemID != wc2.m_itemID)
        {


            gServerLogic.LogCheat(peerId_, PKT_S2C_CheatWarning_s::CHEAT_Protocol, false, "weapDataRep different",
                "slot%d %d - %d", i, wc1.m_itemID, wc2.m_itemID);
        }
        else
        {
            // create diffs string for logging
            char diffs[4096] = "";
            if(fabs((float)wc1.m_spread - (float)wc2.m_spread) > 0.01f)
                sprintf(diffs + strlen(diffs), "spread:%.2f/%.2f ", (float)wc1.m_spread, (float)wc2.m_spread);
            if(fabs((float)wc1.m_recoil - (float)wc2.m_recoil) > 0.01f)
                sprintf(diffs + strlen(diffs), "recoil:%.2f/%.2f ", (float)wc1.m_recoil, (float)wc2.m_recoil);
            if(fabs((float)wc1.m_reloadTime - (float)wc2.m_reloadTime) > 0.01f)
                sprintf(diffs + strlen(diffs), "reloadtime:%.2f/%.2f ", (float)wc1.m_reloadTime, (float)wc2.m_reloadTime);
            if(fabs((float)wc1.m_fireDelay - (float)wc2.m_fireDelay) > 0.01f)
                sprintf(diffs + strlen(diffs), "rateoffire:%.2f/%.2f ", (float)wc1.m_fireDelay, (float)wc2.m_fireDelay);
            if(fabs((float)wc1.m_AmmoSpeed - (float)wc2.m_AmmoSpeed) > 0.01f)
                sprintf(diffs + strlen(diffs), "ammospeed:%.2f/%.2f ", (float)wc1.m_AmmoSpeed, (float)wc2.m_AmmoSpeed);


            // report it only once per session (for now, because there is no disconnect yet)
            if(diffs[0] && !weapCheatReported)
            {
                weapCheatReported = true;
                gServerLogic.LogCheat(peerId_, PKT_S2C_CheatWarning_s::CHEAT_BadWeapData, false, "weapDataRep different",
                    "id:%d, diff:%s", wc1.m_itemID, diffs);
            }
            // automatic ban.
            if(diffs[0])
            {
                char chatmessage[128] = {0};
                g_AsyncApiMgr->AddJob(new CJobBanID(profile_.CustomerID,diffs));
                gMasterServerLogic.SendNoticeMsg("FairFight Banned '%s'",userName);
                gServerLogic.DoKillPlayer(this, this, storecat_INVALID, true);
            }
        }
    }
}


Now in obj_ServerPlayer.h, Search for this:

Code:
void        OnNetPacket(const PKT_C2S_FallingDamage_s& n);

And add Below:

Code:
void        OnNetPacket(const PKT_C2S_ValidateEnvironment_s& n);
    void        OnNetPacket(const PKT_C2S_BulletValidateConfig_s& n);
    void        OnNetPacket(const PKT_C2S_PlayerState_s& n);
    void        OnNetPacket(const PKT_C2S_WpnLog_s& n);

Search for this:

Code:
bool        isTargetDummy_;

Add Below:

Code:
float lastCurTime;
bool firstTime;

Search for that:

Code:
float        m_Stamina;

Add Below:

Code:
float        LastWpnLog;


Now, Search for this (in P2PMessages.h):

Code:
struct PKT_S2C_SetPlayerReputation_s : public DefaultPacketMixin<PKT_S2C_SetPlayerReputation>
{
    int            Reputation;
};

IF YOU DON'T FOUND THIS, SEARCH FOR THAT:
Code:
struct PKT_C2S_DBG_LogMessage_s : public DefaultPacketMixin<PKT_C2S_DBG_LogMessage>
{
    char    msg[128];
};


Add Below:

Code:
struct PKT_C2S_WpnLog_s : public DefaultPacketMixin<PKT_C2S_WpnLog>
{
    float m_spread;
    float m_recoil;
    float m_AmmoSpeed;
    float m_AmmoMass;
    float m_AmmoDamage;
    DWORD itemid;
    DWORD slot;
    float m_recoilattm;
    float m_spreadattm;
    float m_rateoffire;
    float m_rateattm;
    float m_spread2;
    float m_recoil2;
};


struct PKT_C2S_BulletValidateConfig_s : public DefaultPacketMixin<PKT_C2S_BulletValidateConfig>
{
    int m_itemId;
    float m_AmmoMass;
    float m_AmmoSpeed;
};


struct PKT_C2S_ValidateEnvironment_s : public DefaultPacketMixin<PKT_C2S_ValidateEnvironment>
{
    float CurTime;
};
struct PKT_S2C_UpdateEnvironment_s : public DefaultPacketMixin<PKT_S2C_UpdateEnvironment>
{
    bool rain;
};
struct PKT_C2S_PlayerState_s : public DefaultPacketMixin<PKT_C2S_PlayerState>
{
    r3dPoint3D accel;
    int state;
};


Search for That:

Code:
PKT_S2C_SetPlayerReputation,[COLOR=#000000]
[/COLOR]


Or if you don't found

Code:
PKT_C2S_DBG_LogMessage,[COLOR=#000000]
[/COLOR]


Add Below:

Code:
PKT_C2S_BulletValidateConfig,
  PKT_C2S_ValidateEnvironment,
  PKT_S2C_UpdateEnvironment,
  PKT_C2S_WpnLog,
  PKT_C2S_PlayerState,


Now in AsyncFuncs.cpp, Search for:

Code:
CJobProcessUserJoin::CJobProcessUserJoin(int in_peerId) : CAsyncApiJob()
{
    sprintf(desc, "CJobProcessUserJoin[%d] %p", CustomerID, this);


    ServerGameLogic::peerInfo_s& peer = gServerLogic.GetPeer(in_peerId);
    r3d_assert(peer.startGameAns == 0);


    peerId       = in_peerId;
    CustomerID   = peer.CustomerID;
    SessionID    = peer.SessionID;
    CharID       = peer.CharID;


    r3d_assert(CustomerID);
    r3d_assert(CharID);
}[COLOR=#000000]
[/COLOR]


Add Below:

Code:
CJobBanID::CJobBanID(int in_CustomerID , char reason1[512]) : CAsyncApiJob()
{
    sprintf(desc, "CJobBanID[%d] %p", in_CustomerID, this);


    CustomerID   = in_CustomerID;


    sprintf(reason,reason1);
    r3d_assert(CustomerID);
}
void CJobBanID::OnSuccess()
{
}
int CJobBanID::Exec()
{
    CWOBackendReq req("api_BanID.aspx");
    req.AddSessionInfo(CustomerID, SessionID);
    req.AddParam("CustomerID",  CustomerID);
    req.AddParam("reason",  reason);
    if (!req.Issue())
    r3dOutToLog("apiBanID Failed. Code %d\n",req.resultCode_);
    else
    r3dOutToLog("apiBanID %d Success\n",CustomerID);


    return 0;
}[COLOR=#000000]
[/COLOR]


Now in AsyncFuncs.h, search for it:

Code:
class CJobProcessUserJoin : public CAsyncApiJob
{
    CServerUserProfile prof;
    int        GameJoinResult;


  public:
    CJobProcessUserJoin(int in_peerId);


    int        Exec();
    void        OnSuccess();
};[COLOR=#000000]
[/COLOR]


Add Below:

Code:
class CJobBanID : public CAsyncApiJob
{


  public:
    CJobBanID(int in_CustomerID , char reason1[512]);
    char reason[512];


    int        Exec();
    void        OnSuccess();
};[COLOR=#000000]
[/COLOR]


Now, in MasterServerLogic.cpp, Search for this:

FIRST ADD:

Code:
[URL="http://forum.ragezone.com/usertag.php?do=list&action=hash&hash=include"]#include[/URL]  "ServerGameLogic.h"[COLOR=#000000]
[/COLOR]


Code:
void MasterServerLogic::FinishGame()
{
  if(net_ == NULL)
    return;


  CREATE_PACKET(SBPKT_G2M_FinishGame, n);
  net_->SendToHost(&n, sizeof(n), true);
  
  return;
}


Add Below:

Code:
void MasterServerLogic::SendNoticeMsg(const char* msg , ...)
{
    if(net_ == NULL)
        return;


    char buf[1024];


    va_list ap;
    va_start(ap, msg);
    StringCbVPrintfA(buf, sizeof(buf), msg, ap);
    va_end(ap);


    CREATE_PACKET(SBPKT_G2M_SendNoticeMsg, n);
    r3dscpy(n.msg,buf);
    net_->SendToHost(&n, sizeof(n), true);


    r3dOutToLog("BrostCast Notice Msg to all servers. '%s'\n",buf);
    return;
}[COLOR=#000000]
[/COLOR]


Now Search for this:

Code:
case SBPKT_M2G_UpdateWeaponData:
    {
      const SBPKT_M2G_UpdateWeaponData_s& n = *(SBPKT_M2G_UpdateWeaponData_s*)packetData;
      r3d_assert(sizeof(n) == packetSize);


      /*
      WeaponConfig* wc = const_cast<WeaponConfig*>(g_pWeaponArmory->getWeaponConfig(n.itemId));
      if(wc == NULL) {
        r3dOutToLog("!!! got update for not existing weapon %d\n", n.itemId);
        return;
      }


      wc->copyParametersFrom(n.wi);
      //r3dOutToLog("got update for weapon %s\n", wc->m_StoreName);
      */
      break;
    }[COLOR=#000000]
[/COLOR]


Add Below:

Code:
case SBPKT_G2M_SendNoticeMsg:
        {
            const SBPKT_G2M_SendNoticeMsg_s& n = *(SBPKT_G2M_SendNoticeMsg_s*)packetData;
            r3d_assert(sizeof(n) == packetSize);
            r3dOutToLog("Received notice packet from master. msg '%s' , brostcast to all players.\n",n.msg);
            // brostcast by chat packet.
            PKT_C2C_ChatMessage_s n1;
            r3dscpy(n1.gamertag, "<SYSTEM>");
            r3dscpy(n1.msg, n.msg);
            n1.msgChannel = 1;
            n1.userFlag = 2;
            gServerLogic.p2pBroadcastToAll(NULL, &n1, sizeof(n1), true);
            break;
        }[COLOR=#000000]
[/COLOR]


Now, in MasterServerLogic.h, Search for:

Code:
void        FinishGame();[COLOR=#000000]
[/COLOR]


Add Below:

Code:
void        SendNoticeMsg(const char* msg , ...);[COLOR=#000000]
[/COLOR]


Now, in NetPackets
ServerBrowser.h, Search for:

Code:
SBPKT_G2M_CloseGame,[COLOR=#000000]
[/COLOR]


Add Below:

Code:
SBPKT_G2M_SendNoticeMsg,[COLOR=#000000]
[/COLOR]


Now Search for it:

Code:
struct SBPKT_G2M_CloseGame_s : public r3dNetPacketMixin<SBPKT_G2M_CloseGame>
{
};[COLOR=#000000]
[/COLOR]


Add Below:

Code:
struct SBPKT_G2M_SendNoticeMsg_s : public r3dNetPacketMixin<SBPKT_G2M_SendNoticeMsg>
{
    char msg[512];
};[COLOR=#000000]
[/COLOR]


Now in MasterServerGame.cpp, Search for:

Code:
case SBPKT_G2M_RegisterGame:
        {
            const SBPKT_G2M_RegisterGame_s& n = *(SBPKT_G2M_RegisterGame_s*)PacketData;
            r3d_assert(sizeof(n) == PacketSize);
            r3d_assert(peer.status == PEER_Validated);


            r3dOutToLog("game 0x%x connected\n", n.gameId);


            // register this game in supervisor
            CServerS* super = GetServerByGameId(n.gameId);
            if(super == NULL) {
                // this might happen when supervisor crashed between game start & registration
                r3dOutToLog("game 0x%x without supervisor\n", n.gameId);


                SBPKT_M2G_KillGame_s n1;
                net_->SendToPeer(&n1, sizeof(n1), peerId);
                net_->DisconnectPeer(peerId);
                break;
            }


            CServerG* game = super->CreateGame(n.gameId, peerId);
            r3d_assert(game);


            games_.insert(TGamesList::value_type(peerId, game));


            r3d_assert(peer.status == PEER_Validated);
            peer.status = PEER_GameServer;


[URL="http://forum.ragezone.com/usertag.php?do=list&action=hash&hash=if"]#if[/URL]  ENABLED_SERVER_WEAPONARMORY
            SendArmoryInfoToGame(game);
[URL="http://forum.ragezone.com/usertag.php?do=list&action=hash&hash=endif"]#endif[/URL] 
            break;
        }[COLOR=#000000]
[/COLOR]


Add Below:

Code:
case SBPKT_G2M_SendNoticeMsg:
        {
            const SBPKT_G2M_SendNoticeMsg_s& n = *(SBPKT_G2M_SendNoticeMsg_s*)PacketData;
            r3dOutToLog("Received notice message from peer%d '%s'\n",peerId,n.msg);
            //r3dOutToLog("Brostcast to all servers.\n");
            // scans servers.
            int numgames = 0;
            for(CMasterGameServer::TSupersList::const_iterator it = gMasterGameServer.supers_.begin();
                it != gMasterGameServer.supers_.end();
                ++it)
            {
                const CServerS* super = it->second;
                numgames += super->GetExpectedGames();
                for(int i=0; i<super->maxGames_; i++) 
                {
                    const CServerG* game = super->games_[i].game;
                    if(!game) 
                        continue;
                    // resend this packet to all servers.
                    net_->SendToPeer(&n, sizeof(n), game->peer_, true);
                }
            }
            r3dOutToLog("Send notice packet to %d servers\n",numgames);
            break;
        }[COLOR=#000000]
[/COLOR]

DOWNLOAD API AND SQL


Credits to: @Yuri-BR - For code
and me for tutorial!


 
Last edited:
Junior Spellweaver
Joined
Jun 22, 2014
Messages
175
Reaction score
87
Hm, nice release... but why some code boxes are empty?
 
Skilled Illusionist
Joined
May 17, 2013
Messages
309
Reaction score
206
Hm, nice release... but why some code boxes are empty?

Thanks, i edited the post 9 times, and 9 times didn't work.

So, you can follow the tutorial perfectly without any error, just ignore empty boxes.
 
Last edited:
  • Like
Reactions: DNC
Joined
Oct 22, 2013
Messages
421
Reaction score
176
just giving it ago now but the code side of things look spot on :D

maybe i will not use it dont seem to want to work on the old dnc lol 234 Errors lol
 
Experienced Elementalist
Joined
Sep 13, 2013
Messages
205
Reaction score
23
SBPKT_G2M_CloseGame, I can not find this anywhere even in 3 differnet sources :(
 
Skilled Illusionist
Joined
May 17, 2013
Messages
309
Reaction score
206
not work in InvasionMMO Source

Work in "All Sources" work for me in new DNC release, work in first alpha source release, first DNC, all right, i know Invasion and i think he work on that because invasion is a DNC with skills and more details...

You don't do the tutorial correctly!
 
Newbie Spellweaver
Joined
Nov 8, 2013
Messages
37
Reaction score
3
Work in "All Sources" work for me in new DNC release, work in first alpha source release, first DNC, all right, i know Invasion and i think he work on that because invasion is a DNC with skills and more details...

You don't do the tutorial correctly!
yes guy i do the turial Correctly is easy only ctrl +c and ctrl+v but i don't found SBPKT_G2M_CloseGame, in InvasionMMO source
 
Newbie Spellweaver
Joined
Feb 4, 2012
Messages
25
Reaction score
4
fdr...
Invasionmmo doesn't have this packet SBPKT_G2M_CloseGame either this file linked on source "NetPacketsServerBrowser.h"
Anyways i just comment the sendmessage function... idk if going to work... i'll tell later.
 
Newbie Spellweaver
Joined
Jul 29, 2014
Messages
65
Reaction score
2
#fdrgamer can i try it by myself so that i am hacking on my on server ? or i cant get banned when i am dev ?
 
Newbie Spellweaver
Joined
Jul 29, 2014
Messages
65
Reaction score
2
ok nice but i have played one hour with a hack no ban -.-
 
Junior Spellweaver
Joined
Jan 6, 2014
Messages
175
Reaction score
7
You don't make tutorial correctly, because no spread, no recoil, instant hit, rapid fire...is detected!

or the fairfight isn't detecting those types of hack.

but, someone tried to put on RZ:CE src? i'm going to, just wanting a heads up.
 
Back
Top