Reklama
Strona 1 z 3 123 OstatniaOstatnia
Pokazuje wyniki od 1 do 15 z 41

Temat: Bed System

  1. #1
    Kamil0

    Domyślny Bed System

    Bed System ;)

    Odrazu na wstepie mowie ze to nei jest moj bed system.Znalazlem go na otfans.pl i chce tu go zamiescic

    w pliku game.cpp na koncu plku dodaj:

    Kod PHP:
    #ifdef TLM_BEDS 
    bool Game::loadBeds(std::string file) 
    { 
      xmlDocPtr doc; 
      doc = xmlParseFile(file.c_str()); 
      if (doc){ 
       xmlNodePtr root, p, tmp; 
       root = xmlDocGetRootElement(doc); 
       if (xmlStrcmp(root->name, (const xmlChar*)"beds")) { 
         xmlFreeDoc(doc); 
         return -1; 
       } 
        tmp = root->children; 
        int x,y,z,id; 
        while(tmp){ 
          if (strcmp((char*) tmp->name, "bed")==0){      
            x = atoi((const char*) xmlGetProp(tmp, (const xmlChar*) "x")); 
            y = atoi((const char*) xmlGetProp(tmp, (const xmlChar*) "y")); 
            z = atoi((const char*) xmlGetProp(tmp, (const xmlChar*) "z")); 
            id = atoi((const char*) xmlGetProp(tmp, (const xmlChar*) "id")); 
            Position mainPos(x, y, z); 
            Item *mainItem = Item::CreateItem(id);  
            Tile *mainTile = getTile(mainPos.x, mainPos.y, mainPos.z); 
            if (mainTile && mainItem){ 
              Position nextPos(x, y, z); 
              Item *nextItem = Item::CreateItem(id+1); 
              if (id == 1754 || id == 1758 || id == 1762 || id == 1766){ 
                nextPos.y++; 
              } 
              else if(id == 1756 || id == 1760 || id == 1764 || id == 1768){ 
                nextPos.x++; 
              } 
              Tile *nextTile = getTile(nextPos.x, nextPos.y, nextPos.z);    
              if (nextTile && nextItem){ 
                mainTile->addThing(mainItem); 
                mainItem->pos = mainPos; 
                nextTile->addThing(nextItem); 
                nextItem->pos = nextPos; 
              } 
            } 
          } 
          tmp = tmp->next; 
        }      
        xmlFreeDoc(doc); 
        return 0; 
      } 
      return -1; 
    } 
    std::string Game::getBedSleeper(const Position pos) 
    { 
      std::string file="data/beds.xml"; 
      xmlDocPtr doc; 
      doc = xmlParseFile(file.c_str()); 
      if (doc){ 
        xmlNodePtr root, tmp; 
        root = xmlDocGetRootElement(doc);        
        if (xmlStrcmp(root->name, (const xmlChar*)"beds")) { 
          xmlFreeDoc(doc); 
          return "Nobody"; 
        } 
        tmp = root->children; 
        while(tmp){ 
          if (strcmp((const char*) tmp->name, "bed")==0){ 
            int x = atoi((const char*) xmlGetProp(tmp, (const xmlChar*) "x")); 
            int y = atoi((const char*) xmlGetProp(tmp, (const xmlChar*) "y")); 
            int z = atoi((const char*) xmlGetProp(tmp, (const xmlChar*) "z")); 
            if (x == pos.x && y == pos.y && z == pos.z){ 
              return (const char*)xmlGetProp(tmp, (const xmlChar *)"name"); 
            }  
          } 
          tmp = tmp->next; 
        } 
        xmlFreeDoc(doc); 
      } 
      return "Nobody"; 
    } 
    unsigned int Game::getBedID(const Position pos) 
    { 
      std::string file="data/beds.xml"; 
      xmlDocPtr doc; 
      doc = xmlParseFile(file.c_str()); 
      if (doc){ 
        xmlNodePtr root, tmp; 
        root = xmlDocGetRootElement(doc);        
        if (xmlStrcmp(root->name, (const xmlChar*)"beds")) { 
          xmlFreeDoc(doc); 
          return 0; 
        } 
        tmp = root->children; 
        while(tmp){ 
          if (strcmp((const char*) tmp->name, "bed")==0){ 
            int x = atoi((const char*) xmlGetProp(tmp, (const xmlChar*) "x")); 
            int y = atoi((const char*) xmlGetProp(tmp, (const xmlChar*) "y")); 
            int z = atoi((const char*) xmlGetProp(tmp, (const xmlChar*) "z")); 
            if (x == pos.x && y == pos.y && z == pos.z){ 
              return atoi((const char*) xmlGetProp(tmp, (const xmlChar*) "id")); 
            }  
          } 
          tmp = tmp->next; 
        } 
        xmlFreeDoc(doc); 
      } 
      return 0; 
    } 
    
    bool Game::changeBed(const Position pos, unsigned int oldid, std::string sleepname) 
    { 
      Tile *maintile = getTile(pos.x,pos.y,pos.z); 
      Item *mainitem = dynamic_cast<Item*>(maintile->getThingByStackPos(maintile->getThingCount()-1)); 
      if (mainitem && maintile->isHouse()){ 
        Position tilePos(pos.x, pos.y, pos.z); 
        if (oldid == 1754 || oldid == 1758 || oldid == 1762 || oldid == 1766){ 
          tilePos.y++; 
        } 
        else if(oldid == 1756 || oldid == 1760 || oldid == 1764 || oldid == 1768){ 
          tilePos.x++; 
        } 
        Tile *nexttile = getTile(tilePos.x,tilePos.y,tilePos.z); 
        Item *nextitem = dynamic_cast<Item*>(nexttile->getThingByStackPos(maintile->getThingCount()-1)); 
        if (nextitem && nexttile->isHouse()){  
          if (oldid == 1754 || oldid == 1758){ 
            mainitem->setID(oldid+8); 
          } 
          else if(oldid == 1756){ 
            mainitem->setID(1768); 
          } 
          else if(oldid == 1760){ 
            mainitem->setID(1764); 
          } 
          else if(oldid == 1762 || oldid == 1766){ 
            mainitem->setID(oldid-8); 
          } 
          else if(oldid == 1764){ 
            mainitem->setID(1760); 
          } 
          else if(oldid == 1768){ 
            mainitem->setID(1756); 
          } 
          nextitem->setID(mainitem->getID()+1); 
          creatureBroadcastTileUpdated(pos); 
          creatureBroadcastTileUpdated(tilePos); 
          
          std::string file="data/beds.xml"; 
          xmlDocPtr doc; 
          doc = xmlParseFile(file.c_str()); 
          if (doc){ 
            xmlNodePtr root, tmp; 
            root = xmlDocGetRootElement(doc);        
            if (xmlStrcmp(root->name, (const xmlChar*)"beds")) { 
              xmlFreeDoc(doc); 
              return false; 
            } 
            Position bedPos[1000];// 1000 = number of beds 
            unsigned int id[1000]; 
            std::string name[1000]; 
            int i = 0; 
            tmp = root->children; 
            while(tmp){ 
              if (strcmp((const char*) tmp->name, "bed")==0){ 
                i++; 
                bedPos[i].x = atoi((const char*) xmlGetProp(tmp, (const xmlChar*) "x"  )); 
                bedPos[i].y = atoi((const char*) xmlGetProp(tmp, (const xmlChar*) "y"  )); 
                bedPos[i].z = atoi((const char*) xmlGetProp(tmp, (const xmlChar*) "z"  )); 
                id[i]    = atoi((const char*) xmlGetProp(tmp, (const xmlChar*) "id" )); 
                name[i]   = atoi((const char*) xmlGetProp(tmp, (const xmlChar*) "name")); 
                if (bedPos[i] == pos){ 
                  id[i]  = mainitem->getID(); 
                  name[i] = sleepname; 
                } 
              } 
              tmp = tmp->next; 
            } 
            doc = xmlNewDoc((const xmlChar*)"1.0"); 
            doc->children = xmlNewDocNode(doc, NULL, (const xmlChar*)"beds", NULL); 
           root = doc->children; 
          
            std::stringstream sb; 
            for(int x = 1; x <= i; x++){ 
              tmp = xmlNewNode(NULL,(const xmlChar*)"bed"); 
              sb << bedPos[x].x; xmlSetProp(tmp, (const xmlChar*) "x" ,  (const xmlChar*)sb.str().c_str()); sb.str(""); 
              sb << bedPos[x].y; xmlSetProp(tmp, (const xmlChar*) "y" ,  (const xmlChar*)sb.str().c_str()); sb.str(""); 
              sb << bedPos[x].z; xmlSetProp(tmp, (const xmlChar*) "z" ,  (const xmlChar*)sb.str().c_str()); sb.str(""); 
              sb << id[x];    xmlSetProp(tmp, (const xmlChar*) "id",  (const xmlChar*)sb.str().c_str()); sb.str(""); 
              sb << name[x];   xmlSetProp(tmp, (const xmlChar*) "name", (const xmlChar*)sb.str().c_str()); sb.str(""); 
              xmlAddChild(root, tmp); 
            } 
           xmlSaveFile(file.c_str(), doc); 
           xmlFreeDoc(doc); 
            return true; 
          } 
        } 
      } 
      return false; 
    } 
    Position Game::getBedPos(std::string name) 
    { 
      std::string file="data/beds.xml"; 
      xmlDocPtr doc; 
      doc = xmlParseFile(file.c_str()); 
      if (doc){ 
        xmlNodePtr root, tmp; 
        root = xmlDocGetRootElement(doc);        
        if (xmlStrcmp(root->name, (const xmlChar*)"beds")) { 
          xmlFreeDoc(doc); 
          return Position(0xFFFF,0xFFFF,0xFF); 
        } 
        tmp = root->children; 
        while(tmp){ 
          if (strcmp((const char*) tmp->name, "bed")==0){ 
            std::string sleepname = (const char*)xmlGetProp(tmp, (const xmlChar *)"name"); 
            if (sleepname == name){ 
              int x = atoi((const char*) xmlGetProp(tmp, (const xmlChar*) "x")); 
              int y = atoi((const char*) xmlGetProp(tmp, (const xmlChar*) "y")); 
              int z = atoi((const char*) xmlGetProp(tmp, (const xmlChar*) "z")); 
              return Position(x,y,z); 
            }  
          } 
          tmp = tmp->next; 
        } 
        xmlFreeDoc(doc); 
      } 
      return Position(0xFFFF,0xFFFF,0xFF); 
    } 
    
    void Game::sendMagicEffect(const Position pos, unsigned char type) 
    { 
      SpectatorVec list; 
      SpectatorVec::iterator it; 
      getSpectators(Range(pos, true), list); 
       for(it = list.begin(); it != list.end(); ++it) { 
        Player* spectator = dynamic_cast<Player*>(*it); 
        if (spectator){ 
          spectator->sendMagicEffect(pos, type); 
        } 
      } 
    } 
    #endif //TLM_BEDS
    W pliku game.h pod linijką:
    Kod PHP:
    ~Game();
    dodaj:
    Kod PHP:
    #ifdef TLM_BEDS 
            std::string getBedSleeper(const Position pos); 
              unsigned int getBedID(const Position pos); 
              Position getBedPos(std::string name); 
      
              bool changeBed(const Position pos, unsigned int oldid, std::string sleepname); 
              bool loadBeds(std::string file); 
    #endif //TLM BEDS
    W pliku item.cpp na końcu pliku dodaj
    Kod PHP:
    #ifdef TLM_BEDS 
    bool Item::isBed() 
    { 
    if(id == 1754 || id == 1755 || id == 1756 || id == 1757 || id == 1758 || id == 1759 || id == 1760 || id == 1761 || id == 1762 || id == 1763 || id == 1764 || id == 1765 || id == 1766 || id == 1767 || id == 1768 || id == 1769) 
    return true; 
    else return false; 
    } 
    #endif //TLM_BEDS
    W pliku item.h pod:
    Kod PHP:
    bool isDecaying;
    dodaj:
    Kod PHP:
    #ifdef TLM_BEDS    
        bool isBed(); 
    #endif //TLM_BEDS
    W pliku otserv.cpp pod:
    Kod PHP:
    #ifdef TLM_HOUSE_SYSTEM 
        std::cout << ":: Loading houses.xml...            "; 
        if (!Houses::Load(&g_game)) 
        { 
            ErrorMessage("Could not load houses!"); 
            return -1; 
        } 
        std::cout << "[done]" << std::endl; 
    #endif //TLM_HOUSE_SYSTEM
    Dodaj:
    Kod PHP:
    #ifdef TLM_BEDS 
     std::cout << ":: Loading beds.xml...              "; 
     if(g_game.loadBeds("data/beds.xml")){; 
     ErrorMessage("Could not load data/beds.xml!"); 
     return -1; 
    } 
      std::cout << "[done]" << std::endl; 
    #endif //TLM_BEDS
    W pliku player.cpp pod:
    Kod PHP:
    internal_ping = 0;
    dodaj:
    Kod PHP:
    #ifdef TLM_BEDS 
        lastlogout = 0; 
    #endif //TLM_BEDS
    Na końcu pliku dodaj:
    Kod PHP:
    #ifdef TLM_BEDS 
    void Player::sendLogout() 
    { 
      client->logout(); 
    } 
    
        void Player::sendKick() 
    { 
        this->kicked = true; 
        client->sendKick();    
    } 
    
      
    bool Player::isSleeping() 
    { 
      std::string file="data/beds.xml"; 
      xmlDocPtr doc; 
      doc = xmlParseFile(file.c_str()); 
      if (doc){ 
        xmlNodePtr root, tmp; 
        root = xmlDocGetRootElement(doc);        
        if (xmlStrcmp(root->name, (const xmlChar*)"beds")) { 
          xmlFreeDoc(doc); 
          return false; 
        } 
        tmp = root->children; 
        while(tmp){ 
          if (strcmp((const char*) tmp->name, "bed")==0){ 
            std::string sleepname = (const char*)xmlGetProp(tmp, (const xmlChar *)"name"); 
            if (sleepname == this->name){ 
              return true; 
            }  
          } 
          tmp = tmp->next; 
        } 
        xmlFreeDoc(doc); 
      } 
      return false; 
    } 
    #endif //TLM_BEDS
    W pliku player.h
    pod linijką:
    Kod PHP:
    public:
    dodaj:
    Kod PHP:
    #ifdef TLM_BEDS 
    time_t lastlogout; 
    bool isSleeping(); 
    void sendLogout(); 
             bool kicked; 
        void sendKick(); 
    #endif //TLM_BEDS
    W pliku protocol76.cpp NAD:
    Kod PHP:
    #ifdef TLM_HOUSE_SYSTEM 
            Tile* doorTile = game->getTile(LookPos);
    dodaj:
    Kod PHP:
                 #ifdef TLM_BEDS    
           if(item->isBed()){ 
        Position pos(LookPos.x, LookPos.y, LookPos.z); 
        std::stringstream bedtext;        
        bedtext << "You see a bed"/*<< item->getName()*/ 
        << ".\n " << game->getBedSleeper(pos) << " is sleeping there."; 
        AddTextMessage(newmsg, MSG_INFO, 
        bedtext.str().c_str()); 
        sendNetworkMessage(&newmsg); 
                return; 
        } 
    #endif //TLM_BEDS
    Teraz naciśnij ALT + P przejdź do zakładki PARAMETERS i w sub tabeli C++ compiler dodaj na końcu tabelki:

    Kod PHP:
    -DTLM_BEDS

    Mam nadzieje ze niktorym pomoglem ;)

  2. #2
    konto usunięte

    Domyślny

    Było juz to !!!

  3. Reklama
  4. #3
    konto usunięte

    Domyślny

    a czy dziala to na ots'ach pod 7.6?? Bo widzialem bed system do zrobienia ale on tylko pod 7.5 byl

  5. #4
    konto usunięte

    Domyślny

    Na niekt&#243;rych 7.6 juz jest ale tez dziala tylko cos trzeba pozmieniac jak znajde to dam edita

    PS: m&#243;j setny post:P


    @EDIT
    To jest do 7.6

  6. #5
    Kamil0

    Domyślny

    Cytuj Hudfakt napisał
    Cytat został ukryty, ponieważ ignorujesz tego użytkownika. Pokaż cytat.
    Było juz to !!!

    hm.. mowisz ze bylo to taki mądry jestes to daj mi link jak mowisz ze bylo to uwiezr ja szukalem nie moglem nic znaleśc ... czekam na link

  7. #6

  8. #7
    konto usunięte

    Domyślny

    A jak zrobic z tym bed system gdzie jest ten plik game.cpp: : ??
    Mam YourOts 7.6

  9. #8
    konto usunięte

    Domyślny

    Problem w tym ze nie wszystkie ots'y maja te pliki

  10. #9
    konto usunięte

    Domyślny

    uhm... po 1 takie temat jusz byl a po 2 te bed systemy crashujom otsa jak slyszalem:)!

  11. #10
    konto usunięte

    Domyślny

    lol poco kolejny temat to bylo z 10 razy!!!!!

  12. #11
    Avatar Czepek
    Data rejestracji
    2005
    Położenie
    Świebodzin
    Posty
    24
    Siła reputacji
    0

    Domyślny

    Cytuj Kindo napisał
    Cytat został ukryty, ponieważ ignorujesz tego użytkownika. Pokaż cytat.
    A jak zrobic z tym bed system gdzie jest ten plik game.cpp: : ??
    Mam YourOts 7.6
    plik game.cpp jest w źródłach OTS (source)

    @topic: to może napisz kto go tam dał :<

  13. #12
    BoD3k

    Domyślny

    Hmm... ja zrobiłem wszystko wg. poradnika Twojego i mi nie działa na DeadTouch 1.9. Może zrób sam Beds System pod DeadTouch 1.9 i daj na download, tak będzie najlepiej ;)

  14. #13
    Kamil0

    Domyślny

    Cytuj Hudfakt napisał
    Cytat został ukryty, ponieważ ignorujesz tego użytkownika. Pokaż cytat.

    a nie to sorry szacunek dla Ciebie ;)

  15. #14
    Avatar smietek
    Data rejestracji
    2006
    Wiek
    31
    Posty
    207
    Siła reputacji
    19

    Domyślny

    Ej czy to działa na OTS pod tibie 7,6??

  16. #15
    szymczak

    Domyślny

    Chyba u mnie nie bedzie ale tylko zapytam czy pojdzie na YurOTSa 7.5? I Gdzie sa te pliki .cpp widzialem je w neverlandzie ale w Jerzym(Yurek)nie

Reklama

Informacje o temacie

Użytkownicy przeglądający temat

Aktualnie 1 użytkowników przegląda ten temat. (0 użytkowników i 1 gości)

Podobne tematy

  1. Odpowiedzi: 30
    Ostatni post: 06-03-2017, 21:07
  2. Odpowiedzi: 20
    Ostatni post: 01-01-2016, 19:04
  3. Odpowiedzi: 20
    Ostatni post: 06-12-2015, 20:50
  4. Odpowiedzi: 4
    Ostatni post: 06-03-2012, 18:59
  5. Odpowiedzi: 4
    Ostatni post: 21-08-2011, 18:58

Zakładki

Zakładki

Zasady postowania

  • Nie możesz pisać nowych tematów
  • Nie możesz pisać postów
  • Nie możesz używać załączników
  • Nie możesz edytować swoich postów
  •