• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

CreatureEvent Party Loot Share

tetra20

DD
Joined
Jan 17, 2009
Messages
1,315
Solutions
4
Reaction score
323
Location
Egypt
Credits:
@cbrm For The Function Part
@tetra20 for Editing it

  • Hello :) i wanted to release my latest script.Party Loot Share
  • I Will Start By The ScreenShots
  • It Should Work With
  • 0.3.7:Tested And Working
  • 0.3.6:Tested And Working
  • 0.4:Tested And Working
  • 1.0:Not Really Tested But Should Work Good Here


21dg5ed.jpg

This Is The Killer Player
9F4Vyo.png


The Player In Party

SgszWD.png


21dg5ed.jpg

  • Create A New .lua name it killcreature.lua
  • Add This:
Code:
math.randomseed(os.time())
local maxdis = 40
function autoloot(cid, target, pos)
    if not isPlayer(cid) then
        return
    end
    local function scanContainer(cid, uid)
        local added = 0
        local members = getPartyMembers(cid)
        for k = (getContainerSize(uid) - 1), 0, -1 do
            local tmp = getContainerItem(uid, k)
            local stack = 0
            local winner = getPartyMembers(getPartyLeader(cid))[math.random(1, table.maxn(getPartyMembers(getPartyLeader(cid))))]
            if getDistanceBetween(getCreaturePosition(cid), getCreaturePosition(winner)) <= maxdis then
                if (isInArray({2148,2152, 2160}, tmp.itemid)) then
                        local money = (tmp.itemid == 2160) and (tmp.type*10000) or (tmp.itemid == 2152) and (tmp.type*100) or tmp.type
                        added = added + money
                        for a = 1,#members do
                            doPlayerAddMoney(members[a], math.floor((money/table.maxn(members))))
                            doPlayerSendTextMessage(members[a], MESSAGE_STATUS_CONSOLE_BLUE, '[Loot System] ' .. math.floor(((added/table.maxn(members)))) .. ' Gold Coin Has Been Added to Your Backpack')
                        end
                elseif isItemStackable(tmp.itemid) then
                    stack = tmp.type
                        for i = 1,#members do
                            doPlayerAddItem(members[i], tmp.itemid,math.floor(stack/table.maxn(members))+1)
                            if doPlayerSendTextMessage(members[i], MESSAGE_STATUS_CONSOLE_BLUE, "[Loot System] " .. math.floor(((stack/table.maxn(members))))+1 .. "x " .. getItemNameById(tmp.itemid) .. " Has Been Added to Your Backpack") then
                            end
                        end
                elseif isContainer(tmp.uid) then
                 scanContainer(cid, tmp.uid)
                else
                    if tmp.type == 0 and not (isInArray({2148, 2152, 2160}, tmp.itemid)) then
                    doPlayerAddItem(winner, tmp.itemid,tmp.type)
                    doPlayerSendTextMessage(winner, MESSAGE_STATUS_CONSOLE_BLUE, "[Loot System] You've won: " .. tmp.type+1 .. "x " .. getItemNameById(tmp.itemid) .. ".")
                    else
                    doPlayerAddItem(winner, tmp.itemid,tmp.type)
                    doPlayerSendTextMessage(winner, MESSAGE_STATUS_CONSOLE_BLUE, "[Loot System] You've won: " .. tmp.type .. "x " .. getItemNameById(tmp.itemid) .. ".")
                    end
                end
            end
            doRemoveItem(tmp.uid)
        end
        return true
    end
    local items = {}
    for i = getTileInfo(pos).items, 1, -1 do
        pos.stackpos = i
        items[i] = getThingFromPos(pos)
    end
    if (#items == 0) then
        return
    end
    local corpse = -1
    for _, item in pairs(items) do
        if not isCreature(item.uid) then
            local name = getItemName(item.uid):lower()
            if name:find(target:lower()) then
                corpse = item.uid
                break
            end
        end
  end
if (corpse ~= -1) and isContainer(corpse) and (getItemAttribute(corpse, "corpseowner") == cid) then
  scanContainer(cid, corpse)
end
end
function onKill(cid, target, lastHit)
        local members = getPartyMembers(cid)
        if isMonster(target) and (isInParty(cid)) and getPlayerStorageValue(members[2], 23305) == 1 then
            addEvent(autoloot, 100, cid, getCreatureName(target), getCreaturePosition(target))
        end
    return true
end
  • In Creaturescripts.xml Add This
Code:
<event type="kill" name="killcreature" event="script" value="killcreature.lua"/>
  • Now In Login.lua Add This
Code:
registerCreatureEvent(cid, "killcreature")
  • Now Open The Talkactions.xml
  • Add This:
Code:
<talkaction words="!loot" event="script" value="lootshare.lua"/>
  • Create A New lootshare.lua in talkaction
  • Add This:
Code:
local stor = 23305

function onSay(cid, words, param, channel)
local party = getPartyMembers(cid)
   if isInParty(cid) then
     if party[2] == cid then
     doCreatureSetStorage(party[2], stor, (getCreatureStorage(party[2], stor) == -1) and 1 or -1)
     doPlayerSendTextMessage(party[2], MESSAGE_STATUS_CONSOLE_BLUE, 'Party Item Share has been ' .. (getCreatureStorage(party[2], stor) == -1 and 'disabled' or 'enabled') .. '.')
     else
     doPlayerSendCancel(cid, "You Aren't The Leader of Party")
     doSendMagicEffect(getThingPos(cid), CONST_ME_POFF)
     end
   else
     doPlayerSendCancel(cid, "You Aren't In Party")
     doSendMagicEffect(getThingPos(cid), CONST_ME_POFF)
   end
  return true
end
  • How To Use:
Code:
!loot
The Script Mistakes:
Code:
1-This Script Won't Work With Random Item Stats.it will just give the item with normal stats
  • The Script Was Tabbed but it got screwed up due to the code Tags
 
Last edited:
Looks great! I hope it works (or works after modifications) for TFS 1.0.
I will give it a shot when I get home.

Kind Regards,
Eldin.
 
for tfs 1.0 it will just need few edits.i will post it at night
 
ye it should work for tfs --0.4--,--0.3.7--,--0.3.6--
--Edit--
Test it and send me the result
 
Tester your script no errors while running up but If you say !loot and you are not in a party you get 10 gold coins every time lol so sucks you get rich when you make bot doing this :/


@tetra20
 
i know that this was a test
remove this
Code:
    doPlayerAddMoney(cid, 10)
in Talkactions.xml

The doPlayerAddMoney Script was bugged in my ot because doPlayerAddMoney(cid, 1) add nothing
doPlayerAddMoney(cid, 10) gives 1 gp
 
Will check right now

@tetra20 Works perfectly. Sorry it took me a while was testing some other stuff out. It works perfectly though! Good job +

EDIT: just poiting out if there is a "always" drop like Dragon Claw from demodras for example, it will put the item in a random party members BP so for boss fights it will be on luck haha
 
Last edited:
Close to finish it for 1.0? :)
Also, the script splits the stackables etc and not copy them and give the double?
Then the person who "got the kill" gets the "single" (nonstackable) items?

Kind Regards,
Eldin.
 
Close to finish it for 1.0? :)
Also, the script splits the stackables etc and not copy them and give the double?
Then the person who "got the kill" gets the "single" (nonstackable) items?

Kind Regards,
Eldin.
for tfs 1.0 it will take me a while since i can't test it so give me a minute gonna try now
For the Stackable.if you looted 3 worm.and there is 2 party members each one will get 2 worm

if you looted 13 ham and there is 5 members = 13/5 = 2.6 after math.floor = 3 + 1 = 4
each member will get 4 hams.you will ask me why i added +1.because you might loot 1x ham it will tell you. you got 0x ham Rofl
 
What can I see? Looking forward too it. ;)
Thank You for the explanation, will for sure use it on all my servers if it'll work.

Kind Regards,
Eldin.
 
Code:
math.randomseed(os.time())
local maxdis = 40
function autoloot(cid, target, pos)
local player = Player(cid)
local party = player:getParty()
if not isPlayer(cid) then
return
end
local function scanContainer(cid, uid)
local added = 0
local members = getPartyMembers(cid)
for k = (getContainerSize(uid) - 1), 0, -1 do
local tmp = getContainerItem(uid, k)
local stack = 0
local winner = party:getMembers()
if (isInArray({2148,2152, 2160}, tmp.itemid)) then
local money = (tmp.itemid == 2160) and (tmp.type*10000) or (tmp.itemid == 2152) and (tmp.type*100) or tmp.type
added = added + money
for a = 1,#members do
doPlayerAddMoney(members[a], math.floor((money/party:getMemberCount())))
doPlayerSendTextMessage(members[a], MESSAGE_STATUS_CONSOLE_BLUE, '[Loot System] ' .. math.floor(((added/table.maxn(members)))) .. ' Gold Coin Has Been Added to Your Backpack')
end
elseif isItemStackable(tmp.itemid) then
stack = tmp.type
for i = 1,#members do
doPlayerAddItem(members[i], tmp.itemid,math.floor(stack/party:getMemberCount())+1)
if doPlayerSendTextMessage(members[i], MESSAGE_STATUS_CONSOLE_BLUE, "[Loot System] " .. math.floor(((stack/table.maxn(members))))+1 .. "x " .. getItemNameById(tmp.itemid) .. " Has Been Added to Your Backpack") then
end
end
elseif isContainer(tmp.uid) then
scanContainer(cid, tmp.uid)
else
if tmp.type == 0 and not (isInArray({2148, 2152, 2160}, tmp.itemid)) then
doPlayerAddItem(winner[math.random(1,#winner)], tmp.itemid,tmp.type)
doPlayerSendTextMessage(winner[math.random(1,#winner)], MESSAGE_STATUS_CONSOLE_BLUE, "[Loot System] You've won: " .. tmp.type+1 .. "x " .. getItemNameById(tmp.itemid) .. ".")
else
doPlayerAddItem(winner[math.random(1,#winner)], tmp.itemid,tmp.type)
doPlayerSendTextMessage(winner[math.random(1,#winner)], MESSAGE_STATUS_CONSOLE_BLUE, "[Loot System] You've won: " .. tmp.type .. "x " .. getItemNameById(tmp.itemid) .. ".")
end
end
doRemoveItem(tmp.uid)
end
return true
end
local items = {}
for i = getTileInfo(pos).items, 1, -1 do
pos.stackpos = i
items[i] = getThingFromPos(pos)
end
if (#items == 0) then
return
end
local corpse = -1
for _, item in pairs(items) do
if not isCreature(item.uid) then
local name = getItemName(item.itemid):lower()
if name:find(target:lower()) then
if isCorpse(item.uid) then
corpse = item.uid
break
end
end
end
end
scanContainer(cid, corpse)
end

function onKill(cid, target, lastHit)
local members = getPartyMembers(cid)
local party = Player(cid):getParty()
if isMonster(target) and party and getPlayerStorageValue(members[2], 23305) == 1 then
addEvent(autoloot, 100, cid, getCreatureName(target), getCreaturePosition(target))
end
return true
end

Talkaction
Code:
local stor = 23305

function onSay(cid, words, param, channel)
local party = getPartyMembers(cid)
  if Player(cid):getParty() then
  if party:getLeader() == cid then
  setPlayerStorageValue(party:getLeader(), stor, (getPlayerStorageValue(party:getLeader(), stor) == -1) and 1 or -1)
  doPlayerSendTextMessage(party:getLeader(), MESSAGE_STATUS_CONSOLE_BLUE, 'Party Item Share has been ' .. (getPlayerStorageValue(party:getLeader(), stor) == -1 and 'disabled' or 'enabled') .. '.')
  else
  doPlayerSendCancel(cid, "You Aren't The Leader of Party")
  doSendMagicEffect(getThingPos(cid), CONST_ME_POFF)
  end
  else
  doPlayerSendCancel(cid, "You Aren't In Party")
  doSendMagicEffect(getThingPos(cid), CONST_ME_POFF)
  end
  return true
end
 
Last edited:
Will try ASAP when I get time, already too late. HAVE to sleep so I get up to work tomorrow. ;)
Might get time in the morning!

Keep it up!

Kind Regards,
Eldin.
 
Will try ASAP when I get time, already too late. HAVE to sleep so I get up to work tomorrow. ;)
Might get time in the morning!

Keep it up!

Kind Regards,
Eldin.
Just Try It and Send me the result.i haven't tested it
 
Close to finish it for 1.0? :)
Also, the script splits the stackables etc and not copy them and give the double?
Then the person who "got the kill" gets the "single" (nonstackable) items?

Kind Regards,
Eldin.

i didnt pay attention to who got the "single" loot every time.. its probably random but ill give it a couple tries later. Im working on this other script real quick and ill get to doing that..
no matter what the outcome is, either way its a good script haha, if its random then its fun cause its luck.. and if its party leader then maybe a knight is encouraged for blocking and keeping loot or things like that loll

EDIT: Oops, i meant to quote @tetra20 ... sorry loll but yea, ill test in a few
 
Back
Top