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

help improving script and doubts

kn4tseb

New Member
Joined
Feb 8, 2009
Messages
83
Reaction score
0
-hi everyone, well.. im a begginer in all the scripting area so i took things from here and there and made this script for obsidian knife and i'd like elite scripters a little help improving it and in shorting it...
- the second script is my food.lua but i have some doubts.. i add item 9005 to the script as you can see.. but when i right clicked it, i get the cannot use this object message.. does it have something to do with the item itself??.. thank you all

obsidian knife / with ice cube part.
PHP:
local chance = 20

function onUse(cid, item, fromPosition, itemEx, toPosition)
    if itemEx.itemid == 7441 then
    if (math.random(1, 100) <= chance*3) then
       doTransformItem(itemEx.uid, 7442)
       doSendMagicEffect(toPosition, CONST_ME_MAGIC_GREEN)
    else
       doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR,"You broke it.")
       doSendMagicEffect(toPosition, CONST_ME_BLOCKHIT)
    doRemoveItem(itemEx.uid)
    end
    elseif itemEx.itemid == 7442 then
    if (math.random(1, 100) <= chance*2) then
       doTransformItem(itemEx.uid, 7444)
       doSendMagicEffect(toPosition, CONST_ME_MAGIC_GREEN)
    else
       doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR,"You broke it.")
       doSendMagicEffect(toPosition, CONST_ME_BLOCKHIT)
    doRemoveItem(itemEx.uid)
    end
    elseif itemEx.itemid == 7444 then
    if (math.random(1, 100) <= chance) then
       doTransformItem(itemEx.uid, 7445)
       doSendMagicEffect(toPosition, CONST_ME_MAGIC_GREEN)
    else
       doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR,"You broke it.")
       doSendMagicEffect(toPosition, CONST_ME_BLOCKHIT)
    doRemoveItem(itemEx.uid)
    end
    elseif itemEx.itemid == 7445 then
    if (math.random(1, 100) <= chance/4) then
       doTransformItem(itemEx.uid, 7446)
       doSendMagicEffect(toPosition, CONST_ME_MAGIC_GREEN)
    else
       doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR,"You broke it.")
       doSendMagicEffect(toPosition, CONST_ME_BLOCKHIT)
    doRemoveItem(itemEx.uid)
    end
end
    return TRUE
end
 
Last edited:
Lua:
local chance = 20
local transf = {     [ItemEx.ItemId]={toid = item created  if success, chance_level = value 'chance' added earlier * chance_level value % for success}
					[7441] = {toid = 7442, chance_level = 3},
					[7442] = {toid = 7444, chance_level = 2},
					[7444] = {toid = 7445, chance_level = 1},
					[7445] = {toid = 7446, chance_level = 1/4}

				}
function onUse(cid, item, fromPosition, itemEx, toPosition)

    if (math.random(1, 100) <= transf[itemEx.itemid].chance_level*chance) then
       doTransformItem(itemEx.uid, transf[itemEx.itemid].toid)
       doSendMagicEffect(toPosition, CONST_ME_MAGIC_GREEN)
    else
       doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR,"You broke it.")
       doSendMagicEffect(toPosition, CONST_ME_BLOCKHIT)
		doRemoveItem(itemEx.uid)
    end
    
    return TRUE
end

om nom nom
 
omg.... that is just beautifull :S
well i forgot to mention that im using TFS 0.3.4pl2
and well it didnt work but im trying to fix it.. dunno if i can make it


Ok Ok.. i got the idea, now is working.. thank you very much :D:D:D:D:D

THANKS!!

Well mate, the script worked and now i want to integrate it to obsidian_knife script... i did but im getting an error.. here's the script and the error after it..

PHP:
local chance = 20
local MINOTAUR_LEATHER = 5878
local LIZARD_LEATHER = 5876
local GREEN_DRAGON_LEATHER = 5877
local RED_DRAGON_LEATHER = 5948
local HARDENED_BONE = 5925
local BEHEMOTH_FANG = 5893
local BEHEMOTH_FANG = 5893

local config = {
    [2830] = {product = MINOTAUR_LEATHER, newcorpse = 2831},
    [2866] = {product = MINOTAUR_LEATHER, newcorpse = 2867},
    [2871] = {product = MINOTAUR_LEATHER, newcorpse = 2872},
    [2876] = {product = MINOTAUR_LEATHER, newcorpse = 2877},
    [3090] = {product = MINOTAUR_LEATHER, newcorpse = 3091},
    [3104] = {product = GREEN_DRAGON_LEATHER, newcorpse = 3105},
    [2881] = {product = RED_DRAGON_LEATHER, newcorpse = 2882},
    [2931] = {product = BEHEMOTH_FANG, newcorpse = 2932},
    [4256] = {product = LIZARD_LEATHER, newcorpse = 4257},
    [4259] = {product = LIZARD_LEATHER, newcorpse = 4260},
    [4262] = {product = LIZARD_LEATHER, newcorpse = 4263},
    [3031] = {product = HARDENED_BONE, newcorpse = 3032}
}

local icecube = { 
               [7441] = {toid = 7442, chance_level = 3},
               [7442] = {toid = 7444, chance_level = 2},
               [7444] = {toid = 7445, chance_level = 1},
               [7445] = {toid = 7446, chance_level = 1/4}
}

local pumpkin_items = {
    [1] = {itemid = 2683},
    [2] = {itemid = 2688, count = 50},
    [3] = {itemid = 6571},
    [4] = {itemid = 6492},
    [5] = {itemid = 6574},
    [6] = {itemid = 6526},
    [7] = {itemid = 2096},
    [8] = {itemid = 9005, count = 20}
}
function onUse(cid, item, fromPosition, itemEx, toPosition)

    -- For The Elemental Spheres Quest, extracting neutral matter from Lord of the Elements corpse
    if itemEx.itemid == 9010 then
        if getPlayerStorageValue(cid, 64998) <= 0 then
            doSendMagicEffect(toPosition, CONST_ME_MAGIC_GREEN)
            doPlayerAddItem(cid, 8310, 1)
            setPlayerStorageValue(cid, 64998, 1)
        else
            doCreatureSay(cid, "You already used your knife on the corpse.", TALKTYPE_ORANGE_1)
        end
        return TRUE
    end
    -- Slain Mutated Pumpkin
    if itemEx.itemid == 8961 then
        if getPlayerStorageValue(cid, 64999) <= 0 then
            doCreatureSay(cid, "Happy Halloween!", TALKTYPE_ORANGE_1)
            doSendMagicEffect(getCreaturePosition(cid), math.random(28,30))
            setPlayerStorageValue(cid, 64999, 1)
            local random = math.random(8)
            if pumpkin_items[random].count ~= nil then
                doPlayerAddItem(cid, pumpkin_items[random].itemid, pumpkin_items[random].count)
            else
                doPlayerAddItem(cid, pumpkin_items[random].itemid, 1)
            end
        else
            doCreatureSay(cid, "You already used your knife on the corpse.", TALKTYPE_ORANGE_1)
        end
        return TRUE
    end

 -- items and corpses

    if (config[itemEx.itemid] == nil) then
        return FALSE
    end
    if (math.random(1, 100) <= chance) then
        doPlayerAddItem(cid, config[itemEx.itemid].product, 1)
        doSendMagicEffect(toPosition, CONST_ME_MAGIC_GREEN)
    else
        doSendMagicEffect(toPosition, CONST_ME_BLOCKHIT)
    end
    doTransformItem(itemEx.uid, config[itemEx.itemid].newcorpse)
    doDecayItem(itemEx.uid)
    return TRUE
end  

    -- Ice cube
    if (icecube[itemEx.itemid] == nil) then
        return FALSE
    end
    if (math.random(1, 100) <= icecube[itemEx.itemid].chance_level*chance) then
       doTransformItem(itemEx.uid, icecube[itemEx.itemid].toid)
       doSendMagicEffect(toPosition, CONST_ME_MAGIC_GREEN)
    else
       doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR,"You broke it.")
       doSendMagicEffect(toPosition, CONST_ME_BLOCKHIT)
                doRemoveItem(itemEx.uid)
    end
return true
end

[Warning - Event::loadScript] Cannot load script (data/actions/scripts/tools/obsidian_knife.lua)
data/actions/scripts/tools/obsidian_knife.lua:102: '<eof>' expected near 'end'

i know someone here has the answer please, helpme with thisone.. ive tried for hours and i just cant figure it out :(
 
Last edited by a moderator:
idk if isInArray Is goog option here;)
Lua:
local chance = 20
local MINOTAUR_LEATHER = 5878
local LIZARD_LEATHER = 5876
local GREEN_DRAGON_LEATHER = 5877
local RED_DRAGON_LEATHER = 5948
local HARDENED_BONE = 5925
local BEHEMOTH_FANG = 5893
local BEHEMOTH_FANG = 5893

local config = {
					[2830] = {product = MINOTAUR_LEATHER, newcorpse = 2831},
					[2866] = {product = MINOTAUR_LEATHER, newcorpse = 2867},
					[2871] = {product = MINOTAUR_LEATHER, newcorpse = 2872},
					[2876] = {product = MINOTAUR_LEATHER, newcorpse = 2877},
					[3090] = {product = MINOTAUR_LEATHER, newcorpse = 3091},
					[3104] = {product = GREEN_DRAGON_LEATHER, newcorpse = 3105},
					[2881] = {product = RED_DRAGON_LEATHER, newcorpse = 2882},
					[2931] = {product = BEHEMOTH_FANG, newcorpse = 2932},
					[4256] = {product = LIZARD_LEATHER, newcorpse = 4257},
					[4259] = {product = LIZARD_LEATHER, newcorpse = 4260},
					[4262] = {product = LIZARD_LEATHER, newcorpse = 4263},
					[3031] = {product = HARDENED_BONE, newcorpse = 3032}
				}

local icecube = { 
				   [7441] = {toid = 7442, chance_level = 3},
				   [7442] = {toid = 7444, chance_level = 2},
				   [7444] = {toid = 7445, chance_level = 1},
				   [7445] = {toid = 7446, chance_level = 1/4}
				}

local pumpkin_items = {
						[1] = {itemid = 2683},
						[2] = {itemid = 2688, count = 50},
						[3] = {itemid = 6571},
						[4] = {itemid = 6492},
						[5] = {itemid = 6574},
						[6] = {itemid = 6526},
						[7] = {itemid = 2096},
						[8] = {itemid = 9005, count = 20}
					}
function onUse(cid, item, fromPosition, itemEx, toPosition)

    -- For The Elemental Spheres Quest, extracting neutral matter from Lord of the Elements corpse
    if itemEx.itemid == 9010 then
        if getPlayerStorageValue(cid, 64998) <= 0 then
            doSendMagicEffect(toPosition, CONST_ME_MAGIC_GREEN)
            doPlayerAddItem(cid, 8310, 1)
            setPlayerStorageValue(cid, 64998, 1)
        else
            doCreatureSay(cid, "You already used your knife on the corpse.", TALKTYPE_ORANGE_1)
        end
        return TRUE
    end
    -- Slain Mutated Pumpkin
    if itemEx.itemid == 8961 then
        if getPlayerStorageValue(cid, 64999) <= 0 then
            doCreatureSay(cid, "Happy Halloween!", TALKTYPE_ORANGE_1)
            doSendMagicEffect(getCreaturePosition(cid), math.random(28,30))
            setPlayerStorageValue(cid, 64999, 1)
            local random = math.random(8)
            if pumpkin_items[random].count ~= nil then
                doPlayerAddItem(cid, pumpkin_items[random].itemid, pumpkin_items[random].count)
            else
                doPlayerAddItem(cid, pumpkin_items[random].itemid, 1)
            end
        else
            doCreatureSay(cid, "You already used your knife on the corpse.", TALKTYPE_ORANGE_1)
        end
        return TRUE
    end

 -- items and corpses

    if isInArray(config, itemEx.itemid) then
		if (math.random(1, 100) <= chance) then
			doPlayerAddItem(cid, config[itemEx.itemid].product, 1)
			doSendMagicEffect(toPosition, CONST_ME_MAGIC_GREEN)
		else
			doSendMagicEffect(toPosition, CONST_ME_BLOCKHIT)
		end
		doTransformItem(itemEx.uid, config[itemEx.itemid].newcorpse)
		doDecayItem(itemEx.uid)
	elseif isInArray(icecube, itemEx.itemid) then
		if (math.random(1, 100) <= icecube[itemEx.itemid].chance_level*chance) then
		   doTransformItem(itemEx.uid, icecube[itemEx.itemid].toid)
		   doSendMagicEffect(toPosition, CONST_ME_MAGIC_GREEN)
		else
		   doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR,"You broke it.")
		   doSendMagicEffect(toPosition, CONST_ME_BLOCKHIT)
			doRemoveItem(itemEx.uid)
		end
	end  

return true
end
 
Ohhhh i got i got it :D.. didnt know that ^^.. im going to test it right away


doesnt seem to work.... :S i dont get any errors but when i use it over the corpses/items nothing happens... help please :(

i think isInArray wont work here... but i dont know how to define the configs... :S help please

Bump

plz... i need it T_T.. im sure it wont be any hard for middle hight scripters.. but i dont know how to do it..
 
Last edited by a moderator:
Lua:
  local chance = 20
local MINOTAUR_LEATHER = 5878
local LIZARD_LEATHER = 5876
local GREEN_DRAGON_LEATHER = 5877
local RED_DRAGON_LEATHER = 5948
local HARDENED_BONE = 5925
local BEHEMOTH_FANG = 5893
local BEHEMOTH_FANG = 5893

local config = {
                                        [2830] = {product = MINOTAUR_LEATHER, newcorpse = 2831},
                                        [2866] = {product = MINOTAUR_LEATHER, newcorpse = 2867},
                                        [2871] = {product = MINOTAUR_LEATHER, newcorpse = 2872},
                                        [2876] = {product = MINOTAUR_LEATHER, newcorpse = 2877},
                                        [3090] = {product = MINOTAUR_LEATHER, newcorpse = 3091},
                                        [3104] = {product = GREEN_DRAGON_LEATHER, newcorpse = 3105},
                                        [2881] = {product = RED_DRAGON_LEATHER, newcorpse = 2882},
                                        [2931] = {product = BEHEMOTH_FANG, newcorpse = 2932},
                                        [4256] = {product = LIZARD_LEATHER, newcorpse = 4257},
                                        [4259] = {product = LIZARD_LEATHER, newcorpse = 4260},
                                        [4262] = {product = LIZARD_LEATHER, newcorpse = 4263},
                                        [3031] = {product = HARDENED_BONE, newcorpse = 3032}
                                }

local icecube = {
                                   [7441] = {toid = 7442, chance_level = 3},
                                   [7442] = {toid = 7444, chance_level = 2},
                                   [7444] = {toid = 7445, chance_level = 1},
                                   [7445] = {toid = 7446, chance_level = 1/4}
                                }

local pumpkin_items = {
                                                [1] = {itemid = 2683},
                                                [2] = {itemid = 2688, count = 50},
                                                [3] = {itemid = 6571},
                                                [4] = {itemid = 6492},
                                                [5] = {itemid = 6574},
                                                [6] = {itemid = 6526},
                                                [7] = {itemid = 2096},
                                                [8] = {itemid = 9005, count = 20}
                                        }
function onUse(cid, item, fromPosition, itemEx, toPosition)

    -- For The Elemental Spheres Quest, extracting neutral matter from Lord of the Elements corpse
	
    if itemEx.itemid == 9010 then
        if getPlayerStorageValue(cid, 64998) <= 0 then
            doSendMagicEffect(toPosition, CONST_ME_MAGIC_GREEN)
            doPlayerAddItem(cid, 8310, 1)
            setPlayerStorageValue(cid, 64998, 1)
        else
            doCreatureSay(cid, "You already used your knife on the corpse.", TALKTYPE_ORANGE_1)
        end

    -- Slain Mutated Pumpkin
    elseif itemEx.itemid == 8961 then
        if getPlayerStorageValue(cid, 64999) <= 0 then
            doCreatureSay(cid, "Happy Halloween!", TALKTYPE_ORANGE_1)
            doSendMagicEffect(getCreaturePosition(cid), math.random(28,30))
            setPlayerStorageValue(cid, 64999, 1)
            local random = math.random(8)
            if pumpkin_items[random].count ~= nil then
                doPlayerAddItem(cid, pumpkin_items[random].itemid, pumpkin_items[random].count)
            else
                doPlayerAddItem(cid, pumpkin_items[random].itemid, 1)
            end
        else
            doCreatureSay(cid, "You already used your knife on the corpse.", TALKTYPE_ORANGE_1)
        end
 -- items and corpses

    elseif #config[itemEx.itemid] > 1 then
                if (math.random(1, 100) <= chance) then
                        doPlayerAddItem(cid, config[itemEx.itemid].product, 1)
                        doSendMagicEffect(toPosition, CONST_ME_MAGIC_GREEN)
                else
                        doSendMagicEffect(toPosition, CONST_ME_BLOCKHIT)
                end
                doTransformItem(itemEx.uid, config[itemEx.itemid].newcorpse)
                doDecayItem(itemEx.uid)
    elseif #icecube[itemEx.itemid] > 1  then
			if (math.random(1, 100) <= icecube[itemEx.itemid].chance_level*chance) then
			   doTransformItem(itemEx.uid, icecube[itemEx.itemid].toid)
			   doSendMagicEffect(toPosition, CONST_ME_MAGIC_GREEN)
			else
			   doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR,"You broke it.")
			   doSendMagicEffect(toPosition, CONST_ME_BLOCKHIT)
					doRemoveItem(itemEx.uid)
			end
    end  

return true
end


?
 
Nop.. you cannot use this object :/:/:/:/:/


this is the error: Lua Script Error: [Action Interface]
data/actions/scripts/tools/obsidian_knife.lua:eek:nUse

data/actions/scripts/tools/obsidian_knife.lua:72: attempt to get length of field '?' (a nil value)
stack traceback:
data/actions/scripts/tools/obsidian_knife.lua:72: in function <data/actions/scripts/tools/obsidian_knife.lua:42>
 
Last edited:
@kn4tseb:

Lua:
local chance = 20
local MINOTAUR_LEATHER = 5878
local LIZARD_LEATHER = 5876
local GREEN_DRAGON_LEATHER = 5877
local RED_DRAGON_LEATHER = 5948
local HARDENED_BONE = 5925
local BEHEMOTH_FANG = 5893
local BEHEMOTH_FANG = 5893

local config = {
                                        [2830] = {product = MINOTAUR_LEATHER, newcorpse = 2831},
                                        [2866] = {product = MINOTAUR_LEATHER, newcorpse = 2867},
                                        [2871] = {product = MINOTAUR_LEATHER, newcorpse = 2872},
                                        [2876] = {product = MINOTAUR_LEATHER, newcorpse = 2877},
                                        [3090] = {product = MINOTAUR_LEATHER, newcorpse = 3091},
                                        [3104] = {product = GREEN_DRAGON_LEATHER, newcorpse = 3105},
                                        [2881] = {product = RED_DRAGON_LEATHER, newcorpse = 2882},
                                        [2931] = {product = BEHEMOTH_FANG, newcorpse = 2932},
                                        [4256] = {product = LIZARD_LEATHER, newcorpse = 4257},
                                        [4259] = {product = LIZARD_LEATHER, newcorpse = 4260},
                                        [4262] = {product = LIZARD_LEATHER, newcorpse = 4263},
                                        [3031] = {product = HARDENED_BONE, newcorpse = 3032}
                                }

local icecube = {
                                   [7441] = {toid = 7442, chance_level = 3},
                                   [7442] = {toid = 7444, chance_level = 2},
                                   [7444] = {toid = 7445, chance_level = 1},
                                   [7445] = {toid = 7446, chance_level = 1/4}
                                }

local pumpkin_items = {
                                                [1] = {itemid = 2683},
                                                [2] = {itemid = 2688, count = 50},
                                                [3] = {itemid = 6571},
                                                [4] = {itemid = 6492},
                                                [5] = {itemid = 6574},
                                                [6] = {itemid = 6526},
                                                [7] = {itemid = 2096},
                                                [8] = {itemid = 9005, count = 20}
                                        }
function onUse(cid, item, fromPosition, itemEx, toPosition)

    -- For The Elemental Spheres Quest, extracting neutral matter from Lord of the Elements corpse
    if itemEx.itemid == 9010 then
        if getPlayerStorageValue(cid, 64998) <= 0 then
            doSendMagicEffect(toPosition, CONST_ME_MAGIC_GREEN)
            doPlayerAddItem(cid, 8310, 1)
            setPlayerStorageValue(cid, 64998, 1)
        else
            doCreatureSay(cid, "You already used your knife on the corpse.", TALKTYPE_ORANGE_1)
        end
   
    -- Slain Mutated Pumpkin
    elseif itemEx.itemid == 8961 then
        if getPlayerStorageValue(cid, 64999) <= 0 then
            doCreatureSay(cid, "Happy Halloween!", TALKTYPE_ORANGE_1)
            doSendMagicEffect(getCreaturePosition(cid), math.random(28,30))
            setPlayerStorageValue(cid, 64999, 1)
            local random = math.random(8)
            if pumpkin_items[random].count ~= nil then
                doPlayerAddItem(cid, pumpkin_items[random].itemid, pumpkin_items[random].count)
            else
                doPlayerAddItem(cid, pumpkin_items[random].itemid, 1)
            end
        else
            doCreatureSay(cid, "You already used your knife on the corpse.", TALKTYPE_ORANGE_1)
        end

 -- items and corpses

		elseif config[itemEx.itemid] then
                if (math.random(1, 100) <= chance) then
                        doPlayerAddItem(cid, config[itemEx.itemid].product, 1)
                        doSendMagicEffect(toPosition, CONST_ME_MAGIC_GREEN)
                else
                        doSendMagicEffect(toPosition, CONST_ME_BLOCKHIT)
                end
                doTransformItem(itemEx.uid, config[itemEx.itemid].newcorpse)
                doDecayItem(itemEx.uid)
        elseif icecube[itemEx.itemid] then
                if (math.random(1, 100) <= icecube[itemEx.itemid].chance_level*chance) then
                   doTransformItem(itemEx.uid, icecube[itemEx.itemid].toid)
                   doSendMagicEffect(toPosition, CONST_ME_MAGIC_GREEN)
                else
                   doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR,"You broke it.")
                   doSendMagicEffect(toPosition, CONST_ME_BLOCKHIT)
                   doRemoveItem(itemEx.uid)
                end
          
		else
			doPlayerSendCancel(cid, "Sorry, not possible.")
		end

return true
end
TESTED

@Master-m

I am posting to make ppl know that there is something new. I never open thread where i posted a solution if i don't see that sb else have posted (due of problem or thanks)

So i f that person edit his post, of course i won't even open this thread to be helpful ;)

I don't know that you understood me xD
 
@kn4tseb:

Lua:
local chance = 20
local MINOTAUR_LEATHER = 5878
local LIZARD_LEATHER = 5876
local GREEN_DRAGON_LEATHER = 5877
local RED_DRAGON_LEATHER = 5948
local HARDENED_BONE = 5925
local BEHEMOTH_FANG = 5893
local BEHEMOTH_FANG = 5893

local config = {
                                        [2830] = {product = MINOTAUR_LEATHER, newcorpse = 2831},
                                        [2866] = {product = MINOTAUR_LEATHER, newcorpse = 2867},
                                        [2871] = {product = MINOTAUR_LEATHER, newcorpse = 2872},
                                        [2876] = {product = MINOTAUR_LEATHER, newcorpse = 2877},
                                        [3090] = {product = MINOTAUR_LEATHER, newcorpse = 3091},
                                        [3104] = {product = GREEN_DRAGON_LEATHER, newcorpse = 3105},
                                        [2881] = {product = RED_DRAGON_LEATHER, newcorpse = 2882},
                                        [2931] = {product = BEHEMOTH_FANG, newcorpse = 2932},
                                        [4256] = {product = LIZARD_LEATHER, newcorpse = 4257},
                                        [4259] = {product = LIZARD_LEATHER, newcorpse = 4260},
                                        [4262] = {product = LIZARD_LEATHER, newcorpse = 4263},
                                        [3031] = {product = HARDENED_BONE, newcorpse = 3032}
                                }

local icecube = {
                                   [7441] = {toid = 7442, chance_level = 3},
                                   [7442] = {toid = 7444, chance_level = 2},
                                   [7444] = {toid = 7445, chance_level = 1},
                                   [7445] = {toid = 7446, chance_level = 1/4}
                                }

local pumpkin_items = {
                                                [1] = {itemid = 2683},
                                                [2] = {itemid = 2688, count = 50},
                                                [3] = {itemid = 6571},
                                                [4] = {itemid = 6492},
                                                [5] = {itemid = 6574},
                                                [6] = {itemid = 6526},
                                                [7] = {itemid = 2096},
                                                [8] = {itemid = 9005, count = 20}
                                        }
function onUse(cid, item, fromPosition, itemEx, toPosition)

    -- For The Elemental Spheres Quest, extracting neutral matter from Lord of the Elements corpse
    if itemEx.itemid == 9010 then
        if getPlayerStorageValue(cid, 64998) <= 0 then
            doSendMagicEffect(toPosition, CONST_ME_MAGIC_GREEN)
            doPlayerAddItem(cid, 8310, 1)
            setPlayerStorageValue(cid, 64998, 1)
        else
            doCreatureSay(cid, "You already used your knife on the corpse.", TALKTYPE_ORANGE_1)
        end
   
    -- Slain Mutated Pumpkin
    elseif itemEx.itemid == 8961 then
        if getPlayerStorageValue(cid, 64999) <= 0 then
            doCreatureSay(cid, "Happy Halloween!", TALKTYPE_ORANGE_1)
            doSendMagicEffect(getCreaturePosition(cid), math.random(28,30))
            setPlayerStorageValue(cid, 64999, 1)
            local random = math.random(8)
            if pumpkin_items[random].count ~= nil then
                doPlayerAddItem(cid, pumpkin_items[random].itemid, pumpkin_items[random].count)
            else
                doPlayerAddItem(cid, pumpkin_items[random].itemid, 1)
            end
        else
            doCreatureSay(cid, "You already used your knife on the corpse.", TALKTYPE_ORANGE_1)
        end

 -- items and corpses

		elseif config[itemEx.itemid] then
                if (math.random(1, 100) <= chance) then
                        doPlayerAddItem(cid, config[itemEx.itemid].product, 1)
                        doSendMagicEffect(toPosition, CONST_ME_MAGIC_GREEN)
                else
                        doSendMagicEffect(toPosition, CONST_ME_BLOCKHIT)
                end
                doTransformItem(itemEx.uid, config[itemEx.itemid].newcorpse)
                doDecayItem(itemEx.uid)
        elseif icecube[itemEx.itemid] then
                if (math.random(1, 100) <= icecube[itemEx.itemid].chance_level*chance) then
                   doTransformItem(itemEx.uid, icecube[itemEx.itemid].toid)
                   doSendMagicEffect(toPosition, CONST_ME_MAGIC_GREEN)
                else
                   doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR,"You broke it.")
                   doSendMagicEffect(toPosition, CONST_ME_BLOCKHIT)
                   doRemoveItem(itemEx.uid)
                end
          
		else
			doPlayerSendCancel(cid, "Sorry, not possible.")
		end

return true
end
TESTED

@Master-m

I am posting to make ppl know that there is something new. I never open thread where i posted a solution if i don't see that sb else have posted (due of problem or thanks)

So i f that person edit his post, of course i won't even open this thread to be helpful ;)

I don't know that you understood me xD

hehe it was @ kn4tseb

he made like 6post under eachother. then 1 post by u then he again 6 posts. XD u did nothing wrong^^
 
@kn4tseb:

Lua:
local chance = 20
local MINOTAUR_LEATHER = 5878
local LIZARD_LEATHER = 5876
local GREEN_DRAGON_LEATHER = 5877
local RED_DRAGON_LEATHER = 5948
local HARDENED_BONE = 5925
local BEHEMOTH_FANG = 5893
local BEHEMOTH_FANG = 5893

local config = {
                                        [2830] = {product = MINOTAUR_LEATHER, newcorpse = 2831},
                                        [2866] = {product = MINOTAUR_LEATHER, newcorpse = 2867},
                                        [2871] = {product = MINOTAUR_LEATHER, newcorpse = 2872},
                                        [2876] = {product = MINOTAUR_LEATHER, newcorpse = 2877},
                                        [3090] = {product = MINOTAUR_LEATHER, newcorpse = 3091},
                                        [3104] = {product = GREEN_DRAGON_LEATHER, newcorpse = 3105},
                                        [2881] = {product = RED_DRAGON_LEATHER, newcorpse = 2882},
                                        [2931] = {product = BEHEMOTH_FANG, newcorpse = 2932},
                                        [4256] = {product = LIZARD_LEATHER, newcorpse = 4257},
                                        [4259] = {product = LIZARD_LEATHER, newcorpse = 4260},
                                        [4262] = {product = LIZARD_LEATHER, newcorpse = 4263},
                                        [3031] = {product = HARDENED_BONE, newcorpse = 3032}
                                }

local icecube = {
                                   [7441] = {toid = 7442, chance_level = 3},
                                   [7442] = {toid = 7444, chance_level = 2},
                                   [7444] = {toid = 7445, chance_level = 1},
                                   [7445] = {toid = 7446, chance_level = 1/4}
                                }

local pumpkin_items = {
                                                [1] = {itemid = 2683},
                                                [2] = {itemid = 2688, count = 50},
                                                [3] = {itemid = 6571},
                                                [4] = {itemid = 6492},
                                                [5] = {itemid = 6574},
                                                [6] = {itemid = 6526},
                                                [7] = {itemid = 2096},
                                                [8] = {itemid = 9005, count = 20}
                                        }
function onUse(cid, item, fromPosition, itemEx, toPosition)

    -- For The Elemental Spheres Quest, extracting neutral matter from Lord of the Elements corpse
    if itemEx.itemid == 9010 then
        if getPlayerStorageValue(cid, 64998) <= 0 then
            doSendMagicEffect(toPosition, CONST_ME_MAGIC_GREEN)
            doPlayerAddItem(cid, 8310, 1)
            setPlayerStorageValue(cid, 64998, 1)
        else
            doCreatureSay(cid, "You already used your knife on the corpse.", TALKTYPE_ORANGE_1)
        end
   
    -- Slain Mutated Pumpkin
    elseif itemEx.itemid == 8961 then
        if getPlayerStorageValue(cid, 64999) <= 0 then
            doCreatureSay(cid, "Happy Halloween!", TALKTYPE_ORANGE_1)
            doSendMagicEffect(getCreaturePosition(cid), math.random(28,30))
            setPlayerStorageValue(cid, 64999, 1)
            local random = math.random(8)
            if pumpkin_items[random].count ~= nil then
                doPlayerAddItem(cid, pumpkin_items[random].itemid, pumpkin_items[random].count)
            else
                doPlayerAddItem(cid, pumpkin_items[random].itemid, 1)
            end
        else
            doCreatureSay(cid, "You already used your knife on the corpse.", TALKTYPE_ORANGE_1)
        end

 -- items and corpses

		elseif config[itemEx.itemid] then
                if (math.random(1, 100) <= chance) then
                        doPlayerAddItem(cid, config[itemEx.itemid].product, 1)
                        doSendMagicEffect(toPosition, CONST_ME_MAGIC_GREEN)
                else
                        doSendMagicEffect(toPosition, CONST_ME_BLOCKHIT)
                end
                doTransformItem(itemEx.uid, config[itemEx.itemid].newcorpse)
                doDecayItem(itemEx.uid)
        elseif icecube[itemEx.itemid] then
                if (math.random(1, 100) <= icecube[itemEx.itemid].chance_level*chance) then
                   doTransformItem(itemEx.uid, icecube[itemEx.itemid].toid)
                   doSendMagicEffect(toPosition, CONST_ME_MAGIC_GREEN)
                else
                   doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR,"You broke it.")
                   doSendMagicEffect(toPosition, CONST_ME_BLOCKHIT)
                   doRemoveItem(itemEx.uid)
                end
          
		else
			doPlayerSendCancel(cid, "Sorry, not possible.")
		end

return true
end
TESTED

@Master-m

I am posting to make ppl know that there is something new. I never open thread where i posted a solution if i don't see that sb else have posted (due of problem or thanks)

So i f that person edit his post, of course i won't even open this thread to be helpful ;)

I don't know that you understood me xD
:eek: I think I made that script, here's the latest version:
Code:
local MINOTAUR_LEATHER = 5878
local LIZARD_LEATHER = 5876
local GREEN_DRAGON_LEATHER = 5877
local RED_DRAGON_LEATHER = 5948
local HARDENED_BONE = 5925
local BEHEMOTH_FANG = 5893

local config = {
	[2830] = {chance = 10, product = MINOTAUR_LEATHER},
	[2866] = {chance = 10, product = MINOTAUR_LEATHER},
	[2871] = {chance = 10, product = MINOTAUR_LEATHER},
	[2876] = {chance = 10, product = MINOTAUR_LEATHER},
	[2844] = {chance = 10, product = GREEN_DRAGON_LEATHER},
	[2881] = {chance = 10, product = RED_DRAGON_LEATHER},
	[2931] = {chance = 10, product = BEHEMOTH_FANG},
	[4256] = {chance = 10, product = LIZARD_LEATHER},
	[4259] = {chance = 10, product = LIZARD_LEATHER},
	[4262] = {chance = 10, product = LIZARD_LEATHER},
	[3031] = {chance = 10, product = HARDENED_BONE}
}

local pumpkin_items = {
	[1] = {itemid = 2683},
	[2] = {itemid = 2688, count = 50},
	[3] = {itemid = 6571},
	[4] = {itemid = 6492},
	[5] = {itemid = 6574},
	[6] = {itemid = 6526},
	[7] = {itemid = 2096},
	[8] = {itemid = 9005, count = 20}
}

local sculpting =
{
	[7441] = {randsize = 4, newid = 7442},
	[7442] = {randsize = 5, newid = 7444},
	[7444] = {randsize = 6, newid = 7445},
	[7445] = {randsize = 7, newid = 7446},
}

function onUse(cid, item, fromPosition, itemEx, toPosition)
	-- For The Elemental Spheres Quest, extracting neutral matter from Lord of the Elements' corpse
	if itemEx.itemid == 9010 then
		if getPlayerStorageValue(cid, 65049) <= 0 then
			doSendMagicEffect(toPosition, CONST_ME_MAGIC_GREEN)
			doPlayerAddItem(cid, 8310, 1)
			setPlayerStorageValue(cid, 65049, 1)
		else
			doCreatureSay(cid, "You already used your knife on the corpse.", TALKTYPE_ORANGE_1)
		end
		return TRUE
	end

	-- Slain Mutated Pumpkin
	if itemEx.itemid == 8961 then
		if getPlayerStorageValue(cid, 65048) <= 0 then
			doCreatureSay(cid, "Happy Halloween!", TALKTYPE_ORANGE_1)
			doSendMagicEffect(getCreaturePosition(cid), math.random(28,30))
			setPlayerStorageValue(cid, 65048, 1)
			local type = pumpkin_items[math.random(8)]
			doPlayerAddItem(cid, type.itemid, type.count or 1)
		else
			doCreatureSay(cid, "You already used your knife on the corpse.", TALKTYPE_ORANGE_1)
		end
		return TRUE
	end

	-- Sculpting
	local type = sculpting[itemEx.itemid]
	if(type) then
		if(math.random(type.randsize) == 1) then
			doTransformItem(itemEx.uid, type.newid)
		else
			doRemoveItem(itemEx.uid)
			doCreatureSay(cid, "The attempt at sculpting failed miserably.", TALKTYPE_ORANGE_1)
		end
		doSendMagicEffect(toPosition, CONST_ME_HITAREA)
		return TRUE
	end

	-- Skinning
	local type = config[itemEx.itemid]
	if(not(type)) then
		return FALSE
	end
	if(math.random(100) <= type.chance) then
		doPlayerAddItem(cid, type.product, 1)
		doSendMagicEffect(toPosition, CONST_ME_MAGIC_GREEN)
	else
		doSendMagicEffect(toPosition, CONST_ME_BLOCKHIT)
	end
	doTransformItem(itemEx.uid, itemEx.itemid + 1)
	doDecayItem(itemEx.uid)
	return TRUE
end
 
Last edited:
Back
Top