Advertisement
jdrecarp

First Items w/Runes

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