stoneharry

Untitled

May 15th, 2015
483
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.18 KB | None | 0 0
  1.  
  2. local CHOICE_TABLE = {
  3.     -- TYPES:
  4.     --      1: Spell
  5.     --      2: Item
  6.     -- Each set of values must contain at least 3 unique values
  7.     -- level = { number of types, type1, set of values for type1, ... }
  8.     [2] = {2, 1, {5, 11, 1908}, 2, {50055, 23368, 26029}},
  9.     [3] = {2, 1, {5, 11, 1908}, 2, {50055, 23368, 26029}},
  10.     [4] = {2, 1, {5, 11, 1908}, 2, {50055, 23368, 26029}},
  11.     [5] = {2, 1, {5, 11, 1908}, 2, {50055, 23368, 26029}},
  12.     [6] = {2, 1, {5, 11, 1908}, 2, {50055, 23368, 26029}}
  13.    
  14. }
  15.  
  16. local function PLAYER_EVENT_ON_LEVEL_CHANGE(event, player, oldLevel)
  17.     local t = CHOICE_TABLE[oldLevel + 1]
  18.     if not t then
  19.         return
  20.     end
  21.     local numTypes = t[1];
  22.     local results = {}
  23.     for i=1,3 do
  24.         local _type = math.random(1, t[2])
  25.         local values = t[(_type * 2) + 1]
  26.         while #results ~= i do
  27.             local val = math.random(1, #values)
  28.             results[val] = {_type, val}
  29.         end
  30.     end
  31.    
  32.     local message = "LEVELUP-" .. string.format("%02d", oldLevel + 1)
  33.     for i=1,3 do
  34.         message = message .. "-" ..  string.format("%01d", results[i][1])
  35.         message = message .. "-" ..  string.format("%06d", results[i][2])
  36.     end
  37.    
  38.     sendAddonMessage(player, message, 1)
  39. end
  40.  
  41. RegisterPlayerEvent(13, PLAYER_EVENT_ON_LEVEL_CHANGE)
Advertisement
Add Comment
Please, Sign In to add comment