What's new

7.6+ Ban system (ctrl+Y)

Status
Not open for further replies.

MiZ

User
Joined
Mar 3, 2011
Messages
13
Reaction score
0
1. Opis kodu:
Kod to system banowania CTRL + Y. Jest mo?liwo?? banowania na dni. Wiele os?b poszukiwa?o tego kodu dlatego go opublikowa?em. Zosta? on wyci?ty ze znanego silnika Kentana OTS.
2.Autor:
Autor: Huczu
Opublikowa?: Xelix i MiZ
3.Kod:
W game.cpp pod:
Code:
        if (attackedPlayer->skullType == SKULL_NONE)
        {
            player->skullKills++;
            std::string justice(std::string("Warning! The murder of ") + attackedPlayer->getName() + " was not justified!");
            player->sendTextMessage(MSG_RED_INFO, justice.c_str());
dodaj:
Code:
#ifdef HUCZU_BAN_SYSTEM
            if (player->skullKills >= g_config.BAN_UNJUST)
            {
                banPlayer(player, "Przekroczono limit zabijania graczy", "AccountBan", "2", 0);
            }else
#endif //HUCZU_BAN_SYSTEM
nast?pnie pod tym:
Code:
        creatureThrowRune(player, attackedCreature->pos, runeAreaSpell);
        player->addManaSpent(mana);
        player->mana -= mana;
    }
}
dodajemy to:
Code:
#ifdef HUCZU_BAN_SYSTEM
void Game::banPlayer(Player *player, std::string reason, std::string action, std::string comment, unsigned char IPban)
{
    int bantime = 0;
    if(player){
        if(action == "BanNaDni")
        bantime = atoi(comment.c_str()) * 86400; // ban na dni : )
        if(action != "BanNaDni")
        bantime = atoi(comment.c_str()) * 3600/*86400*/; //ban na godziny ;)
        if(player->finalwarning == 1)
        player->deleted = 1;
        if(action == "Namelock/AccountBan+FinalWarning"){
        player->namelock = 1;
        player->finalwarning = 1;
        }
        if(action == "AccountBan+FinalWarning")
        player->finalwarning = 1;
        if(action == "Namelock")
        player->namelock = 1;
        if(reason == "Przekroczono limit zabijania graczy")
        bantime = g_config.getGlobalNumber("pkbandays",3) * 3600;
        player->banned = 1;
        player->comment = comment;
        player->reason = reason;
        player->action = action;
#ifdef USING_VISUAL_2005
        player->banstart = _time32(NULL);
#else
        player->banstart = std::time(NULL);
#endif
        player->banend = player->banstart + bantime;
        time_t endBan = player->banend;
        player->banrealtime = ctime(&endBan);
        if(IPban != 0){
            std::pair<unsigned long, unsigned long> IpNetMask;
IpNetMask.first = player->lastip;
IpNetMask.second = 0xFFFFFFFF;
if(IpNetMask.first > 0)
    bannedIPs.push_back(IpNetMask);
        }
        std::stringstream ban;
        ban << "Zostales zbanowany za " << reason << "!";
        player->sendTextMessage(MSG_INFO, ban.str().c_str());
        player->kickPlayer();
     }
}
#endif //HUCZU_BAN_SYSTEM
w game.h pod tym:
Code:
class Game {
public:
	Game();
  ~Game();
dodajemy to:
Code:
#ifdef HUCZU_BAN_SYSTEM     
    void banPlayer(Player *player, std::string reason, std::string action, std::string comment, unsigned char IPban);
#endif //HUCZU_BAN_SYSTEM
Teraz w ioplayerxml.cpp pod tym:
Code:
                nodeValue = (char*)xmlGetProp(p, (const xmlChar *) "z");
                if(nodeValue) {
                    player->pos.z=atoi(nodeValue);
                    xmlFreeOTSERV(nodeValue);
                }
                else
                    isLoaded = false;
            }
dodaj:
Code:
#ifdef HUCZU_BAN_SYSTEM              
       else if(str=="ban")
{
    nodeValue = (char*)xmlGetProp(p, (const xmlChar *) "banned");
    if(nodeValue) {
     player->banned=atoi(nodeValue);
     xmlFreeOTSERV(nodeValue);
    }
    else
     isLoaded = false;
    nodeValue = (char*)xmlGetProp(p, (const xmlChar *) "banstart");
    if(nodeValue) {
     player->banstart=atoi(nodeValue);
     xmlFreeOTSERV(nodeValue);
    }
    else
     isLoaded = false;
    nodeValue = (char*)xmlGetProp(p, (const xmlChar *) "banend");
    if(nodeValue) {
     player->banend=atoi(nodeValue);
     xmlFreeOTSERV(nodeValue);
    }
    else
     isLoaded = false;
    nodeValue = (char*)xmlGetProp(p, (const xmlChar *) "comment");
    if(nodeValue) {
     player->comment=nodeValue;
     xmlFreeOTSERV(nodeValue);
    }
    else
     isLoaded = false;
    nodeValue = (char*)xmlGetProp(p, (const xmlChar *) "reason");
    if(nodeValue) {
     player->reason=nodeValue;
     xmlFreeOTSERV(nodeValue);
    }
    else
     isLoaded = false;
    nodeValue = (char*)xmlGetProp(p, (const xmlChar *) "action");
    if(nodeValue) {
     player->action=nodeValue;
     xmlFreeOTSERV(nodeValue);
    }
    else
     isLoaded = false;
    nodeValue = (char*)xmlGetProp(p, (const xmlChar *) "deleted");
    if(nodeValue) {
     player->deleted=atoi(nodeValue);
     xmlFreeOTSERV(nodeValue);
    }
    else
     isLoaded = false;
    nodeValue = (char*)xmlGetProp(p, (const xmlChar *) "finalwarning");
    if(nodeValue) {
     player->finalwarning=atoi(nodeValue);
     xmlFreeOTSERV(nodeValue);
    }
    else
     isLoaded = false;
    nodeValue = (char*)xmlGetProp(p, (const xmlChar *) "banrealtime");
    if(nodeValue) {
     player->banrealtime=nodeValue;
     xmlFreeOTSERV(nodeValue);
    }
    else
     isLoaded = false;
       nodeValue = (char*)xmlGetProp(root, (const xmlChar *) "namelock");
        if(nodeValue) {
            player->namelock=atoi(nodeValue);
            xmlFreeOTSERV(nodeValue);
        }
        else
            isLoaded = false;
}
#endif //HUCZU_BAN_SYSTEM
nast?pnie pod tym:
Code:
    pn = xmlNewNode(NULL,(const xmlChar*)"mana");
    sb << player->mana;      xmlSetProp(pn, (const xmlChar*) "now", (const xmlChar*)sb.str().c_str());        sb.str("");
    sb << player->manamax;   xmlSetProp(pn, (const xmlChar*) "max", (const xmlChar*)sb.str().c_str());        sb.str("");
    sb << player->manaspent; xmlSetProp(pn, (const xmlChar*) "spent", (const xmlChar*)sb.str().c_str());      sb.str("");
    xmlAddChild(root, pn);
dodaj to:
Code:
#ifdef HUCZU_BAN_SYSTEM      
    pn = xmlNewNode(NULL,(const xmlChar*)"ban");
    sb << player->banned;     xmlSetProp(pn, (const xmlChar*) "banned", (const xmlChar*)sb.str().c_str());    sb.str("");
    sb << player->banstart;    xmlSetProp(pn, (const xmlChar*) "banstart", (const xmlChar*)sb.str().c_str()); sb.str("");
    sb << player->banend;     xmlSetProp(pn, (const xmlChar*) "banend", (const xmlChar*)sb.str().c_str());    sb.str("");
    sb << player->comment;     xmlSetProp(pn, (const xmlChar*) "comment", (const xmlChar*)sb.str().c_str()); sb.str("");
    sb << player->reason;     xmlSetProp(pn, (const xmlChar*) "reason", (const xmlChar*)sb.str().c_str());    sb.str("");
    sb << player->action;     xmlSetProp(pn, (const xmlChar*) "action", (const xmlChar*)sb.str().c_str());    sb.str("");
    sb << player->deleted;     xmlSetProp(pn, (const xmlChar*) "deleted", (const xmlChar*)sb.str().c_str());    sb.str("");
    sb << player->finalwarning;     xmlSetProp(pn, (const xmlChar*) "finalwarning", (const xmlChar*)sb.str().c_str());    sb.str("");
    sb << player->banrealtime;     xmlSetProp(pn, (const xmlChar*) "banrealtime", (const xmlChar*)sb.str().c_str());    sb.str("");
    sb << player->namelock;           xmlSetProp(root, (const xmlChar*) "namelock", (const xmlChar*)sb.str().c_str());  sb.str("");
    xmlAddChild(root, pn);
#endif //HUCZU_BAN_SYSTEM
Teraz otserv.cpp pod tym:
Code:
                        if(playerexist && !g_config.getGlobalNumber("allowclones", 0)){
                            #ifdef __DEBUG_PLAYERS__
                            std::cout << "reject player... (already logged in)" << std::endl;
                            #endif
                            msg.Reset();
                            msg.AddByte(0x14);
                            msg.AddString("You are already logged in.");
                            msg.WriteToSocket(s);
                        }
Dodaj to:
Code:
#ifdef HUCZU_BAN_SYSTEM
                          long long timeNow = std::time(NULL); // VISUAL
                        else if (player->banned && timeNow < player->banend){
                            msg.Reset();
                            msg.AddByte(0x14);
                            time_t endBan = player->banend;
                            std::stringstream txt;
                            if(player->deleted == 0) // checks if not deleted
                            txt << "Twoja postac zostala zablokowana! Powod: " << player->reason << ".\nTwoj ban zostanie zdjety " << ctime(&endBan) << "Sprobuj zalogowac sie po tej dacie.";
                            if(player->namelock != 0) // gdy namelock
                            txt << "Dostales rowniez namelocka. Zmien swoj nick na stronie.";
                            if(player->deleted != 0)// deleted == 1
                            txt << "Twoja postac zostala usunieta z serwera!\nNigdy nie zostanie juz odbanowana!";
                             msg.AddString(txt.str().c_str());
                             msg.WriteToSocket(s);
                         }
                         else if(player->banned && timeNow > player->banend && player->deleted == 0){  
                            player->banned = 0;
                            player->comment = "";
                            player->reason = "";
                            player->action = ""; 
                            IOPlayer::instance()->savePlayer(player);
                            msg.Reset();
                            msg.AddByte(0x14);
                            msg.AddString("Zostales odbanowany. Mozesz sie teraz zalogowac.");
                            msg.WriteToSocket(s);
                        }
                        else if(player->namelock != 0){
                        msg.Reset();
                        msg.AddByte(0x14);
                        msg.AddString("Posiadasz namelocka. Zmien swoj nick na stronie.");
                        msg.WriteToSocket(s);
                        }
#endif //HUCZU_BAN_SYSTEM
Teraz w player.cpp pod tym:
Code:
    guildId    = 0;
Dodaj to:
Code:
#ifdef HUCZU_BAN_SYSTEM
    banned     = 0;  
    banstart = 0;  
    banend     = 0;  
    comment    = ""; 
    reason     = ""; 
    action     = ""; 
    deleted = 0; 
    finalwarning = 0; 
    banrealtime = ""; 
    namelock = 0;
#endif //HUCZU_BAN_SYSTEM
Teraz player.h pod tym:
Code:
    void kickPlayer();
Dodaj to:
Code:
#ifdef HUCZU_BAN_SYSTEM       
    int banned , banstart, banend, deleted, finalwarning;
    std::string comment, reason, action, banrealtime;
    unsigned char namelock;
#endif //HUCZU_BAN_SYSTEM
Teraz protocol76.cpp pod tym:
Code:
    case 0x99: // close Channel
        parseCloseChannel(msg);
        break;
Dodaj to:
Code:
#ifdef HUCZU_BAN_SYSTEM    
    case 0xe7: 
        parseGM(msg);
        break;
#endif //HUCZU_BAN_SYSTEM
Nast?pnie zamie? to:
Code:
/*msg.AddByte(0x00);//TODO?. GM actions
     msg.AddByte(0xFF);msg.AddByte(0xFF);msg.AddByte(0xFF);msg.AddByte(0xFF);
     msg.AddByte(0xFF);msg.AddByte(0xFF);msg.AddByte(0xFF);msg.AddByte(0xFF);
     msg.AddByte(0xFF);msg.AddByte(0xFF);msg.AddByte(0xFF);msg.AddByte(0xFF);
     msg.AddByte(0xFF);msg.AddByte(0xFF);msg.AddByte(0xFF);msg.AddByte(0xFF);
     msg.AddByte(0xFF);msg.AddByte(0xFF);msg.AddByte(0xFF);msg.AddByte(0xFF);
     msg.AddByte(0xFF);msg.AddByte(0xFF);msg.AddByte(0xFF);msg.AddByte(0xFF);
msg.AddByte(0xFF);msg.AddByte(0xFF);msg.AddByte(0xFF);msg.AddByte(0xFF);
     msg.AddByte(0xFF);msg.AddByte(0xFF);msg.AddByte(0xFF);msg.AddByte(0xFF);
*/
Na to:
Code:
#ifdef HUCZU_BAN_SYSTEM
std::stringstream myIP2;
            std::string myIP;
            unsigned char ip[4];
            *(unsigned long*)&ip = player->getIP();
            myIP2 << (unsigned int)ip[0] << "." << (unsigned int)ip[1] <<
             "." << (unsigned int)ip[2] << "." << (unsigned int)ip[3];
            myIP = myIP2.str();
if(add_player->access >= 1){
     msg.AddByte(0x0B);
     msg.AddByte(0xFF);msg.AddByte(0xFF);msg.AddByte(0xFF);msg.AddByte(0xFF);
     msg.AddByte(0xFF);msg.AddByte(0xFF);msg.AddByte(0xFF);msg.AddByte(0xFF);
     msg.AddByte(0xFF);msg.AddByte(0xFF);msg.AddByte(0xFF);msg.AddByte(0xFF);
     msg.AddByte(0xFF);msg.AddByte(0xFF);msg.AddByte(0xFF);msg.AddByte(0xFF);
     msg.AddByte(0xFF);msg.AddByte(0xFF);msg.AddByte(0xFF);msg.AddByte(0xFF);
     msg.AddByte(0xFF);msg.AddByte(0xFF);msg.AddByte(0xFF);msg.AddByte(0xFF);
msg.AddByte(0xFF);msg.AddByte(0xFF);msg.AddByte(0xFF);msg.AddByte(0xFF);
     msg.AddByte(0xFF);msg.AddByte(0xFF);msg.AddByte(0xFF);msg.AddByte(0xFF);
        }
#endif //HUCZU_BAN_SYSTEM
 
Status
Not open for further replies.
Top