• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Lua [TFS1.4] How can I change the message form of this script. ?

Zarosiano

New Member
Joined
Dec 9, 2022
Messages
21
Reaction score
1
How to make the message when receiving the reward, instead of appearing in the chat, appear on the screen? In orange, highlighted. Because the way it is, the player doesn't even see that he won something, it's only appearing in the chat.
1671574831485.png

code
local table =
{
-- [level] = type = "item", id = {ITEM_ID, QUANTIDADE}, msg = "MENSAGEM"},
-- [level] = type = "bank", id = {QUANTIDADE, 0}, msg = "MENSAGEM"},
-- [level] = type = "addon", id = {ID_ADDON_FEMALE, ID_ADDON_MALE}, msg = "MENSAGEM"},
-- [level] = type = "mount", id = {ID_MOUNT, 0}, msg = "MENSAGEM"},

[20] = {type = "item", id = {2160, 2}, msg = "Voce ganhou 2 crystal coins por alcancar o level 20!"},
[30] = {type = "bank", id = {20000, 0}, msg = "Foi depositado em seu bank 20000 gold coints!"},
[40] = {type = "addon", id = {136, 128}, msg = "Voce ganhou o addon citizen full por alcancar o level 40!"},
[60] = {type = "mount", id = {2, 0}, msg = "Voce ganhou a montaria x!"},
}

local storage = 15000

function onAdvance(player, skill, oldLevel, newLevel)

if skill ~= SKILL_LEVEL or newLevel <= oldLevel then
return true
end

for level, _ in pairs(table) do
if newLevel >= level and player:getStorageValue(storage) < level then
if table[level].type == "item" then
player:addItem(table[level].id[1], table[level].id[2])
elseif table[level].type == "bank" then
player:setBankBalance(player:getBankBalance() + table[level].id[1])
elseif table[level].type == "addon" then
player:addOutfitAddon(table[level].id[1], 3)
player:addOutfitAddon(table[level].id[2], 3)
elseif table[level].type == "mount" then
player:addMount(table[level].id[1])
else
return false
end

player:sendTextMessage(MESSAGE_EVENT_ADVANCE, table[level].msg)
player:setStorageValue(storage, level)
end
end

player:save()

return true
end
 
How to make the message when receiving the reward, instead of appearing in the chat, appear on the screen? In orange, highlighted. Because the way it is, the player doesn't even see that he won something, it's only appearing in the chat.
View attachment 72390

code
Clean code
Lua:
local rewards = {
  -- [level] = {type = "item", id = {ITEM_ID, QUANTITY}, msg = "MESSAGE"},
  -- [level] = {type = "bank", id = {QUANTITY, 0}, msg = "MESSAGE"},
  -- [level] = {type = "addon", id = {ID_ADDON_FEMALE, ID_ADDON_MALE}, msg = "MESSAGE"},
  -- [level] = {type = "mount", id = {ID_MOUNT, 0}, msg = "MESSAGE"},

  [20] = {
    type = "item",
    id = {2160, 2},
    msg = "You have received 2 crystal coins for reaching level 20!"
  },
  [30] = {
    type = "bank",
    id = {20000, 0},
    msg = "20000 gold coints have been deposited in your bank!"
  },
  [40] = {
    type = "addon",
    id = {136, 128},
    msg = "You have received the citizen full addon for reaching level 40!"
  },
  [60] = {
    type = "mount",
    id = {2, 0},
    msg = "You have received mount x!"
  }
}

local storage = 15000

function onAdvance(player, skill, oldLevel, newLevel)
  if skill ~= SKILL_LEVEL or newLevel <= oldLevel then
    return true
  end

  for level, reward in pairs(rewards) do
    if newLevel >= level and player:getStorageValue(storage) < level then
      if reward.type == "item" then
        player:addItem(reward.id[1], reward.id[2])
      elseif reward.type == "bank" then
        player:setBankBalance(player:getBankBalance() + reward.id[1])
      elseif reward.type == "addon" then
        player:addOutfitAddon(reward.id[1], 3)
        player:addOutfitAddon(reward.id[2], 3)
      elseif reward.type == "mount" then
        player:addMount(reward.id[1])
      else
        return false
      end

      -- Display the message on the screen
      local pos = player:getPosition()
      player:say(reward.msg, TALKTYPE_MONSTER_SAY, false, player, {x = pos.x, y = pos.y, z = pos.z})

      player:setStorageValue(storage, level)
    end
  end

  player:save()

  return true
end
 
Back
Top