• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Feature Age System

tetra20

DD
Joined
Jan 17, 2009
Messages
1,315
Solutions
4
Reaction score
323
Location
Egypt
Game.cpp
Code:
  if(player->hasCustomFlag(PlayerCustomFlag_CanSeePosition))
   {
     ss << std::endl << "Position: [X: " << thingPos.x << "] [Y: " << thingPos.y << "] [Z: " << thingPos.z << "]";
     if(Tile* tile = getTile(thingPos))
     {
       if(House* house = tile->getHouse())
         ss << " [House: " << house->getId() << "]";
     }

     ss << ".";
   }

Above It,Add This

Code:
  std::string year;
   if (const Creature* creature = thing->getCreature())
   {
     if (const Player* destPlayer = creature->getPlayer())
     {
       destPlayer->getStorage("6723", year);
       int32_t YearSay = atoi(year.c_str()) / 60;
       int32_t MonthSay =  ((atoi(year.c_str()) / 5) % 12)+1;
       if (MonthSay > 0 || YearSay > 0)
       {
         if (thing != player)
           ss << std::endl << "He is " << std::floor(YearSay) << " Years, " << std::floor(MonthSay) << " Months old.";
         else
           ss << std::endl << "You are " << std::floor(YearSay) << " Years, " << std::floor(MonthSay) << " Months old.";
       }
       else {
         if (thing != player)
           ss << std::endl << "He Was Just Born.";
         else
           ss << std::endl << "You Were Just Born";
       }
     }
   }

Then in globalevents.xml
Code:
<globalevent name="age" interval="60000" event="script" value="age.lua"/>
globalevents/scripts/age.lua
add
Code:
function onThink(interval)
   if #getPlayersOnline() >= 1 then
     for i = 1,#getPlayersOnline() do
       doPlayerSetStorageValue(getPlayersOnline()[i],6723, getPlayerStorageValue(getPlayersOnline()[i],6723) + 1)
     end
   end

   return true
end

How it Looks like Ingame:
ddb22e332eb98d16766e8481e12d023e.png


How it Works:
Each 1 minute, the player will get +1 in the storage, and each 5 points = 1 month
so if you change 60000 to 120000 it will be 1 point each 2 minutes, and so on

Known Bugs:
It's Always He

-- Fix
Code:
  if (const Creature* creature = thing->getCreature())
   {
     if (const Player* destPlayer = creature->getPlayer())
     {
       destPlayer->getStorage("6723", year);
       int32_t YearSay = atoi(year.c_str()) / 60;
       int32_t MonthSay =  ((atoi(year.c_str()) / 5) % 12)+1;
       if (MonthSay > 0 || YearSay > 0)
       {
         if (thing != player)
           ss << std::endl << (destPlayer->getSex(false) == PLAYERSEX_FEMALE ? "She" : "He") << "is" << std::floor(YearSay) << " Years, " << std::floor(MonthSay) << " Months old.";
         else
           ss << std::endl << "You are " << std::floor(YearSay) << " Years, " << std::floor(MonthSay) << " Months old.";
       }
       else {
         if (thing != player)
           ss << std::endl << (destPlayer->getSex(false) == PLAYERSEX_FEMALE ? "She" : "He") << " Was Just Born.";
         else
           ss << std::endl << "You Were Just Born";
       }
     }
   }

Not sure if it will work right now
 
Back
Top