Advertisement
jdrecarp

First Items (Lua)

Dec 11th, 2015
435
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.65 KB | None | 0 0
  1. local commonItems = {
  2.     {itemid=8707, count=1, useMessage=true}, -- a book (or whatever) with a message
  3.     {itemid=2789, count=10, inContainer = true}, -- 10 brown mushrooms
  4.     {itemid=2152, count=10, inContainer = true}, -- 10 platinum coins
  5.     {itemid=2200, count=100, useSlot=true, slotType=CONST_SLOT_NECKLACE}, -- protection amulet
  6.     {itemid=2643} -- leather boots
  7. }
  8.  
  9. local firstItems = {
  10.     { -- Sorcerer
  11.         {itemid=1988}, -- backpack
  12.         {itemid=2175}, -- spellbook
  13.         {itemid=2190}, -- wand of vortex
  14.         {itemid=8819}, -- magician's robe
  15.         {itemid=8820}, -- mage hat
  16.         {itemid=2468}, -- studded legs
  17.         {itemid=7620, count=3, inContainer=true}, -- mana potion
  18.         {useRunes=true, container=1988, runeId=2268, charges=3}
  19.     },
  20.     { -- Druid
  21.         {itemid=1988}, -- backpack
  22.         {itemid=2175}, -- spellbook
  23.         {itemid=2182}, -- snakebite rod
  24.         {itemid=8819}, -- magician's robe
  25.         {itemid=8820}, -- mage hat
  26.         {itemid=2468}, -- studded legs
  27.         {itemid=7620, count=3, inContainer=true}, -- mana potion
  28.         {useRunes=true, container=1988, runeId=2268, charges=3}
  29.     },
  30.     { -- Paladin
  31.         {itemid=1988}, -- backpack
  32.         {itemid=2456, count=1, useSlot=true, slotType=CONST_SLOT_LEFT}, -- bow
  33.         {itemid=2544, count=100, useSlot=true, slotType=CONST_SLOT_LAST}, -- 100 arrow's
  34.         {itemid=2660}, -- ranger's cloak
  35.         {itemid=2481}, -- soldier helmet
  36.         {itemid=8923}, -- ranger legs
  37.         {itemid=7618, count=1, inContainer=true}, -- health potion
  38.         {itemid=7620, count=2, inContainer=true}, -- mana potion
  39.         {useRunes=false, container=1988, runeId=2268, charges=3}
  40.     },
  41.     { -- Knight
  42.         {itemid=1988}, -- backpack
  43.         {itemid=2509}, -- steel shield
  44.         {itemid=8602}, -- jagged sword
  45.         {itemid=8601, inContainer=true}, -- steel axe
  46.         {itemid=2439, inContainer=true}, -- daramanian mace
  47.         {itemid=2465}, -- brass armor
  48.         {itemid=2481}, -- soldier helmet
  49.         {itemid=2478}, -- brass legs
  50.         {itemid=7618, count=3, inContainer=true}, -- health potion
  51.         {useRunes=false, container=1988, runeId=2268, charges=3}
  52.     }
  53. }
  54.  
  55. function onLogin(cid)
  56.     for _, items in ipairs(firstItems) do
  57.         for _, item in ipairs(commonItems) do
  58.             table.insert(items, item)
  59.         end
  60.     end
  61.    
  62.     if(getPlayerAccess(cid) < 3 and (getPlayerLastLoginSaved(cid) < 1) and firstItems[getPlayerVocation(cid)]) then
  63.         for _, v in ipairs(firstItems[getPlayerVocation(cid)]) do
  64.             if isItemContainer(v.itemid) then
  65.                 backpack = doPlayerAddItem(cid, v.itemid, 1, false)
  66.             elseif v.inContainer then
  67.                 doAddContainerItem(backpack, v.itemid, v.count or 1)
  68.             elseif v.useSlot then
  69.                 local id = doCreateItemEx(v.itemid, v.count or 1)
  70.                 doPlayerAddItemEx(cid, id, false, v.slotType)
  71.             elseif v.useMessage then
  72.                 local t, k = {
  73.                     writer = "Server Staff", date = os.time(),
  74.                     text = "Welcome to " .. getConfigValue('serverName') .. ", " .. getCreatureName(cid) .. ".\n\nIf you need help with anything, please refer to the help channel and our staff will gladly assist you. Please remember to report any errors, bugs, or abuse to the Gamemasters."
  75.                 }, doPlayerAddItem(cid, v.itemid, v.count or 1, false)
  76.                 doSetItemText(k, t.text, t.writer, t.date)
  77.             elseif v.useRunes then
  78.                 local weight = getItemWeightById(v.runeId, tonumber(getItemInfo(v.container).maxItems)) + getItemWeightById(v.container, 1)
  79.                 if(getPlayerFreeCap(cid) >= weight) then
  80.                     local bp = doCreateItemEx(cid, v.container, 1)
  81.                     if(doPlayerAddItemEx(cid, bp) ~= RETURNVALUE_NOERROR) then
  82.                         return false
  83.                     else
  84.                         for i = 1, tonumber(getItemInfo(v.container).maxItems) do
  85.                             doAddContainerItem(bp, v.runeId, v.charges or 1)
  86.                         end
  87.                     end
  88.                 end
  89.             else
  90.                 doPlayerAddItem(cid, v.itemid, v.count or 1)
  91.             end
  92.         end
  93.     end
  94.     return true
  95. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement