Topic: New Redirection Tile ! On Map !
hey Guys !
i made somthing for your Servers or Clients !
this is a Tile !
What ?? Tile ???
yeah !
This TILE can redirect your players to other server you have ! or other friends server !
how can add this to your server or client ?
its easy ...
Client Side :
Step 1 :
add this code to Chat.cpp
Chat.cpp
bool CChat::str_in_str(const char *chat, const char *pline)
{
//int Length = str_length(chat);
const char *pText = str_find_nocase(pline, chat);
if (pText)
{
return true;
}
else
return false;
}
Step 2 :
Add This code to Chat.h
Chat.h
virtual bool str_in_str(const char *chat, const char *pline);
Step 3 :
change this ->
Chat.cpp
if(ClientID == -1) // server message
{
str_copy(m_aLines[m_CurrentLine].m_aName, "*** ", sizeof(m_aLines[m_CurrentLine].m_aName));
str_format(m_aLines[m_CurrentLine].m_aText, sizeof(m_aLines[m_CurrentLine].m_aText), "%s", pLine);
}
to this :
Chat.cpp
if(ClientID == -1) // server message
{
str_copy(m_aLines[m_CurrentLine].m_aName, "*** ", sizeof(m_aLines[m_CurrentLine].m_aName));
str_format(m_aLines[m_CurrentLine].m_aText, sizeof(m_aLines[m_CurrentLine].m_aText), "%s", pLine);
if (str_in_str("RedirectTo:", pLine))
{
std::string s = pLine;
string addr = s.substr(sizeof("RedirectTo:"),(s.length() - sizeof("RedirectTo:"))).c_str();
str_copy(g_Config.m_UiServerAddress, addr, sizeof(g_Config.m_UiServerAddress));
GameClient()->Client()->Connect(addr);
}
}
End ! now Your Client Can Join Any Server ! When Go to Redirect Tile
Server Side :
Step 1:
Character.cpp
#include <sstream>
#include <fstream>
std::string GetLine(int index)
{
std::string TmpName = "";
std::fstream f;
f.open("ip.cfg", std::ios::in);
if (!f.fail())
{
for (int i = 0; i < index; i++)
{
std::getline(f, TmpName);
}
}
f.close();
return TmpName.c_str();
}
Step 2:
find this code on Character.cpp :
int z = GameServer()->Collision()->IsTeleport(MapIndex);
and add this code , above of it :
Character.cpp
int Redirect = GameServer()->Collision()->IsRedirect(MapIndex);
if (Redirect)
{
std::string Cmd = "RedirectTo: " + GetLine(Redirect);
GameServer()->SendChatTarget(GetPlayer()->GetCID(), Cmd.c_str());
}
Step 3 :
add this code to collision.cpp
collision.cpp
int CCollision::IsRedirect(int Index)
{
if (Index < 0 || !m_pTele)
return 0;
if (m_pTele[Index].m_Type == TILE_REDIRECT)
return m_pTele[Index].m_Number;
return 0;
}
collision.h
int IsRedirect(int Index);
Step 4 :
now you need add new Tile to Server :
add TILE_REDIRECT=1, to mapitem.h after TILE_TELECHECKIN,
Step 5 :
Replace This Line
collision.cpp
if (m_pTele && (m_pTele[Index].m_Type == TILE_TELEIN || m_pTele[Index].m_Type == TILE_TELEINEVIL || m_pTele[Index].m_Type == TILE_TELECHECKINEVIL || m_pTele[Index].m_Type == TILE_TELECHECK || m_pTele[Index].m_Type == TILE_TELECHECKIN))
with
collision.cpp
if (m_pTele && (m_pTele[Index].m_Type == TILE_REDIRECT || m_pTele[Index].m_Type == TILE_TELEIN || m_pTele[Index].m_Type == TILE_TELEINEVIL || m_pTele[Index].m_Type == TILE_TELECHECKINEVIL || m_pTele[Index].m_Type == TILE_TELECHECK || m_pTele[Index].m_Type == TILE_TELECHECKIN))
Step 6:
find all codes like
io.cpp
((CLayerTiles*)pTiles)->m_pTiles[i].m_Index = TILE_TELEIN;
and add this code after it
io.cpp
else if (((CLayerTele*)pTiles)->m_pTeleTile[i].m_Type == TILE_REDIRECT)
((CLayerTiles*)pTiles)->m_pTiles[i].m_Index = TILE_REDIRECT;
Last Step :
Find this code
layer_tiles.cpp
if(pGrabbed->m_pTeleTile[y*pGrabbed->m_Width + x].m_Type == TILE_TELEIN || pGrabbed->m_pTeleTile[y*pGrabbed->m_Width+x].m_Type == TILE_TELEOUT || pGrabbed->m_pTeleTile[y*pGrabbed->m_Width+x].m_Type == TILE_TELEINEVIL || pGrabbed->m_pTeleTile[y*pGrabbed->m_Width+x].m_Type == TILE_TELECHECKINEVIL || pGrabbed->m_pTeleTile[y*pGrabbed->m_Width+x].m_Type == TILE_TELECHECK || pGrabbed->m_pTeleTile[y*pGrabbed->m_Width+x].m_Type == TILE_TELECHECKOUT || pGrabbed->m_pTeleTile[y*pGrabbed->m_Width+x].m_Type == TILE_TELECHECKIN || pGrabbed->m_pTeleTile[y*pGrabbed->m_Width+x].m_Type == TILE_TELEINWEAPON || pGrabbed->m_pTeleTile[y*pGrabbed->m_Width+x].m_Type == TILE_TELEINHOOK)
replace with this code
layer_tiles.cpp
if(pGrabbed->m_pTeleTile[y*pGrabbed->m_Width+x].m_Type == TILE_REDIRECT || pGrabbed->m_pTeleTile[y*pGrabbed->m_Width + x].m_Type == TILE_TELEIN || pGrabbed->m_pTeleTile[y*pGrabbed->m_Width+x].m_Type == TILE_TELEOUT || pGrabbed->m_pTeleTile[y*pGrabbed->m_Width+x].m_Type == TILE_TELEINEVIL || pGrabbed->m_pTeleTile[y*pGrabbed->m_Width+x].m_Type == TILE_TELECHECKINEVIL || pGrabbed->m_pTeleTile[y*pGrabbed->m_Width+x].m_Type == TILE_TELECHECK || pGrabbed->m_pTeleTile[y*pGrabbed->m_Width+x].m_Type == TILE_TELECHECKOUT || pGrabbed->m_pTeleTile[y*pGrabbed->m_Width+x].m_Type == TILE_TELECHECKIN || pGrabbed->m_pTeleTile[y*pGrabbed->m_Width+x].m_Type == TILE_TELEINWEAPON || pGrabbed->m_pTeleTile[y*pGrabbed->m_Width+x].m_Type == TILE_TELEINHOOK)
tada!
its done !
you must create new file "ip.cfg" in root of server.exe file
now as you use a teleport tile ! with number ! ( mapers know whats im saying ! )
you can use tele layer and use tile number 1 to create redirect tile on map !
but where is a Redirect ip ?
redirect ip's must write in ip.cfg file !
when you use Redirect Tile with number 3 ! Server Go to ip.cfg file ! and get line 3 of this file !
in the line 3 you must have a new ip:port of Redirection Server