MaXwEllDeN

Egg System

Jun 7th, 2012
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.21 KB | None | 0 0
  1. --[[
  2.     EGG System
  3.     Author: MaXwEllDeN
  4.     Version: 1.0
  5. ]]
  6.  
  7. EGG_LIB = {
  8.       func = {},
  9.       Eggs = {
  10.            [2147] = {Time = 1, imo = 2328, Pokes = {{na = "Pikachu", health = 1500}}}            
  11.       },
  12.  
  13.       enid = 1993,
  14.       maxpokes = 1,
  15. }
  16.                
  17. function getGenderPrefix(str)
  18.    return (str:sub(#str, #str) == "a") and "a" or ""      
  19. end
  20.  
  21. function getItemsInContainer(container) -- Function By Kydrai
  22.    local items = {}
  23.    if isContainer(container) and getContainerSize(container) > 0 then
  24.       for slot=0, (getContainerSize(container)-1) do
  25.          local item = getContainerItem(container, slot)
  26.          if isContainer(item.uid) then
  27.             local itemsbag = getItemsInContainerById(item.uid)
  28.             for i=0, #itemsbag do
  29.                table.insert(items, itemsbag[i])
  30.             end
  31.          else
  32.             table.insert(items, item)
  33.          end
  34.       end  
  35.    end
  36.    
  37.    return items
  38. end
  39.  
  40. function printTableSI(aff) -- BETA ~ By MaXwEllDeN
  41.     local s = "{"
  42.     for a, b in pairs(aff) do
  43.         local index = "[".. a .. "]"
  44.         if (type(a) == "string") then
  45.            index = '["'.. a ..'"]'
  46.         end
  47.         if (type(b) == "table") then
  48.            value = printTableSI(b)
  49.         elseif (type(b) == "string") then    
  50.            value = '"'.. b .. '"'
  51.         else
  52.            value = b
  53.         end
  54.         s = s .. index .. " = " .. value .. ", "        
  55.     end
  56.     s = "{" .. s:sub(2, #s)
  57.     return (#s < 3) and "{}" or (s:sub(1, #s-2) .. "}")
  58. end
  59.  
  60. EGG_LIB.func.getEggs = function (player)
  61.    if (getPlayerStorageValue(player, 72777) == -1) then
  62.       setPlayerStorageValue(player, 72777, "{}")
  63.    end              
  64.    local pass = loadstring("return ".. getPlayerStorageValue(player, 72777))()
  65.  
  66.    return pass
  67. end
  68.  
  69. EGG_LIB.func.removeEgg = function (player, enc)
  70.    local Eggs = EGG_LIB.func.getEggs(player)
  71.    table.remove(Eggs, enc)                  
  72.    return setPlayerStorageValue(player, 72777, printTableSI(Eggs))
  73. end
  74.  
  75. EGG_LIB.func.addEgg = function (player, newegg)
  76.    local Eggs = EGG_LIB.func.getEggs(player)
  77.    table.insert(Eggs, newegg)
  78.    return setPlayerStorageValue(player, 72777, printTableSI(Eggs))
  79. end
Advertisement
Add Comment
Please, Sign In to add comment