From 85786efbd32f99db08e0abaff3edc452bd5539ed Mon Sep 17 00:00:00 2001 From: Kamil Date: Mon, 9 Jul 2012 08:59:16 +0200 Subject: [PATCH] Fixed bug with adding Vip from console or map, who is already on viplist. --- modules/game/player.lua | 7 +++++++ modules/game_console/console.lua | 4 +++- modules/game_interface/gameinterface.lua | 4 +++- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/modules/game/player.lua b/modules/game/player.lua index 715729a5..8043d336 100644 --- a/modules/game/player.lua +++ b/modules/game/player.lua @@ -31,3 +31,10 @@ function Player:isPartySharedExperienceActive() shield == ShieldBlueNoSharedExpBlink or shield == ShieldBlueNoSharedExp) end + +function Player:hasVip(creatureName) + for id, vip in pairs(g_game.getVips()) do + if (vip[1] == creatureName) then return true end + end + return false +end diff --git a/modules/game_console/console.lua b/modules/game_console/console.lua index f2cb0785..f4acfb75 100644 --- a/modules/game_console/console.lua +++ b/modules/game_console/console.lua @@ -403,7 +403,9 @@ function Console.popupMenu(mousePos, mouseButton, creatureName, text) if creatureName then if creatureName ~= g_game.getCharacterName() then menu:addOption(tr('Message to ' .. creatureName), function () g_game.openPrivateChannel(creatureName) end) - menu:addOption(tr('Add to VIP list'), function () g_game.addVip(creatureName) end) --TODO not show if creature already in vip + if (not Player:hasVip(creatureName)) then + menu:addOption(tr('Add to VIP list'), function () g_game.addVip(creatureName) end) + end -- TODO ignore creatureName menu:addSeparator() end diff --git a/modules/game_interface/gameinterface.lua b/modules/game_interface/gameinterface.lua index 13a1c402..92f2e28d 100644 --- a/modules/game_interface/gameinterface.lua +++ b/modules/game_interface/gameinterface.lua @@ -263,7 +263,9 @@ function GameInterface.createThingMenu(menuPosition, lookThing, useThing, creatu menu:addOption(tr('Invite to private chat'), function() g_game.inviteToOwnChannel(creatureName) end) menu:addOption(tr('Exclude from private chat'), function() g_game.excludeFromOwnChannel(creatureName) end) -- [TODO] must be removed after message's popup labels been implemented end - menu:addOption(tr('Add to VIP list'), function() g_game.addVip(creatureName) end) + if (not Player:hasVip(creatureName)) then + menu:addOption(tr('Add to VIP list'), function() g_game.addVip(creatureName) end) + end local localPlayerShield = localPlayer:asCreature():getShield() local creatureShield = creatureThing:getShield()