Advertisement
Dev_iThorgrim

mod-modrate-xp

Aug 17th, 2019
255
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.36 KB | None | 0 0
  1. --##########################################
  2. --#
  3. --# - Script created by iThorgrim
  4. --#
  5. --# Forum : http://emulophye.fr
  6. --# Discord : https://discord.gg/nsEZtuS
  7. --#
  8. --# Support me : paypal.me/DevRainDash
  9. --#
  10. --##########################################
  11.  
  12. local m_exp = {};
  13.  
  14. local function OnConnect(event, player)
  15.     local pGuid = player:GetGUIDLow()
  16.     if not(m_exp[pGuid])then
  17.         m_exp[pGuid] = {
  18.             mod_exp = 1;
  19.         }
  20.     end
  21.     local GetRateExp = CharDBQuery('SELECT mod_exp FROM ElunaDB.mod_rate_exp WHERE guid = '..pGuid..';')
  22.     if GetRateExp ~= nil then
  23.         m_exp[pGuid].mod_exp = GetRateExp:GetUInt32(0)
  24.     else
  25.         local AddRateExp = CharDBQuery('INSERT INTO ElunaDB.mod_rate_exp (guid, mod_exp) VALUES ('..pGuid..', 1);')
  26.         m_exp[pGuid].mod_exp = 1
  27.     end
  28. end
  29. RegisterPlayerEvent(3, OnConnect)
  30.  
  31. local function OnDisconnect(event, player)
  32.     local pGuid = player:GetGUIDLow()
  33.     if not(m_exp[pGuid])then
  34.         m_exp[pGuid] = {
  35.             mod_exp = 1;
  36.         }
  37.     end
  38.     local SaveRateExp = CharDBQuery('UPDATE ElunaDB.mod_rate_exp SET mod_exp = '..m_exp[pGuid].mod_exp..' WHERE guid = '..pGuid..';')
  39. end
  40. RegisterPlayerEvent(4, OnDisconnect)
  41.  
  42. local function OnReceiveExp(event, player, amount, victim)
  43.     local pGuid = player:GetGUIDLow()
  44.     if not(m_exp[pGuid])then
  45.         m_exp[pGuid] = {
  46.             mod_exp = 1;
  47.         }
  48.     end
  49.  
  50.     return amount * m_exp[pGuid].mod_exp
  51. end
  52. RegisterPlayerEvent(12, OnReceiveExp)
  53.  
  54. local function GetAllPlayerExp(event)
  55.     for i, player in ipairs(GetPlayersInWorld()) do
  56.         OnConnect(event, player)
  57.     end
  58. end
  59. RegisterServerEvent(33, GetAllPlayerExp)
  60.  
  61. local function SaveAllPlayerExp(event)
  62.     for i, player in ipairs(GetPlayersInWorld()) do
  63.         OnDisconnect(event, player)
  64.     end
  65. end
  66. RegisterServerEvent(16, SaveAllPlayerExp)
  67.  
  68. --[[
  69.  
  70. NPC SECTION
  71.  
  72. ]]--
  73.  
  74. local NpcEntry = 45000;
  75. local function OnGossipHello(event, player, object)
  76.     player:GossipClearMenu()
  77.     player:GossipSetText("Bonjour,\n\nJe suis Epoque l'intemporel.\nJe viens de loin pour vous permettre d'accélerer votre avenir.\n\nGrace à moi vous pouvez modifier votre multiplicateur d'experience.\n\n\nÀ vous de choisir :")
  78.     player:GossipMenuAddItem(4, 'Multiplier par 1', 1, 100)
  79.     player:GossipMenuAddItem(4, 'Multiplier par 2', 1, 101)
  80.     player:GossipMenuAddItem(4, 'Multiplier par 3', 1, 102)
  81.  
  82.     player:GossipSendMenu(0x7FFFFFFF, object)
  83. end
  84. RegisterCreatureGossipEvent(NpcEntry, 1, OnGossipHello)
  85.  
  86. local function OnGossipSelect(event, player, object, sender, intid, code, menu_id)
  87.     local pGuid = player:GetGUIDLow()
  88.     if not(m_exp[pGuid])then
  89.         m_exp[pGuid] = {
  90.             mod_exp = 1;
  91.         }
  92.     end
  93.     --
  94.     if intid == 100 then
  95.         m_exp[pGuid].mod_exp = 1;
  96.         player:SendNotification('Votre rate d\'experience est désormais fixés à x1.')
  97.         player:GossipComplete()
  98.     elseif intid == 101 then
  99.         m_exp[pGuid].mod_exp = 2;
  100.         player:SendNotification('Votre rate d\'experience est désormais fixés à x2.')
  101.         player:GossipComplete()
  102.     elseif intid == 102 then
  103.         m_exp[pGuid].mod_exp = 3;
  104.         player:SendNotification('Votre rate d\'experience est désormais fixés à x3.')
  105.         player:GossipComplete()
  106.     end
  107.     OnDisconnect(event, player)
  108. end
  109. RegisterCreatureGossipEvent(NpcEntry, 2, OnGossipSelect)
  110.  
  111. CharDBQuery('CREATE DATABASE IF NOT EXISTS ElunaDB;')
  112. CharDBQuery('CREATE TABLE IF NOT EXISTS `ElunaDB`.`mod_rate_exp` (`guid` int(11) NOT NULL, `mod_exp` int(11) DEFAULT '1', PRIMARY KEY (`guid`)) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement