Itutorial
Legendary OT User
- Joined
- Dec 23, 2014
- Messages
- 2,332
- Solutions
- 68
- Reaction score
- 1,009
I have never run into this problem before. Here is whats going on.
The codes:
The codes:
Lua:
local stats = {
[1] = {id = 0x01, name = 'Health'},
[2] = {id = 0x02, name = 'Health Regen'},
[3] = {id = 0x03, name = 'Mana'},
[4] = {id = 0x04, name = 'Mana Regen'},
[5] = {id = 0x05, name = 'Physical Damage'},
[6] = {id = 0x06, name = 'Magic Damage'},
[7] = {id = 0x07, name = 'Healing'},
[8] = {id = 0x08, name = 'Physical Defense'},
[9] = {id = 0x09, name = 'Magic Defense'}
}
function onSay(player, words, param)
window = ModalWindow(6, 'Stat Point Shop', 'You have '..player:getStatPoints()..' stat points to spend')
for i = 1, #stats do
window:addChoice(stats[i].id, stats[i].name)
end
window:addButton(1, 'Buy')
window:setDefaultEnterButton(1)
window:addButton(2, 'Close')
window:setDefaultEscapeButton(2)
window:sendToPlayer(player)
return false
end
Lua:
function onModalWindow(player, modalWindowId, choiceId, buttonId)
if modalWindowId ~= 6 then return true end
if buttonId ~= 1 then return true end
if player:getStatPoints() < 1 then
return player:sendCancelMessage("You do not have any stat points to spend.")
end
if choiceId == 0x01 then
player:addExtraHealth(1)
player:setMaxHealth(player:getMaxHealth() + 5)
player:addStatPoints(-1)
player:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, "You have increased your health by 5. One stat point has been used.")
end
if choiceId == 0x02 then
player:addHealthRegen(1)
player:addStatPoints(-1)
player:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, "You have increased your health regeneration by 2. One stat point has been used.")
end
if choiceId == 0x03 then
player:addExtraMana(1)
player:setMaxMana(player:getMaxMana() + 5)
player:addStatPoints(-1)
player:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, "You have increased your mana by 5. One stat point has been used.")
end
if choiceId == 0x04 then
player:addManaRegen(1)
player:addStatPoints(-1)
player:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, "You have increased your mana regeneration by 2. One stat point has been used.")
end
if choiceId == 0x05 then
player:addExtraDamage(1)
player:addStatPoints(-1)
player:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, "You have increased your physical damage. One stat point has been used.")
end
if choiceId == 0x06 then
player:addExtraMagicDamage(1)
player:addStatPoints(-1)
player:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, "You have increased your magic damage. One stat point has been used.")
end
if choiceId == 0x07 then
player:addExtraHealing(1)
player:addStatPoints(-1)
player:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, "You have increased your healing. One stat point has been used.")
end
if choiceId == 0x08 then
player:addPhysicalDefense(1)
player:addStatPoints(-1)
player:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, "You have increased your physical defense. One stat point has been used.")
end
if choiceId == 0x09 then
player:addMagicDefense(1)
player:addStatPoints(-1)
player:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, "You have increased your magic defense. One stat point has been used.")
end
return true
end