Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function doTakeReward(cid, table)
- if not isPlayer(cid) or (table and not next(table)) then
- return false
- end
- local begin, text = true, ""
- if table.addMessage and table.addMessage ~= "" then
- if begin then
- text = "You received "
- begin = false
- else
- text = text .. ", "
- end
- text = table.addMessage
- end
- local newContainer = nil
- if table.addMoney and table.addMoney > 0 then
- newContainer = doCreateItemEx(ITEM_PARCEL)
- for _, coin in pairs(createMoney(table.addMoney)) do
- doAddContainerItem(newContainer, coin[1], coin[2])
- end
- if not table.addItem then
- doPlayerAddItemEx(cid, newContainer)
- end
- if begin then
- text = "You received "
- begin = false
- else
- text = text .. ", "
- end
- text = text .. getPrice(table.addMoney)
- end
- if table.addItem and #table.addItem > 0 then
- local receivedItem, itemsWorth = 0, 0
- local itemsText = ""
- for k, item in ipairs(table.addItem) do
- if not item.ignoreInfo then
- itemsText = itemsText .. (item.count > 1 and (item.count .. 'x ') or '') .. getItemNameById(item.id)
- if k ~= #table.addItem then
- itemsText = itemsText .. ', '
- end
- end
- end
- if #table.addItem > 1 or (table.addMoney and table.addMoney > 0) then
- if not newContainer then
- newContainer = doCreateItemEx(ITEM_PARCEL)
- end
- for k, item in pairs(table.addItem) do
- doAddContainerItem(newContainer, item.id, item.count)
- end
- itemsText = itemsText .. "(in container"
- if doPlayerAddItemEx(cid, newContainer) ~= RETURNVALUE_NOERROR then
- itemsText = itemsText .. ", sended to depo"
- doPlayerSendMailByName(getPlayerName(cid), newContainer)
- end
- itemsText = itemsText .. ")"
- else
- if table.addItem[1].count > 100 then
- if not newContainer then
- newContainer = doCreateItemEx(ITEM_PARCEL)
- end
- itemsText = itemsText .. "(in container"
- doAddContainerItem(newContainer, table.addItem[1].id, table.addItem[1].count)
- if doPlayerAddItemEx(cid, newContainer) ~= RETURNVALUE_NOERROR then
- itemsText = itemsText .. ", sended to depo"
- doPlayerSendMailByName(getPlayerName(cid), newContainer)
- end
- itemsText = itemsText .. ")"
- else
- local newItem = doCreateItemEx(table.addItem[1].id, table.addItem[1].count)
- if doPlayerAddItemEx(cid, newItem) ~= RETURNVALUE_NOERROR then
- itemsText = itemsText .. "(sended to depo)"
- doPlayerSendMailByName(getPlayerName(cid), newItem)
- end
- end
- end
- if begin then
- text = "You received "
- begin = false
- else
- if not table.addMessage then
- text = text .. ", "
- end
- end
- text = text .. itemsText
- end
- if table.addExperience and table.addExperience ~= 0 or table.addExp and table.addExp ~= 0 then
- doPlayerAddExperience(cid, tonumber(table.addExperience and table.addExperience or table.addExp))
- if begin then
- text = "You received "
- begin = false
- else
- text = text .. ", "
- end
- text = text .. '+' .. (table.addExperience and table.addExperience or table.addExp) .. ' experience'
- end
- if table.addLevel and table.addLevel ~= 0 then
- doPlayerAddLevel(cid, table.addLevel)
- if begin then
- text = "You received "
- begin = false
- else
- text = text .. ", "
- end
- text = text .. '+' .. table.addLevel .. ' level' .. (table.addLevel > 1 and 's' or '')
- end
- if table.addStorage and type(table.addStorage) == 'table' then
- setPlayerStorageValue(cid, table.addStorage[1], table.addStorage[2])
- if table.addStorage[3] then
- if begin then
- text = "You received "
- begin = false
- else
- text = text .. ", "
- end
- text = text .. table.addStorage[3]
- end
- end
- if table.addSpell and table.addSpell ~= "" then
- doPlayerLearnInstantSpell(cid, table.addSpell)
- if begin then
- text = "You received "
- begin = false
- else
- text = text .. ", "
- end
- text = text .. 'learned new spell *' .. table.addSpell .. '*'
- end
- if table.addMaxHealth and table.addMaxHealth ~= 0 then
- setCreatureMaxHealth(cid, getCreatureMaxHealth(cid, true) + table.addMaxHealth)
- if begin then
- text = "You received "
- begin = false
- else
- text = text .. ", "
- end
- text = text .. '+' .. table.addMaxHealth .. ' of maximum health'
- end
- if table.addMaxMana and table.addMaxMana ~= 0 then
- setCreatureMaxMana(cid, getPlayerMaxMana(cid, true) + table.addMaxMana)
- if begin then
- text = "You received "
- begin = false
- else
- text = text .. ", "
- end
- text = text .. '+' .. table.addMaxMana .. ' of maximum ki points'
- end
- if table.addSkill and type(table.addSkill) == 'table' then
- doPlayerAddSkillLevel(cid, table.addSkill[1], table.addSkill[2])
- if begin then
- text = "You received "
- begin = false
- else
- text = text .. ", "
- end
- text = text .. '+' .. table.addSkill[2] .. ' ' .. SKILL_NAMES[table.addSkill[1]]
- end
- if table.teleport and type(table.teleport) == 'table' then
- doTeleportThing(cid, table.teleport[1])
- if begin then
- text = "You received "
- begin = false
- else
- text = text .. ", "
- end
- text = text .. 'get teleported ' .. (table.teleport[2] and 'to ' .. table.teleport[2] or "somewhere")
- end
- if text ~= "" then
- text = text .. "."
- doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, text)
- end
- return true
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement