Tag:
<talkaction words="!abrir;!quest" event="script" value="nome_do_arquivo.lua"/>
Código:
local config = {
players = {
{x = 1056, y = 1056, z = 7}, --Posições para onde os jogadores serão teleportados.
{x = 1055, y = 1056, z = 7},
{x = 1054, y = 1056, z = 7},
},
storage = {91812, 91813},
}
function onSay(cid, words)
if words == "!abrir" then
if getPlayerGroupId(cid) ~= 6 then
return false
elseif getGlobalStorageValue(config.storage[1]) > -1 then
return doPlayerSendCancel(cid, "The quest is already open.")
end
setGlobalStorageValue(config.storage[1], 1)
broadcastMessage("The quest was open! Waiting for "..#config.players.." players...")
elseif words == "!quest" then
if getGlobalStorageValue(config.storage[1]) < 1 then
return doPlayerSendCancel(cid, "The quest isn't open.")
end
local message, newStorage, count = getCreatureName(cid).." was registered in the quest!", 0, 0
for i = 0, #config.players - 1 do
count = count + 1
newStorage = config.storage[2] + i
if getGlobalStorageValue(newStorage) == getPlayerGUID(cid) then
return doPlayerSendCancel(cid, "You are already registered in the quest.")
elseif getGlobalStorageValue(newStorage) == -1 then
break
end
end
setGlobalStorageValue(newStorage, getPlayerGUID(cid))
doPlayerSendTextMessage(cid, 27, "You were registered in the quest.")
if count == #config.players then
local startQuest, p = true, {}
for i = 0, #config.players - 1 do
local pid = getPlayerByName(getPlayerNameByGUID(getGlobalStorageValue(config.storage[2] + i)))
if not isPlayer(pid) then
if startQuest then
startQuest = false
end
setGlobalStorageValue(config.storage[2] + i, -1)
else
p[#p + 1] = pid
end
end
if startQuest then
for i = 1, #p do
doPlayerSendTextMessage(p[i], MESSAGE_STATUS_CONSOLE_ORANGE, "Good luck at the quest! ^^")
doTeleportThing(p[i], config.players[i])
end
for i = 0, #config.players - 1 do
setGlobalStorageValue(config.storage[2] + i, -1)
end
setGlobalStorageValue(config.storage[1], -1)
message = message.." It has started now, with "..#p.." players!"
end
end
broadcastMessage(message)
end
return true
end






info
Grupo: Campones
Registrado: 23/08/12
Posts: 67
Reputação: +1
Gênero: Masculino
estou criando uma quest pra meu Servidor, e preciso da seguinte função:
abro a quest com um coamndo.... !abrir
o player se registra (uma action, ou talk, tanto faz...) limite máximo de players 8 (alterável se possível).
cada player e teleportado para um lugar diferente, editável.
se alguém puder ajudar... desde já agradeço...