Postado Fevereiro 22, 2015 10 anos Obrigado. c: PS: Não testei. data/lib: config = { day = {"Saturday"}, --Dia(s) que ocorrerá o evento. time = 5, --Tempo de espera de player, em minutos. playerCount = {2, 20}, --Respectivamente, número mínimo e máximo de jogadores no evento. prize = {itemid, count}, --Respectivamente, ID do prêmio e quantidade. fromPosition = {x = x, y = y, z = z}, --Coordenadas da posição superior esquerda da área. toPosition = {x = x, y = y, z = z}, --Coordenadas da posição inferior direita da área. startTime = 20, --Tempo para iniciar o evento, em segundos. aid = 5901, storages = { global = 9501, players = 9502, storage = 9010, }, teleport = { tpId = xxx, --ID do teleporte. createPos = {x = x, y = y, z = z}, --Onde o teleporte será criado. }, } function addPlayerOnEvent(cid) if isPlayer(cid) then local sto = getGlobalStorageValue(config.storages.players) if type(sto) == "number" then setGlobalStorageValue(config.storages.players, getCreatureName(cid)) else local str = "" sto = sto:explode(",") table.insert(sto, getCreatureName(cid)) for i = 1, #sto do if str == "" then str = sto[i] else str = str..","..sto[i] end end setGlobalStorageValue(config.storages.players, str) end setPlayerStorageValue(cid, config.storages.storage, 1) doTeleportThing(cid, getRandomPositions(config.fromPosition, config.toPosition, 1)[1]) doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, "You entered on the Survival event.") doPlayerSetNoMove(cid, true) broadcastMessage(getCreatureName(cid).." entered on the Survival event. "..#getPlayersOnEvent().." on the event now.") end end function getPlayersOnEvent() local pid = {} local sto = getGlobalStorageValue(config.storages.players) if type(sto) ~= "string" then return false end sto = sto:explode(",") for i = 1, #sto do local cid = getCreatureByName(sto[i]) if isPlayer(cid) then table.insert(pid, cid) end end return #pid > 0 and pid or false end function getRandomPositions(fromPos, toPos, count) count = tonumber(count) or 1 local positions = {} for i = 1, count do table.insert(positions, {x = math.random(fromPos.x, toPos.x), y = math.random(fromPos.y, toPos.y), z = math.random(fromPos.z, toPos.z)}) end return positions end function getPlayersInArea(fromPos, toPos) local players = {} for x = fromPos.x, toPos.x do for y = fromPos.y, toPos.y do for z = fromPos.z, toPos.z do local pos = {x = x, y = y, z = z} if isPlayer(getTopCreature(pos).uid) then table.insert(players, getTopCreature(pos).uid) end end end end return players end function addItem(cid, itemid, count) if isItemStackable(itemid) then doPlayerAddItem(cid, itemid, count) else if count > 1 then for i = 1, count do doPlayerAddItem(cid, itemid, 1) end else doPlayerAddItem(cid, itemid, 1) end end end data/globalevents/scripts: function onTime() if isInArray(config.day, os.date("%A")) then broadcastMessage("The survival event is open! You guys have "..config.time.." minutes to enter.") local item = doCreateItem(config.teleport.tpId, 1, config.teleport.createPos) doItemSetAttribute(item, "aid", config.aid) setGlobalStorageValue(config.storages.global, 1) addEvent(function() if getGlobalStorageValue(config.storages.global) == 1 then local tp = getTileItemById(config.teleport.createPos, config.teleport.tpId).uid if tp > 0 then doRemoveItem(tp) end if #getPlayersOnEvent() < config.playerCount[1] then broadcastMessage("Not enough players to start the survival event. :/") setGlobalStorageValue(config.storages.global, -1) for i = 1, #getPlayersOnEvent() do setPlayerStorageValue(getPlayersOnEvent()[i], config.storages.storage, -1) end db.executeQuery("UPDATE player_storage SET value = -1 WHERE key = "..config.storages.storage.." AND value != -1") else broadcastMessage("The survival event will start in "..config.startTime.." seconds.") addEvent(function() broadcastMessage("The survival event started!!!") setGlobalStorageValue(config.storages.global, 2) for i = 1, #getPlayersOnEvent() do doPlayerSetNoMove(getPlayersOnEvent()[i], false) end end, config.startTime * 1000) end end end, config.time * 60 * 1000) end return true end Tag: <!-- Mude 19:30 para o horário que quer que o evento Survival seja aberto. --> <globalevent name="Survival" time="19:30" event="script" value="nome_do_arquivo.lua"/> data/movements/scripts: function onStepIn(cid, item, position, fromPosition) if not isPlayer(cid) then return true elseif getGlobalStorageValue(config.storages.global) < 1 then return doPlayerSendCancel(cid, "The event isn't open.") and doTeleportThing(cid, fromPosition) elseif getPlayersOnEvent() and #getPlayersOnEvent() >= config.playerCount[2] then return doPlayerSendCancel(cid, "There's already the maximum number of players on the Survival event.") and doTeleportThing(cid, fromPosition) end addPlayerOnEvent(cid) if #getPlayersOnEvent() >= config.playerCount[2] then local tp = getTileItemById(config.teleport.createPos, config.teleport.tpId).uid if tp > 0 then doRemoveItem(tp) end broadcastMessage("The survival event will start in "..config.startTime.." seconds.") setGlobalStorageValue(config.storages.global, 3) addEvent(function() broadcastMessage("The survival event started!!!") setGlobalStorageValue(config.storages.global, 2) for i = 1, #getPlayersOnEvent() do doPlayerSetNoMove(getPlayersOnEvent()[i], false) end end, config.startTime * 1000) end return true end Tag: <movevent type="StepIn" actionid="5901" event="script" value="nome_do_arquivo.lua"/> data/creaturescripts/scripts: function onPrepareDeath(cid) if getGlobalStorageValue(config.storages.global) > -1 and getPlayerStorageValue(cid, config.storages.storage) > -1 then doCreatureAddHealth(cid, getCreatureMaxHealth(cid)) doCreatureAddMana(cid, getCreatureMaxMana(cid)) doTeleportThing(cid, getTownTemplePosition(getPlayerTown(cid))) doPlayerSendTextMessage(cid, 27, "Oh, you died in the survival event. :/") setPlayerStorageValue(cid, config.storages.storage, -1) if #getPlayersInArea(config.fromPosition, config.toPosition) == 1 then local pid = getPlayersInArea(config.fromPosition, config.toPosition)[1] broadcastMessage(getCreatureName(pid).." won the survival event! Congratulations to him!") doCreatureAddHealth(pid, getCreatureMaxHealth(pid)) doCreatureAddMana(pid, getCreatureMaxMana(pid)) doTeleportThing(pid, getTownTemplePosition(getPlayerTown(pid))) doPlayerSendTextMessage(pid, MESSAGE_STATUS_CONSOLE_ORANGE, "You win! Congratulations!\nYour prize: "..config.prize[2].."x "..getItemNameById(config.prize[1])..".") addItem(pid, config.prize[1], config.prize[2]) setPlayerStorageValue(pid, config.storages.storage, -1) setGlobalStorageValue(config.storages.global, -1) end end return true end function onStatsChange(cid, attacker, type, combat, value) if getGlobalStorageValue(config.storages.global) > -1 and getGlobalStorageValue(config.storages.global) ~= 2 and getPlayerStorageValue(cid, config.storages.storage) > -1 then return false end return true end function onLogin(cid) if getPlayerStorageValue(cid, config.storages.storage) > -1 and getGlobalStorageValue(config.storages.global) < 1 then setPlayerStorageValue(cid, config.storages.storage, -1) end registerCreatureEvent(cid, "damageSurvival") registerCreatureEvent(cid, "deathSurvival") return true end function onLogout(cid) if getGlobalStorageValue(config.storages.global) > -1 and getPlayerStorageValue(cid, config.storages.storage) > -1 then return doPlayerSendCancel(cid, "You can't logout on the survival event.") and false end return true end Tags: <event type="preparedeath" name="deathSurvival" event="script" value="nome_do_arquivo.lua"/> <event type="login" name="survivalLogin" event="script" value="nome_do_arquivo.lua"/> <event type="logout" name="survivalLogout" event="script" value="nome_do_arquivo.lua"/> <event type="statschange" name="damageSurvival" event="script" value="nome_do_arquivo.lua"/> Editado Março 6, 2015 10 anos por zipter98 (veja o histórico de edições) não respondo pms solicitando suporte em programação/scripting
Postado Fevereiro 23, 2015 10 anos Depois tenta ajuda no meu topico do Battle x1... Eu já estou fazendo pra ti Mas peço pro zipter fazer tbm... dessa forma comparo o meu com o dele e vejo onde posso melhorar... ...você é muito foda mano. XD Um fato. Editado Fevereiro 23, 2015 10 anos por david0703 (veja o histórico de edições) Atenciosamente, David Araujo Meu Conteúdo Fui útil? Gostou? Faça uma doação. "É errando que se erra." "Gambiarras resolvem instantemente, porém podem complicar em problemas futuros." "Cada dia vivido é um aprendizado."
Postado Fevereiro 26, 2015 10 anos Nessa parte do arquivo creaturescripts addItem(cid, config.prize[1], config.prize[2]) não seria pid? e, no arquivo movements broadcastMessage("The survival event will start in "..config.startTime.." seconds.") e no arquivo globalevents broadcastMessage("The survival event will start in "..config.startTime.." seconds.") não seriam minutos? Editado Fevereiro 26, 2015 10 anos por david0703 (veja o histórico de edições) Atenciosamente, David Araujo Meu Conteúdo Fui útil? Gostou? Faça uma doação. "É errando que se erra." "Gambiarras resolvem instantemente, porém podem complicar em problemas futuros." "Cada dia vivido é um aprendizado."
Postado Fevereiro 26, 2015 10 anos Nessa parte do arquivo creaturescripts não seria pid? e, no arquivo movements e no arquivo globalevents não seriam minutos? Falta de atenção no creaturescript, obrigado por alertar. E, na verdade, são segundos sim. Após entrar a quantidade máxima de jogadores no evento ou se passarem os 5 minutos de espera, os jogadores tem config.startTime segundos para se preparar. Editado Fevereiro 26, 2015 10 anos por zipter98 (veja o histórico de edições) não respondo pms solicitando suporte em programação/scripting
Postado Fevereiro 26, 2015 10 anos ah sim... estou adaptando seu script pra esse TÓPICO. editei uma boa parte, mas não estou com tempo AGORA pra terminar, poderia dar uma olhada? Obrigado. Atenciosamente, David Araujo Meu Conteúdo Fui útil? Gostou? Faça uma doação. "É errando que se erra." "Gambiarras resolvem instantemente, porém podem complicar em problemas futuros." "Cada dia vivido é um aprendizado."
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.