VictorOtInfinit
Member
- Joined
- Mar 14, 2020
- Messages
- 139
- Solutions
- 3
- Reaction score
- 11
Hi guys, i have this code that i found in the internet but is not working 100%
The boss is spawning, and the timmer is working ( player got kicked before 10m in the room ), but the clear isn't.
I create an item that give a player "Storage 9000", then he can acess the portal and kill the boss, but he only can kill one time and i want him to kill multiple times based on "1 per day boss". If i give another item that give him storage 9000, he can kill again, but only once (again). In my database on phpmyadmin shows that he have the storage 9000 (players_storage table) but seems he lost de storage when he ends the boss(???)
sorry for bad english.
Lua:
local bconfig = {
boss = 'The Old Widow', -- Nome do Boss
storagend = 9000, -- Storage Necessária Para Poder Matar o Boss
bossposition = Position(1442, 1058, 7), -- Onde o Boss Será Criado
destination = Position(1428, 1059, 7), -- Onde o Teleporta de Entrada Ira Levar
exitposition = Position(1304, 1051, 7), -- Onde o Teleporte de Saida ou Kick ira levar
areacenter = Position(1436, 1059, 7), -- O Centro do Lugar onde o Boss Será Criado
areascan = { -- Largura e Altura minima da Área Onde o Boss Será Criado
minx = 8,
maxx = 17,
miny = 6,
maxy = 13
},
timekill = 10, -- Tempo que o Jogador Terá Para Matar o Boss
timeopen = 1, -- Tempo Para o Boss ficar acessivel Novamente Desde a Abertura
aidenter = 65535, -- Action Id do Tile de Entrada
aidexit = 65534, -- Action Id do Tile de Saida
enterpos = DIRECTION_EAST ,-- Direção do Player Quando Entrar na Sala do Boss
exitpos = DIRECTION_EAST -- Direção do Player Quando Sair da Sala do Boss
}
function onStepIn(creature, item, position, fromPosition)
local player = creature:getPlayer()
if not player then
player:sendTextMessage(MESSAGE_STATUS_WARNING, 'Nao e um jogador')
return true
end
if item.actionid == bconfig.aidenter then
local secs = getGlobalStorageValue(50737)
if player:getStorageValue(bconfig.storagend) == -1 then
player:sendTextMessage(MESSAGE_STATUS_WARNING, 'Você não pode entrar no boss agora.')
player:teleportTo(fromPosition, true)
fromPosition:sendMagicEffect(CONST_ME_TELEPORT)
return true
end
if secs < os.time() then
local boss = Game.createMonster(bconfig.boss, bconfig.bossposition)
setGlobalStorageValue(50737, os.time() + (60 * bconfig.timeopen))
player:teleportTo(bconfig.destination)
player:setDirection(bconfig.enterpos)
position:sendMagicEffect(CONST_ME_TELEPORT)
bconfig.destination:sendMagicEffect(CONST_ME_TELEPORT)
player:sendTextMessage(MESSAGE_STATUS_WARNING, 'Você tem que esperar ' .. bconfig.timekill .. ' minutos para matar o boss novamente')
addEvent(function()
local spectators = Game.getSpectators(bconfig.areacenter, false, false, bconfig.areascan.minx, bconfig.areascan.maxx, bconfig.areascan.miny, bconfig.areascan.maxy)
for i = 1, #spectators, 1 do
if spectators[i]:isMonster() then
spectators[i]:remove()
elseif spectators[i]:isPlayer() then
exitPlayer(player)
player:sendTextMessage(MESSAGE_STATUS_WARNING, 'Acabou o tempo.')
end
end
end, (60 * 1000) * bconfig.timekill)
else
local remain = secs - os.time()
local minutes = string.format("%d", math.floor(remain/60))
local seconds = string.format("%d", remain-(math.floor(remain/60)*60))
player:teleportTo(fromPosition, true)
fromPosition:sendMagicEffect(CONST_ME_TELEPORT)
player:sendTextMessage(MESSAGE_STATUS_WARNING, 'O portal vai estar disponivel novamente em ' .. minutes .. ' minuto(s) e ' .. seconds .. ' segundo(s).')
end
elseif item.actionid == bconfig.aidexit then
exitPlayer(player)
end
return true
end
function exitPlayer(player)
player:setStorageValue(bconfig.storagend, -1)
player:teleportTo(bconfig.exitposition)
player:setDirection(bconfig.exitpos)
bconfig.exitposition:sendMagicEffect(CONST_ME_TELEPORT)
end
The boss is spawning, and the timmer is working ( player got kicked before 10m in the room ), but the clear isn't.
I create an item that give a player "Storage 9000", then he can acess the portal and kill the boss, but he only can kill one time and i want him to kill multiple times based on "1 per day boss". If i give another item that give him storage 9000, he can kill again, but only once (again). In my database on phpmyadmin shows that he have the storage 9000 (players_storage table) but seems he lost de storage when he ends the boss(???)
sorry for bad english.