nanduzenho
Member
Good morning, I'm having a problem again in this script where when a prize runs out the char goes back to the temple. It turns out that when I create a new char, either in rook or in main (in other cities) the char always starts in the temple where the script is programmed with the warning that the premium ended. And when the character in rook finishes the premium he goes to main. Can someone fix this for me?
Lua:
local premiumResetStorage = 45055
local TOWN_ID = 2
function onLogin(cid)
local player = Player(cid)
local resultId = db.storeQuery("SELECT `premdays` FROM `accounts` WHERE `id` = " .. player:getAccountId())
local premDays = false
if resultId ~= false then
premDays = result.getNumber(resultId, "premdays")
result.free(resultId)
end
-- no premium
if premDays and premDays < 1 then
-- if player's town has not been reset
if player:getStorageValue(premiumResetStorage) ~= 1 then
local town = Town(TOWN_ID)
player:setTown(town)
local templePosition = town:getTemplePosition()
player:teleportTo(templePosition)
templePosition:sendMagicEffect(CONST_ME_TELEPORT)
player:setStorageValue(premiumResetStorage, 1)
player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Sua premium acabou!")
end
-- has premium
elseif premDays and premDays > 0 then
if player:getStorageValue(premiumResetStorage) ~= -1 then
player:setStorageValue(premiumResetStorage, -1)
end
end
return true
end
Last edited: