• 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!

Everyone will get a random item after kill

BugaS

Donżuan
Joined
Mar 12, 2009
Messages
1,219
Reaction score
9
Location
NYC
Hey guys!

I'm looking for a script which is working like this:

There is a monster with name: Rat, everyone who hit the monster after his death get a reward automaticly to backpack (do not need to open corpse, or if it is impossible that they must open it). TFS 0.4

@Xeraphus
 
Last edited:
Solution
add this in ur lib/050-function

Code:
function isSummon(cid)
return getCreatureMaster(cid) ~= nil
end

and yes all player attack will get reward
this script will give items to all player attack monster everytime they kill monster

Code:
local config = {
     ['demon'] = {amount = 1, storage = 190700}, ----- write name of monster and any empty storage
     ['dragon'] = {amount = 1, storage = 19001}  ---- same here
}
local Reward_boss = {2280,2278,2263,2275,2646,2272,2160}  -- put here id of most items to be won
function onKill(cid, target)
     local monster = config[getCreatureName(target):lower()]
     if isPlayer(target) or not monster or isSummon(target) then
         return true
     end
      local Reward = Reward_boss[math.random(1, #Reward_boss)]
     if (getPlayerStorageValue(cid, monster.storage)+1) < monster.amount then
         setPlayerStorageValue(cid, monster.storage, getPlayerStorageValue(cid, monster.storage) + 1)
     end
     if (getPlayerStorageValue(cid, monster.storage)+1) == monster.amount then
         doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, 'Congratulations, you have killed '..getCreatureName(target)..' and received '..getItemNameById(Reward)..'.')
         doPlayerAddItem(cid, Reward,1)
     end
     return true
end

this script will give items to all player attack monster but one time only

Code:
local config = {
     ['demon'] = {amount = 1, storage = 190700}, ----- write name of monster and any empty storage
     ['dragon'] = {amount = 1, storage = 19001}  ---- same here
}
local Reward_boss = {2280,2278,2263,2275,2646,2272,2160}  -- put here id of most items to be won
function onKill(cid, target)
     local monster = config[getCreatureName(target):lower()]
     if isPlayer(target) or not monster or isSummon(target) then
         return true
     end
      local Reward = Reward_boss[math.random(1, #Reward_boss)]
     if (getPlayerStorageValue(cid, monster.storage)+1) < monster.amount then
         setPlayerStorageValue(cid, monster.storage, getPlayerStorageValue(cid, monster.storage) + 1)
     end
     if (getPlayerStorageValue(cid, monster.storage)+1) == monster.amount then
         doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, 'Congratulations, you have killed '..getCreatureName(target)..' and received '..getItemNameById(Reward)..'.')
         doPlayerAddItem(cid, Reward,1)
        setPlayerStorageValue(cid, monster.storage, getPlayerStorageValue(cid, monster.storage) + 1)
     end
     return true
end

if u need add outfit to this {when player kill this monster get outfit } u can add somthing like this
['demon'] = {amount = 1, storage = 190700, outfit = {10, 2}},

and above doPlayerAddItem(cid, Reward,1) add doPlayerAddOutfitId(cid, monster.outfit[1], monster.outfit[2])


if u need all player get same items when kill monster use this

['demon'] = {amount = 100, storage = 19000, reward = {7791, 1}, outfit = {10, 2}},

and remove
local Reward = Reward_boss[math.random(1, #Reward_boss)]
local Reward_boss = {2280,2278,2263,2275,2646,2272,2160} -- put here id of most items to be won

and change
doPlayerAddItem(cid, Reward,1) TO doPlayerAddItem(cid, monster.reward[1], monster.reward[2])


i hope u understand me {fucking bad english sorry }
 
this script will give items to all player attack monster everytime they kill monster

Code:
local config = {
     ['demon'] = {amount = 1, storage = 190700}, ----- write name of monster and any empty storage
     ['dragon'] = {amount = 1, storage = 19001}  ---- same here
}
local Reward_boss = {2280,2278,2263,2275,2646,2272,2160}  -- put here id of most items to be won
function onKill(cid, target)
     local monster = config[getCreatureName(target):lower()]
     if isPlayer(target) or not monster or isSummon(target) then
         return true
     end
      local Reward = Reward_boss[math.random(1, #Reward_boss)]
     if (getPlayerStorageValue(cid, monster.storage)+1) < monster.amount then
         setPlayerStorageValue(cid, monster.storage, getPlayerStorageValue(cid, monster.storage) + 1)
     end
     if (getPlayerStorageValue(cid, monster.storage)+1) == monster.amount then
         doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, 'Congratulations, you have killed '..getCreatureName(target)..' and received '..getItemNameById(Reward)..'.')
         doPlayerAddItem(cid, Reward,1)
     end
     return true
end

this script will give items to all player attack monster but one time only

Code:
local config = {
     ['demon'] = {amount = 1, storage = 190700}, ----- write name of monster and any empty storage
     ['dragon'] = {amount = 1, storage = 19001}  ---- same here
}
local Reward_boss = {2280,2278,2263,2275,2646,2272,2160}  -- put here id of most items to be won
function onKill(cid, target)
     local monster = config[getCreatureName(target):lower()]
     if isPlayer(target) or not monster or isSummon(target) then
         return true
     end
      local Reward = Reward_boss[math.random(1, #Reward_boss)]
     if (getPlayerStorageValue(cid, monster.storage)+1) < monster.amount then
         setPlayerStorageValue(cid, monster.storage, getPlayerStorageValue(cid, monster.storage) + 1)
     end
     if (getPlayerStorageValue(cid, monster.storage)+1) == monster.amount then
         doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, 'Congratulations, you have killed '..getCreatureName(target)..' and received '..getItemNameById(Reward)..'.')
         doPlayerAddItem(cid, Reward,1)
        setPlayerStorageValue(cid, monster.storage, getPlayerStorageValue(cid, monster.storage) + 1)
     end
     return true
end

if u need add outfit to this {when player kill this monster get outfit } u can add somthing like this
['demon'] = {amount = 1, storage = 190700, outfit = {10, 2}},

and above doPlayerAddItem(cid, Reward,1) add doPlayerAddOutfitId(cid, monster.outfit[1], monster.outfit[2])


if u need all player get same items when kill monster use this

['demon'] = {amount = 100, storage = 19000, reward = {7791, 1}, outfit = {10, 2}},

and remove
local Reward = Reward_boss[math.random(1, #Reward_boss)]
local Reward_boss = {2280,2278,2263,2275,2646,2272,2160} -- put here id of most items to be won

and change
doPlayerAddItem(cid, Reward,1) TO doPlayerAddItem(cid, monster.reward[1], monster.reward[2])


i hope u understand me {fucking bad english sorry }
Do I need add something to monster sscript? What does mean 'all time' and 'one time'? :D


#EDIT

I'm getting error:

[10:15:11.532] [Error - CreatureScript Interface]
[10:15:11.532] data/creaturescripts/scripts/capsule.lua:eek:nKill
[10:15:11.532] Description:
[10:15:11.532] data/creaturescripts/scripts/capsule.lua:8: attempt to call global 'isSummon' (a nil value)
[10:15:11.532] stack traceback:
[10:15:11.532] data/creaturescripts/scripts/capsule.lua:8: in function <data/creaturescripts/scripts/capsule.lua:6>
 
Last edited:
no u don't need to add anything in monsters.xml
all time its mean when kill this monster u will get reward in everytime u kill this monster
one time mean u will get reward one time only if u killed this monster 2000 time
 
no u don't need to add anything in monsters.xml
all time its mean when kill this monster u will get reward in everytime u kill this monster
one time mean u will get reward one time only if u killed this monster 2000 time
I updated post above you with an error. But tell me, all the attackers will get a reward yes?

@heba
 
Last edited:
add this in ur lib/050-function

Code:
function isSummon(cid)
return getCreatureMaster(cid) ~= nil
end

and yes all player attack will get reward
 
Solution
Back
Top