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

{Obsidian Knife problem}

LucasFerraz

Systems Analyst
Joined
Jun 10, 2010
Messages
2,857
Reaction score
96
Location
Brazil
My problem is:
1. You can get skin ever, never fail
2. Player get skin in summons

LUA:
local MINOTAUR_LEATHER, LIZARD_LEATHER, GREEN_DRAGON_LEATHER, RED_DRAGON_LEATHER, HARDENED_BONE, BEHEMOTH_FANG = 5878, 5876, 5877, 5948, 5925, 5893
 
local config = {
	[3090] = {10, MINOTAUR_LEATHER},
	[2871] = {10, MINOTAUR_LEATHER},
	[2866] = {10, MINOTAUR_LEATHER},
	[2876] = {10, MINOTAUR_LEATHER},
	[3104] = {10, GREEN_DRAGON_LEATHER},
	[2881] = {10, RED_DRAGON_LEATHER},
	[2931] = {10, BEHEMOTH_FANG},
	[4256] = {10, LIZARD_LEATHER},
	[4259] = {10, LIZARD_LEATHER},
	[4262] = {10, LIZARD_LEATHER},
	[3031] = {10, HARDENED_BONE}
}
 
local pumpkin_items = {
	[1] = {2683},
	[2] = {2688, 50},
	[3] = {6571},
	[4] = {6492},
	[5] = {6574},
	[6] = {6526},
	[7] = {2096},
	[8] = {9005, 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)
	if itemEx.itemid == 8961 then
		if getPlayerStorageValue(cid, 81279) <= 0 then
			doCreatureSay(cid, "Happy Halloween!", TALKTYPE_ORANGE_1)
			doSendMagicEffect(getCreaturePosition(cid), math.random(28,30))
			setPlayerStorageValue(cid, 81279, 1)
			local v = pumpkin_items[math.random(#pumpkin_items)]
			doPlayerAddItem(cid, v[1], v[2] or 1)
		else
			doCreatureSay(cid, "You already used your knife on the corpse.", TALKTYPE_ORANGE_1, false, cid)
		end
		return true
	end
 
	-- Sculpting
	local v = sculpting[itemEx.itemid]
	if v then
		if(math.random(v.randsize) == 1) then
			doTransformItem(itemEx.uid, v.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
	v = config[itemEx.itemid]
	if not v then
		return false
	elseif math.random(100) <= v[2] then
		doPlayerAddItem(cid, v[2], 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
 
Replace:
Code:
	elseif math.random(100) <= v[2] then

With:
Code:
	elseif math.random(100) <= v[1] then

Should work.
 
Then change here:
LUA:
local config = {
	[3090] = {10, MINOTAUR_LEATHER},

The 10, for a higher number.
 
10 = 10%?
Thank you, what about summons? Players can skin summons :S

Exactly.
I dont know if that can be done, since itemEx checks an itemid(the corpse) so, theres no difference beetween a summon monster corpse and a normal monster corpse, the only thing that cud be done I guess, its a script so if a summon dies, the corpse gets an AID and if it has that aid then knife cant skin it.
 
Create a LUA file called obsidianknife.lua and add this:
LUA:
function onLogin(cid)
	registerCreatureEvent(cid, "SummonKill")
	return true
end
function onKill(cid, target)
if isMonster(target) and isPlayer(getCreatureMaster(target)) then
	registerCreatureEvent(target, "ObMonsterCheck")
end

	return true
end
function onDeath(cid, corpse)
	doItemSetAttribute(corpse.uid, "aid", 9999)
	return true
end

On creaturescripts.xml
XML:
	<event type="kill" name="SummonKill" event="script" value="obsidianknife.lua"/>
	<event type="login" name="obs_login" event="script" value="obsidianknife.lua"/>
	<event type="death" name="ObMonsterCheck" event="script" value="obsidianknife.lua"/>


Add on script this:
LUA:
if itemEx.actionid == 9999 then
return doPlayerSendCancel(cid, "You cant skin a summon corpse.")
end

and test
 
Last edited:
Back
Top