Alguem poderia me ajudar a implementar uma variavel no premio deste escript?
local centeroffight = {x = 15233, y = 15008, z = 7} local waitingplace = {x = 15210, y = 15023, z = 7} local depotcenter = {x = 15000, y = 15000, z = 7} local MinimumPlayers = 2 local rewardpoints = 1
local function lmsclosed1() broadcastMessage("Last Man Standing event will start in 1 minutes. Portal is opened in depot", MESSAGE_STATUS_WARNING) end
local function lmsclosed()
count = 0 local spectators = getSpectators(waitingplace, 10, 10, false) if spectators ~= nil then for _, spectator in ipairs(spectators) do if isPlayer(spectator) then count = count + 1
end end end
if (count >= MinimumPlayers) then
broadcastMessage("Last Man Standing event portal closed and event started!", MESSAGE_STATUS_WARNING)
for _, pid in ipairs(getOnlinePlayers()) do if getPlayerStorageValue(pid, 25001) == 1 then local playerids = getPlayerByName(pid) doTeleportThing(playerids,centeroffight) doSendMagicEffect(center, CONST_ME_TELEPORT) end
end
else
broadcastMessage("Not enough players to start Last man Standing event! Minimum: "..MinimumPlayers.." players. We have "..count.."!", MESSAGE_STATUS_WARNING) setGlobalStorageValue(25002, 0)
for _, pid in ipairs(getOnlinePlayers()) do if getPlayerStorageValue(pid, 25001) == 1 then local playerids = getPlayerByName(pid) doTeleportThing(playerids,depotcenter) doSendMagicEffect(depotcenter, CONST_ME_TELEPORT) setPlayerStorageValue(pid, 25001, 0)
end end
end
return true end
local function lmscheck()
count = 0 local spectators = getSpectators(centeroffight, 10, 10, false) if spectators ~= nil then for _, spectator in ipairs(spectators) do if isPlayer(spectator) then count = count + 1
end end end
if count == 1 then
for _, pid in ipairs(getOnlinePlayers()) do if getPlayerStorageValue(pid, 25001) == 1 then local playerids = getPlayerByName(pid) setPlayerStorageValue(playerids, 25001, 0) end end
local spectators = getSpectators(centeroffight, 10, 10, false) if spectators ~= nil then for _, spectator in ipairs(spectators) do if isPlayer(spectator) then
doTeleportThing(spectator,depotcenter) doSendMagicEffect(depotcenter, CONST_ME_TELEPORT) broadcastMessage("LMS ended winner is: "..getPlayerName(spectator)..", reward is 1 premium points.", MESSAGE_STATUS_WARNING)
local accid = Player(spectator):getAccountId() local points = rewardpoints db.query("UPDATE `accounts` SET `premium_points` = `premium_points` + " .. points .. " WHERE `id` = " .. accid)
end end end
for _, pid in ipairs(getOnlinePlayers()) do if getPlayerStorageValue(pid, 25001) == 1 then local playerids = getPlayerByName(pid) setPlayerStorageValue(pid, 25001, 0) end end
stopEvent(lmscheck)
else addEvent(lmscheck, 10*1000) end end
local function lms() broadcastMessage("Last Man Standing event will start in 2 minutes. Portal is opened in depot", MESSAGE_STATUS_WARNING)
function onThink(interval) if Game.getPlayerCount() == 0 then return true end
local players = Game.getPlayers() local winner = players[math.random(1, #players)]
local items = {} for itemid, count in pairs(config.rewards) do items[#items + 1] = itemid end
local itemid = items[math.random(1, #items)] local amount = config.rewards[itemid] winner:addItem(itemid, amount)
local it = ItemType(itemid) local name = "" if amount == 1 then name = it:getArticle() .. " " .. it:getName() else name = amount .. " " .. it:getPluralName() end
if config.website then db.query("INSERT INTO `lottery` (`name`, `item`) VALUES (\"".. db.escapeString(winner:getName()) .."\", \"".. db.escapeString(it:getName()) .."\");") end return true end
Pergunta
surfnament 1
Olha eu aqui de novo
Alguem poderia me ajudar a implementar uma variavel no premio deste escript?
local centeroffight = {x = 15233, y = 15008, z = 7}
local waitingplace = {x = 15210, y = 15023, z = 7}
local depotcenter = {x = 15000, y = 15000, z = 7}
local MinimumPlayers = 2
local rewardpoints = 1
local function lmsclosed1()
broadcastMessage("Last Man Standing event will start in 1 minutes. Portal is opened in depot", MESSAGE_STATUS_WARNING)
end
local function lmsclosed()
count = 0
local spectators = getSpectators(waitingplace, 10, 10, false)
if spectators ~= nil then
for _, spectator in ipairs(spectators) do
if isPlayer(spectator) then
count = count + 1
end
end
end
if (count >= MinimumPlayers) then
broadcastMessage("Last Man Standing event portal closed and event started!", MESSAGE_STATUS_WARNING)
for _, pid in ipairs(getOnlinePlayers()) do
if getPlayerStorageValue(pid, 25001) == 1 then
local playerids = getPlayerByName(pid)
doTeleportThing(playerids,centeroffight)
doSendMagicEffect(center, CONST_ME_TELEPORT)
end
end
else
broadcastMessage("Not enough players to start Last man Standing event! Minimum: "..MinimumPlayers.." players. We have "..count.."!", MESSAGE_STATUS_WARNING)
setGlobalStorageValue(25002, 0)
for _, pid in ipairs(getOnlinePlayers()) do
if getPlayerStorageValue(pid, 25001) == 1 then
local playerids = getPlayerByName(pid)
doTeleportThing(playerids,depotcenter)
doSendMagicEffect(depotcenter, CONST_ME_TELEPORT)
setPlayerStorageValue(pid, 25001, 0)
end
end
end
return true
end
local function lmscheck()
count = 0
local spectators = getSpectators(centeroffight, 10, 10, false)
if spectators ~= nil then
for _, spectator in ipairs(spectators) do
if isPlayer(spectator) then
count = count + 1
end
end
end
if count == 1 then
for _, pid in ipairs(getOnlinePlayers()) do
if getPlayerStorageValue(pid, 25001) == 1 then
local playerids = getPlayerByName(pid)
setPlayerStorageValue(playerids, 25001, 0)
end
end
local spectators = getSpectators(centeroffight, 10, 10, false)
if spectators ~= nil then
for _, spectator in ipairs(spectators) do
if isPlayer(spectator) then
doTeleportThing(spectator,depotcenter)
doSendMagicEffect(depotcenter, CONST_ME_TELEPORT)
broadcastMessage("LMS ended winner is: "..getPlayerName(spectator)..", reward is 1 premium points.", MESSAGE_STATUS_WARNING)
local accid = Player(spectator):getAccountId()
local points = rewardpoints
db.query("UPDATE `accounts` SET `premium_points` = `premium_points` + " .. points .. " WHERE `id` = " .. accid)
end
end
end
for _, pid in ipairs(getOnlinePlayers()) do
if getPlayerStorageValue(pid, 25001) == 1 then
local playerids = getPlayerByName(pid)
setPlayerStorageValue(pid, 25001, 0)
end
end
stopEvent(lmscheck)
else
addEvent(lmscheck, 10*1000)
end
end
local function lms()
broadcastMessage("Last Man Standing event will start in 2 minutes. Portal is opened in depot", MESSAGE_STATUS_WARNING)
portalwhere = {x= 14996, y=14999, z=7} local portal = doCreateItem(11796,1,portalwhere)
doSetItemActionId(portal, 25001)
doSendMagicEffect(portalwhere, CONST_ME_TELEPORT)
iteminfo = {x= 14995, y=14999, z=7}
local item = doCreateItem(1431,1,iteminfo)
doSetItemActionId(item, 25002)
doSendMagicEffect(iteminfo, CONST_ME_TELEPORT)
addEvent(function() doRemoveItem(getTileItemById(portalwhere, 11796).uid) end, 120 * 1000)
addEvent(function() doSendMagicEffect(portalwhere, CONST_ME_TELEPORT) end, 120 * 1000)
addEvent(function() doRemoveItem(getTileItemById(iteminfo, 1431).uid) end, 120 * 1000)
addEvent(function() doSendMagicEffect(iteminfo, CONST_ME_TELEPORT) end, 120 * 1000)
addEvent(lmsclosed, 2*60*1000)
addEvent(lmsclosed1, 1*60*1000)
addEvent(lmscheck, 130*1000)
return true
end
function onThink(interval)
broadcastMessage("Last Man Standing event will start in 3 minutes.", MESSAGE_STATUS_WARNING)
addEvent(lms, 60*1000)
return true
end
Eu queria que ao inves de dar premium points , de um item randomico...
Esta pode ser uma boa base:
local config = {
interval = "3 hours",
rewards = {[13295] = 1, [13536] = 1, [13537] = 1, [13294] = 1, [13535] = 1, [13539] = 1, [18448] = 1, [13293] = 1, [12398] = 1, [13247] = 1, [13498] = 1, [13538] = 1, [13508] = 1, [13292] = 1, [13291] = 1, [13938] = 1, [23550] = 1, [13939] = 2, [20138] = 1, [13307] = 1},
-- [itemid] = count; [2160] = 50 - it gives 50 crystal coins
website = true
}
function onThink(interval)
if Game.getPlayerCount() == 0 then
return true
end
local players = Game.getPlayers()
local winner = players[math.random(1, #players)]
local items = {}
for itemid, count in pairs(config.rewards) do
items[#items + 1] = itemid
end
local itemid = items[math.random(1, #items)]
local amount = config.rewards[itemid]
winner:addItem(itemid, amount)
local it = ItemType(itemid)
local name = ""
if amount == 1 then
name = it:getArticle() .. " " .. it:getName()
else
name = amount .. " " .. it:getPluralName()
end
broadcastMessage("[LOTERIA] " .. winner:getName() .. " ganhou " .. name .. "! Parabéns! (Próxima loteria em " .. config.interval .. ")")
if config.website then
db.query("INSERT INTO `lottery` (`name`, `item`) VALUES (\"".. db.escapeString(winner:getName()) .."\", \"".. db.escapeString(it:getName()) .."\");")
end
return true
end
Link para o comentário
Compartilhar em outros sites
7 respostass a esta questão
Posts Recomendados