Ir para conteúdo

Featured Replies

Postado
  • Este é um post popular.

Olá TibiaKing!

Esse script necessita um pouco mais de conhecimento, pois precisa adicionar códigos em C++ ao distro.

O script adiciona você em uma espécie de fila, assim que a fila completar 5 pessoas, automaticamente um grupo é formado e as 5 pessoas são teleportadas para dentro da dungeon ou quest.

Basicamente funciona assim:

  • Player (Eu): /queue join
  • Player (Outro): /queue join
  • Player (Outro): /queue join
  • Player (Outro): /queue join
  • Player (Outro): /queue join

Onde queue significa fila.

Uma pequena demonstração

2eof85j.jpg

Database (MySQL/PHPMyAdmin)


CREATE TABLE `dungeon_finder` (`id` INT(8) AUTO_INCREMENT PRIMARY KEY, `player_id` INT(255))

Talkactions


function onSay(cid, words, param, channel)

if(param == "join") then

  query = db.getResult("SELECT * FROM `dungeon_finder` WHERE `player_id` = " ..  getPlayerGUID(cid) .. "")

  if(getPlayerStorageValue(cid, CONFIG.DUNGEON_STORAGE) > 1) then

   if(getPlayerStorageValue(cid, CONFIG.DUNGEON_STORAGE) > os.time()) then

	doPlayerSendCancel(cid, "You can't join queue with deserter debuff.")

	doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)

	return true

   end

  end

  if(CONFIG.AREA) then

   if(not(isInArea(getPlayerPosition(cid), (CONFIG.AREA).FROMPOS, (CONFIG.AREA).TOPOS))) then

	doPlayerSendCancel(cid, "You're not in required area to join the queue.")

	doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)

	return true

   end

  end

  if(CONFIG.PZ_REQUIRED) then

   if(not(getTilePzInfo(getPlayerPosition(cid)))) then

	doPlayerSendCancel(cid, "You're not in protection zone to join the queue.")

	doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)

	return true

   end

  end

  if(CONFIG.REQUIRED_LEVEL) then

   if(getPlayerLevel(cid) < CONFIG.REQUIRED_LEVEL) then

	doPlayerSendCancel(cid, "You don't have required level to join the queue. The minimum level to join the queue is " .. CONFIG.REQUIRED_LEVEL .. ".")

	doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)

	return true

   end

  end

  if(CONFIG.SKULL) then

   if(getPlayerSkullType(cid) >= CONFIG.SKULL) then

	doPlayerSendCancel(cid, "Murderers are not allowed to join the queue.")

	doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)

	return true

   end

  end

  if(CONFIG.IN_FIGHT) then

   if(getCreatureCondition(cid, CONDITION_INFIGHT)) then

	doPlayerSendCancel(cid, "You can't be in combat in order to join the queue.")

	doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)

	return true

   end

  end

  if(isInParty(cid)) then

   doPlayerSendCancel(cid, "You can't join queue while you are in party group.")

   doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)

   return true

  end

  if(query:getID() == 0) then

   doPlayerSendCancel(cid, "You are already listed in queue.")

   doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)

   return true

  end

  db.executeQuery("INSERT INTO `dungeon_finder` SET `player_id` = " .. getPlayerGUID(cid) .. ";")

  doSendMagicEffect(getPlayerPosition(cid), CONST_ME_MAGIC_BLUE)

  doCreatureSay(cid, "You've beed queued in dungeon finder - random mode.", TALKTYPE_ORANGE_1)

elseif(param == "remove") then

  query = db.getResult("SELECT * FROM `dungeon_finder` WHERE `player_id` = " ..  getPlayerGUID(cid) .. "")

  if(query:getID() == -1) then

   doPlayerSendCancel(cid, "You are not listed in the queue.")

   doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)

   return true

  end

  db.executeQuery("DELETE FROM `dungeon_finder` WHERE `player_id` = " .. getPlayerGUID(cid) .. ";")

  doCreatureSay(cid, "You've beed removed from queue.", TALKTYPE_ORANGE_1)

  doSendMagicEffect(getPlayerPosition(cid), CONST_ME_MAGIC_RED)

end

return true

end

Globalevents


local DUNGEONS = {

[1] = {NAME = "Test dungeon", LEVEL = 30, POS = {x = 450, y = 357, z = 15}},

}


local condition = createConditionObject(CONDITION_INFIGHT)

setConditionParam(condition, CONDITION_PARAM_TICKS, 15000)


function onThink(cid, interval)

DUNGEON = DUNGEONS[math.random(1, table.maxn(DUNGEONS))]

players = {}

for i = 1, 1000 do

  if(table.maxn(players) == 5) then

   break

  end

  query = db.getResult("SELECT * FROM `dungeon_finder` WHERE `id` = " .. i .. ";")

  if(query:getID() > -1) then

   pid = getPlayerByName(getPlayerNameByGUID(query:getDataInt("player_id")))

   if(getPlayerStorageValue(pid, CONFIG.DUNGEON_STORAGE) > 1) then

	return true

   end

   if(getPlayerLevel(pid) > DUNGEON.LEVEL and getPlayerLevel(pid) < DUNGEON.LEVEL + 50) then

	table.insert(players, getPlayerGUID(pid))

   end

   query:free()

  end

end

if(table.maxn(players) == 5) then

  for i = 1, 5 do

   pid = getPlayerByName(getPlayerNameByGUID(players[i]))

   if(i == 1) then

	doPlayerSendTextMessage(pid, MESSAGE_STATUS_CONSOLE_BLUE, "You were chosen to be a dungeon guide.")

	addEvent(doCreatureSay, 15200, pid, "You and your team were teleported to the " .. DUNGEON.NAME .. ".", TALKTYPE_ORANGE_1)

	for j = 2, 5 do

	 lid = getPlayerByName(getPlayerNameByGUID(players[j]))

	 doPlayerInviteToParty(pid, lid)

	end

   else

	doPlayerJoinParty(pid, getPlayerByName(getPlayerNameByGUID(players[1])))

   end

   delay = 0

   for i = 1, 15 do

	addEvent(doPlayerSendTextMessage, delay + 1000, pid, MESSAGE_STATUS_CONSOLE_BLUE, "A dungeon group for you has been found. You'll be teleported to the dungeon in " .. 15 - i .. " seconds.")

	delay = delay + 1000

   end

   doAddCondition(pid, condition)

   addEvent(doTeleportThing, 15000, pid, DUNGEON.POS)

   addEvent(doSendMagicEffect, 15000, DUNGEON.POS, CONST_ME_TELEPORT)

   db.executeQuery("DELETE FROM `dungeon_finder` WHERE `player_id` = " .. players[i] .. ";")

   if(CONFIG.QUIT_POS) then

	setPlayerStorageValue(pid, 9001, getPlayerPosition(pid).x)

	setPlayerStorageValue(pid, 9002, getPlayerPosition(pid).y)

	setPlayerStorageValue(pid, 9003, getPlayerPosition(pid).z)

   end

   setPlayerStorageValue(pid, CONFIG.DUNGEON_STORAGE, 1)

  end

end

return true

end

CreatureEvents


function onLogout(cid)

query = db.getResult("SELECT * FROM `dungeon_finder` WHERE `player_id` = " ..  getPlayerGUID(cid) .. ";")

if(query:getID() == -1) then

  return true

end

db.executeQuery("DELETE FROM `dungeon_finder` WHERE `player_id` = " .. getPlayerGUID(cid) .. ";")

return true

end


function onLeaveParty(cid)

if(getPlayerStorageValue(cid, CONFIG.DUNGEON_STORAGE) == 1) then

  setPlayerStorageValue(cid, CONFIG.DUNGEON_STORAGE, -1)

  if(CONFIG.DESERTER_DEBUFF_TIME) then

   setPlayerStorageValue(cid, CONFIG.DUNGEON_STORAGE, os.time() + CONFIG.DESERTER_DEBUFF_TIME)

   doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You've been marked with deserter debuff for " .. CONFIG.DESERTER_DEBUFF_TIME / 3600 .. " hour/s. For this time you can't join the queue again.")

  end

  TMP_POS = CONFIG.QUIT_POS and {x = getPlayerStorageValue(cid, 9001), y = getPlayerStorageValue(cid, 9002), z = getPlayerStorageValue(cid, 9003)} or getPlayerMasterPos(cid)

  doTeleportThing(cid, TMP_POS)

  doSendMagicEffect(TMP_POS, CONST_ME_TELEPORT)

  for i = 9001, 9003 do

   setPlayerStorageValue(cid, i, -1)

  end

end

return true

end

lib


CONFIG = {

AREA = false, -- if false then everyone can join queue everywhere, if you want certain area add AREA = {FROMPOS = {}, TOPOS = {}}

PZ_REQUIRED = false, -- requirement of standing in pz, if you don't want it just set PZ_REQUIRED = false

REQUIRED_LEVEL = 30, -- required level to join the queue, if you don't want it just set REQUIRED_LEVEL = false

SKULL = 1, -- skull that is not acceptable while joining queue, if you want players join with skulls just set SKULL = false

IN_FIGHT = true, -- if player is in fight he can't join the queue, IN_FIGHT = false to disable

QUIT_POS = false, -- if you want player to go back to his previous position (from which he got teleported to the dungeon) set QUIT_POS = true, if set to false it'll teleport player to his temple

DESERTER_DEBUFF_TIME = 1800, -- 60 = 1 min, 3600 = 1h

DUNGEON_STORAGE = 9005

}

C++

  • luascript.cpp

int32_t LuaScriptInterface::luaDoPlayerJoinParty(lua_State* L)

{

//doPlayerJoinParty(cid, lid)

ScriptEnviroment* env = getEnv();[/left]

Player* leader = env->getPlayerByUID(popNumber(L));

if(!leader)

{

  errorEx(getError(LUA_ERROR_PLAYER_NOT_FOUND));

  lua_pushboolean(L, false);

}

Player* player = env->getPlayerByUID(popNumber(L));

if(!player)

{

  errorEx(getError(LUA_ERROR_PLAYER_NOT_FOUND));

  lua_pushboolean(L, false);

}

g_game.playerJoinParty(player->getID(), leader->getID());

lua_pushboolean(L, true);

return 1;

}

Coloque:

int32_t LuaScriptInterface::luaDoPlayerInviteToParty(lua_State* L)

{

//doPlayerInviteToParty(cid, pid)

ScriptEnviroment* env = getEnv();

Player* leader = env->getPlayerByUID(popNumber(L));

if(!leader)

{

  errorEx(getError(LUA_ERROR_PLAYER_NOT_FOUND));

  lua_pushboolean(L, false);

}

Player* player = env->getPlayerByUID(popNumber(L));

if(!player)

{

  errorEx(getError(LUA_ERROR_PLAYER_NOT_FOUND));

  lua_pushboolean(L, false);

}

g_game.playerInviteToParty(player->getID(), leader->getID());

lua_pushboolean(L, true);

return 1;

}

  • creatureevent.h
Depois de:

CREATURE_EVENT_PREPAREDEATH,

Coloque:

CREATURE_EVENT_LEAVEPARTY

Depois de:

bool playerLogout(Player* player, bool forceLogout);

Coloque:

uint32_t executeLeaveParty(Player* player);

Depois de:

uint32_t executePrepareDeath(Creature* creature, DeathList deathList);

Coloque:

uint32_t executeLeaveParty(Player* player);

  • creatureevent.cpp
Depois de:

else if(tmpStr == "preparedeath")

  m_type = CREATURE_EVENT_PREPAREDEATH;

Coloque:

else if(tmpStr == "leaveparty")

  m_type = CREATURE_EVENT_LEAVEPARTY;

Depois de:

case CREATURE_EVENT_PREPAREDEATH:

   return "onPrepareDeath";

Coloque:

case CREATURE_EVENT_LEAVEPARTY:

   return "onLeaveParty";

Depois de:

case CREATURE_EVENT_PREPAREDEATH:

   return "cid, deathList";

Coloque:

case CREATURE_EVENT_LEAVEPARTY:

   return "cid";

Depois da função:

uint32_t CreatureEvent::executeFollow(Creature* creature, Creature* target)...

Coloque:

uint32_t CreatureEvent::executeLeaveParty(Player* player)

{

//onLeaveParty(cid)

if(m_interface->reserveEnv())

{

  ScriptEnviroment* env = m_interface->getEnv();

  #ifdef __DEBUG_LUASCRIPTS__

   std::stringstream desc;

   desc << player->getName();

   env->setEventDesc(desc.str());

  #endif

  env->setScriptId(m_scriptId, m_interface);

  env->setRealPos(player->getPosition());

  lua_State* L = m_interface->getState();

  m_interface->pushFunction(m_scriptId);

  lua_pushnumber(L, env->addThing(player));

  bool result = m_interface->callFunction(1);

  m_interface->releaseEnv();

  return result;

}

else

{

  std::cout << "[Error - CreatureEvent::executeAdvance] Call stack overflow." << std::endl;

  return 0;

}

}

  • game.cpp
Mude:

bool Game::playerLeaveParty(uint32_t playerId)

{

Player* player = getPlayerByID(playerId);

if(!player || player->isRemoved())

  return false;

if(!player->getParty() || player->hasCondition(CONDITION_INFIGHT))

  return false;


return player->getParty()->leave(player);

}

Para:

bool Game::playerLeaveParty(uint32_t playerId)

{

Player* player = getPlayerByID(playerId);

if(!player || player->isRemoved())

  return false;

if(!player->getParty() || player->hasCondition(CONDITION_INFIGHT))

  return false;


CreatureEventList leavePartyEvents = player->getCreatureEvents(CREATURE_EVENT_LEAVEPARTY);

for(CreatureEventList::iterator it = leavePartyEvents.begin(); it != leavePartyEvents.end(); ++it)

  (*it)->executeLeaveParty(player);

return player->getParty()->leave(player);

}

E é isso galera, o local da quest pode ser mudado/adicionado no GlobalEvent, mais uma maravilha do Teckman

Depois de:

//doPlayerJoinParty(cid, lid)

lua_register(m_luaState, "doPlayerJoinParty", LuaScriptInterface::luaDoPlayerJoinParty);

Coloque:

  //doPlayerInviteToParty(cid, pid)

lua_register(m_luaState, "doPlayerInviteToParty", LuaScriptInterface::luaDoPlayerInviteToParty);

Depois de:

Editado por Guilherme. (veja o histórico de edições)

29161_4.png

 

 

2d168ur.png

 

  • Respostas 12
  • Visualizações 4.6k
  • Created
  • Última resposta

Top Posters In This Topic

Most Popular Posts

  • As sources do servidor são basicamente isso Doug: https://opentibia.svn.sourceforge.net/svnroot/opentibia/otserv/trunk/ Esse é um link do TFS OTServ 0.6.3 Version:revision number :6052

  • Bom, sei que já faz muuuuito tempo, espero que não seja considerado FLOOD, estou acrescentando ao tópico...   -TESTADO EM 0.4 TFS.   Em luascript.cpp, mude: //doPlayerInviteToParty(cid, pid) lu

Postado

Guido obrigado por responder, mais queria saber como edito essas sources?

Respondendo a sua pergunta, seria um tipo de uma quest em tal lugar, dai beleza os players se acomodam na entrada da quest e fazem um tipo de "grupo" com 5 pessoas, ou você mesmo edita aqui:

if(table.maxn(players) == 5) then

Após isso os jogadores executam o comando e quando completar 5 jogadores que executaram o comando, são teleports automaticamente para dentro da Quest/Dungeon, estilo WoW.

Editado por Doughell (veja o histórico de edições)

E-mail para contato: [email protected]

Quer ter um fórum mais organizado? Cumpra as regras!

EU VOLTEI GAROTAS!

31/12/2011

Atenciosamente,

Guilherme Salviati.

Postado
  • Autor

As sources do servidor são basicamente isso Doug:

https://opentibia.svn.sourceforge.net/svnroot/opentibia/otserv/trunk/

Esse é um link do TFS

OTServ 0.6.3

Version:revision number :6052

Client version: 8.60

Após baixar as tais sources e edita-las você deverá compilar elas com algum compilador C++ (preferencial DEV CPP)

Na área de programação open tibia tem um tutorial do Matheus.

29161_4.png

 

 

2d168ur.png

 

Participe da conversa

Você pode postar agora e se cadastrar mais tarde. Se você tem uma conta, faça o login para postar com sua conta.

Visitante
Responder

Quem Está Navegando 0

  • Nenhum usuário registrado visualizando esta página.

Estatísticas dos Fóruns

  • Tópicos 96.9k
  • Posts 519.6k

Informação Importante

Confirmação de Termo