Nerevr back
Member
- Joined
- Nov 7, 2014
- Messages
- 269
- Reaction score
- 7
there way to get scipt for when kill x monster get reward ??
x = number "100"
x = number "100"
Remove everything related to amount and item reward, then add the outfit id in the table and use it in the function.
local config = {
['demon'] = {storage = 19554, outfit = {20, 2}},
['dragon'] = {storage = 19001, outfit = {20, 3}}}
}
function onKill(cid, target)
local monster = config[getCreatureName(target):lower()]
if isPlayer(target) or not monster or isSummon(target) then
return true
end
if getPlayerStorageValue(cid, monster.storage) ~= 1 then
setPlayerStorageValue(cid, monster.storage, getPlayerStorageValue(cid, monster.storage) + 1)
end
if getPlayerStorageValue(cid, monster.storage) ~= 1 then
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, 'Congratulations, you have killed '..(getPlayerStorageValue(cid, monster.storage)+1)..' '..getCreatureName(target)..'s and received a reward.')
doPlayerAddItem(cid, monster.reward[1], monster.reward[2])
end
if math.random(1, 5) == 1 then
doPlayerAddOutfitId(cid, outfitId, addon)
setPlayerStorageValue(cid, monster.storage, 1)
end
return true
end
if getPlayerStorageValue(cid, monster.storage) ~= 1 then
setPlayerStorageValue(cid, monster.storage, getPlayerStorageValue(cid, monster.storage) + 1)
end
doPlayerAddOutfitId(cid, monster.outfit[1], monster.outfit[2])
doPlayerAddItem(cid, monster.reward[1], monster.reward[2])
{storage = 19001, outfit = {20, 3}}}
Remove this (The +1 storage was to count the monsters).
Code:if getPlayerStorageValue(cid, monster.storage) ~= 1 then setPlayerStorageValue(cid, monster.storage, getPlayerStorageValue(cid, monster.storage) + 1) end
An if statement has to close with end (under it), so add the end above "if math.random(1, 5) == 1 then" under setPlayerStorageValue.
Use the table to get the oufit id and addons.
Code:doPlayerAddOutfitId(cid, monster.outfit[1], monster.outfit[2])
And remove this, sinc it's not used anymore.
Code:doPlayerAddItem(cid, monster.reward[1], monster.reward[2])
And this
It has a } to much, 1 is to close the one before storage, the other is to close the one before 20, so remove the last one.Code:{storage = 19001, outfit = {20, 3}}}
local config = {
['demon'] = {storage = 19554, outfit = {20, 2}},
['dragon'] = {storage = 19447, outfit = {20, 3}}
}
function onKill(cid, target)
local monster = config[getCreatureName(target):lower()]
if isPlayer(target) or not monster or isSummon(target) then
return true
end
if getPlayerStorageValue(cid, monster.storage) ~= 1 then
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, 'Congratulations, you have killed '..(getPlayerStorageValue(cid, monster.storage)+1)..' '..getCreatureName(target)..'s and received a reward.')
end
if math.random(1, 5) == 1 then
doPlayerAddOutfitId(cid, monster.outfit[1], monster.outfit[2])
setPlayerStorageValue(cid, monster.storage, 1)
end
return true
end
Add the textmessage under the chance if statement, so players only get it when they get the addon.
You still have to move the end under setPlayerStorageValue.
The chance works line this.
math.random(1,5) gets a random number. 1, 2, 3, 4 or 5, all same chance, so this makes it 20% change, 1 out of 5 is the same as 20% (100:5=20).
local config = {
['demon'] = {storage = 19554, outfit = {20, 2}},
['Strong Freak'] = {storage = 19774, outfit = {19, 2}},
['dragon'] = {storage = 19447, outfit = {20, 3}}
}
function onKill(cid, target)
local monster = config[getCreatureName(target):lower()]
if isPlayer(target) or not monster or isSummon(target) then
return true
end
if math.random(1, 5) == 1 then
doPlayerAddOutfitId(cid, monster.outfit[1], monster.outfit[2])
setPlayerStorageValue(cid, monster.storage, 1)
if getPlayerStorageValue(cid, monster.storage) ~= 1 then
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, 'Congratulations, you have killed '..(getPlayerStorageValue(cid, monster.storage)+1)..' '..getCreatureName(target)..'s and received a reward.')
end
end
return true
end
if getPlayerStorageValue(cid, monster.storage) ~= 1 then
if ... then
-- this (what is added between if and end) will happen if ... is true, it won't happen if ... is not true
end
Add
Above if math.random(1, 5) == 1 then.Code:if getPlayerStorageValue(cid, monster.storage) ~= 1 then
If statements work line this.
http://otland.net/threads/scripting-guide.74030/#post-758243Code:if ... then -- this (what is added between if and end) will happen if ... is true, it won't happen if ... is not true end
When adding addons, 0 means no addon, 1 is for the first addon, 2 is for the second addon and 3 is for both addons.
local config = {
['demon'] = {storage = 19554, outfit = {20, 2}},
['Strong Freak'] = {storage = 19774, outfit = {19, 1}},
['dragon'] = {storage = 19447, outfit = {20, 1}}
}
function onKill(cid, target)
local monster = config[getCreatureName(target):lower()]
if isPlayer(target) or not monster or isSummon(target) then
return true
end
if getPlayerStorageValue(cid, monster.storage) ~= 1 then
end
if math.random(4, 5) == 1 then
doPlayerAddOutfitId(cid, monster.outfit[1], monster.outfit[2])
setPlayerStorageValue(cid, monster.storage, 1)
if getPlayerStorageValue(cid, monster.storage) ~= 1 then
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, 'Congratulations, you have killed '..(getPlayerStorageValue(cid, monster.storage)+1)..' '..getCreatureName(target)..'s and received a reward.')
end
end
return true
end
if math.random(4, 5) == 1 then
Just remove the change if statement
And fix the ends and the storage if statement like I explained.Code:if math.random(4, 5) == 1 then
local config = {
['demon'] = {storage = 19554, outfit = {20, 2}},
['Strong Freak'] = {storage = 19774, outfit = {19, 1}},
['dragon'] = {storage = 19447, outfit = {20, 1}}
}
function onKill(cid, target)
local monster = config[getCreatureName(target):lower()]
if isPlayer(target) or not monster or isSummon(target) then
return true
end
if getPlayerStorageValue(cid, monster.storage) ~= 1 then
doPlayerAddOutfitId(cid, monster.outfit[1], monster.outfit[2])
setPlayerStorageValue(cid, monster.storage, 1)
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, 'Congratulations, you have killed '..(getPlayerStorageValue(cid, monster.storage)+1)..' '..getCreatureName(target)..'s and received a reward.')
end
return true
end
message = 'the second addon of ... outfit'
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, 'Congratulations, you have killed a '..getCreatureName(target)..' and received '..monster.message..'.')
local config = {
cost = {6527, 4}
}
function onUse(cid, item, fromPosition, itemEx, toPosition)
if not doPlayerRemoveItem(cid, config.cost[1], config.cost[2]) then
doCreatureSay(cid, "You need "..config.cost[2].." " .. getItemInfo(config.cost[1]).plural .. " to change ur outfit ", TALKTYPE_ORANGE_1)
doSendMagicEffect(getThingPos(cid), 2)
return true
end
local v, tmp = math.random(365), getCreatureOutfit(cid)
while isInArray({tmp.lookType, 302,146,155,151,156,152,157,153,158,154,252,251,269,268,270,273,279,278,288,289,324,325,336,335,366,367,136,137,129,128,138,130,139,131,140,132,141,133,142,134,147,143,148,144,149,145,150,75, 135, 266}, v) == TRUE or v <= 1 or (v > 160 and v < 192) or v > 333 do
v = math.random(365)
end
tmp.lookType = v
doCreatureChangeOutfit(cid, tmp)
doSendMagicEffect(getThingPos(cid), CONST_ME_MAGIC_RED)
doCreatureSay(cid, 'Your outfit has been changed.', TALKTYPE_ORANGE_1, false, cid, getThingPos(cid))
return TRUE
end