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

Lua Decoy Spell, Need Help

botter1234

Member
Joined
Jun 20, 2008
Messages
103
Reaction score
7
This is what I have, idk who made the script I am sorry for not stating name, but I have made a few modifications to it because it was erroring and not giving the correct hp

I cannot manage to get the script to retrieve the players outfit and apply it to the decoy

Lua:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_EFFECT, 39)
setCombatParam(combat, COMBAT_PARAM_AGGRESSIVE, 0)


function onCastSpell(cid, var) 
local REQUIRED_REBIRTHS = 6  --Change this for the number of rebirths
if getCreatureStorage(cid, 85987) < REQUIRED_REBIRTHS then
    doPlayerSendCancel(cid, "You can only use this spell if you have " .. REQUIRED_REBIRTHS .. " prestiges.")
    doSendMagicEffect(getCreaturePosition(cid), CONST_ME_POFF)
    return false
end

	local n = getCreatureSummons(cid)
	if #n >= 1 then
	for _,pid in ipairs(n) do
		doRemoveCreature(pid)
	end
		return false
	end
		local hp = getCreatureHealth(cid)
		local position = getCreaturePosition(cid)
		
		position.stackpos = 255
		local creature = doSummonCreature("Decoy", position)
		if hp < 1000000000 then
			setCreatureMaxHealth(creature, 2*hp)
                        doSetMonsterOutfit(getCreatureSummons(cid), getCreatureOutfit(cid))
			doConvinceCreature(cid, creature)
		else 
			setCreatureMaxHealth(creature, 2100000000)
                        doSetMonsterOutfit(getCreatureSummons(cid), getCreatureOutfit(cid))
			doConvinceCreature(cid, creature)
		end
	return doCombat(cid, combat, var)
end

the doSetMonsterOutfit, I have tried many different variables and calling it in different parts of the script it made no difference it gave the same error

(luadoSetMonsterOutfit) Creature Not Found
 
Lua:
		if hp < 1000000000 then
			setCreatureMaxHealth(creature, 2*hp)
                        doSetMonsterOutfit(getCreatureSummons(cid)[1], getCreatureOutfit(cid))
			doConvinceCreature(cid, creature)
		else 
			setCreatureMaxHealth(creature, 2100000000)
                        doSetMonsterOutfit(getCreatureSummons(cid)[1], getCreatureOutfit(cid))
			doConvinceCreature(cid, creature)
		end
 
I tryed it =/ didn't work thank you though

No longer errors but doesn't change the outfit

- - - Updated - - -

Finally got it

just make a monster with any look and such, does not matter cause this script will copy your outfit, then make it how you want it it is considered a summon

Now I want to find a way for decoy to get players name so it actually works like a decoy

So will post here for everyone to use

Lua:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_EFFECT, 39)
setCombatParam(combat, COMBAT_PARAM_AGGRESSIVE, 0)


function onCastSpell(cid, var) 
local REQUIRED_REBIRTHS = 6  --Change this for the number of rebirths
if getCreatureStorage(cid, 85987) < REQUIRED_REBIRTHS then
    doPlayerSendCancel(cid, "You can only use this spell if you have " .. REQUIRED_REBIRTHS .. " prestiges.")
    doSendMagicEffect(getCreaturePosition(cid), CONST_ME_POFF)
    return false
end

	local n = getCreatureSummons(cid)
	if #n >= 1 then
	for _,pid in ipairs(n) do
		doRemoveCreature(pid)
	end
		return false
	end
		local hp = getCreatureHealth(cid)
		local position = getCreaturePosition(cid)
		
		position.stackpos = 255
		local creature = doSummonCreature("Decoy", position)
		 if hp < 1000000000 then
			setCreatureMaxHealth(creature, 2*hp)
			doConvinceCreature(cid, creature)
				doCreatureChangeOutfit(getCreatureSummons(cid)[1], getCreatureOutfit(cid))
		else 
			setCreatureMaxHealth(creature, 2100000000)
			doConvinceCreature(cid, creature)
				doCreatureChangeOutfit(getCreatureSummons(cid)[1], getCreatureOutfit(cid))
                        
		end
			--doCreatureChangeOutfit(getCreatureSummons(cid)[1], getCreatureOutfit(cid))
	return doCombat(cid, combat, var)
end

For Server without prestige

Lua:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_EFFECT, 39)
setCombatParam(combat, COMBAT_PARAM_AGGRESSIVE, 0)


function onCastSpell(cid, var) 

	local n = getCreatureSummons(cid)
	if #n >= 1 then
	for _,pid in ipairs(n) do
		doRemoveCreature(pid)
	end
		return false
	end
		local hp = getCreatureHealth(cid)
		local position = getCreaturePosition(cid)
		
		position.stackpos = 255
		local creature = doSummonCreature("Decoy", position)
		 if hp < 1000000000 then
			setCreatureMaxHealth(creature, 2*hp)
			doConvinceCreature(cid, creature)
				doCreatureChangeOutfit(getCreatureSummons(cid)[1], getCreatureOutfit(cid))
		else 
			setCreatureMaxHealth(creature, 2100000000)
			doConvinceCreature(cid, creature)
				doCreatureChangeOutfit(getCreatureSummons(cid)[1], getCreatureOutfit(cid))
                        
		end
			--doCreatureChangeOutfit(getCreatureSummons(cid)[1], getCreatureOutfit(cid))
	return doCombat(cid, combat, var)
end
 
Last edited:
I don't know the exact function name because i've only been working with old otserv distros with no functions but you should be able to set the creaturename = getPlayername(cid) or something like that.
 
Back
Top