• 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!
  • New resources must be posted under Resources tab. A discussion thread will be created automatically, you can't open threads manually anymore.

TalkAction Monster outfits (monster outfits as quest rewards)

Is this useful for you?


  • Total voters
    21

Sportacus

Intermediate OT User
Joined
Aug 3, 2008
Messages
718
Reaction score
100
Haven't seen a script like this posted before, and seeing a lack of new content released, I feel like releasing this.

The reason this was made because I wanted to reward players with different monster outfits as quest rewards. Easily changeable to allow you to give player creature outfits for whatever reason you want (donation reward, special event prize, click a doll and get the outfits, whatever.)

Works simple, you set the storage value to the monster outfit of your choice, and what value of that storage is needed. You can also set it do whatever effect you want when you change into the outfit.

Cool down put in to prevent players from spamming outfit change.

!outfit <-- for changing into the monster outfit (ex: !outfit Vampire)
!outfits <-- for seeing a list of what monster outfits you have access to using. Brings up a dialog box


Has been tested on TFS 0.3.6.

Okay now on to the script.

data\talkactions\scripts\outfit.lua
Code:
local config = {
	cooldown = 3, -- 3 secs of exhaust
	needParam = "You need to insert a monster's name.",
	cancelMessage = "You can't use this outfit.", -- if player doesn't have the storagevalue or outfit is invalid
	exhaustCancel = "You can't use this spell again yet." -- if player is exhausted
}

local outfits = {
	{monster = "Grim Reaper", id = 300, storageValue = 1234, needed = 1, effect = 17},
	{monster = "Mummy", id = 65, storageValue = 1235, needed = 1},
	{monster = "Bat", id = 122, storageValue = 1236, needed = 1, effect = 66}
}	-- The monster, the id of the outfit, the storage key and the storage value that you need to use it, and the effect

function nocase(s) -- DO NOT EDIT
	s = string.gsub(s, "%a", function (c)
		return string.format("[%s%s]", string.lower(c),
							string.upper(c))
		end)
	return s
end

function onSay(cid, words, param, channel)
	explodes = string.explode(param, " ")
	if (param == "") then
		doPlayerSendCancel(cid, config.needParam)
		return true
	end

	if getPlayerStorageValue(cid, 4040) ~= -1 then
		if not((os.time()-getPlayerStorageValue(cid, 4040) >= config.cooldown)) then
			doPlayerSendCancel(cid, config.exhaustCancel)
			return 1
		else
			doPlayerSetStorageValue(cid, 4040, os.time())
		end
	else
		doPlayerSetStorageValue(cid, 4040, os.time())
	end

	for i, a in pairs(outfits) do
		valid = 0 -- DO NOT CHANGE
		validNeed = 1 -- DO NOT CHANGE
		monsterxplode = string.explode(a.monster, " ")

		if #explodes > 1 and #explodes == #monsterxplode then
			validNeed = #explodes
			for i=1, #explodes do
				if nocase(explodes[i]) == nocase(monsterxplode[i]) then
					valid = valid+1
				end
			end
		else
			if nocase(param) == nocase(a.monster) then
				valid = 1
			end
		end

		if valid == validNeed then
			if getPlayerStorageValue(cid, a.storageValue) == a.needed then
				local azp = getCreatureOutfit(cid)
				azp.lookType = a.id
				changedMessage = "You have changed your outfit to a " .. a.monster .. "'s outfit." -- No need to change it~
				doCreatureChangeOutfit(cid, azp)
				if a.effect ~= NIL then
					doSendMagicEffect(getPlayerPosition(cid), a.effect)
				end
				doPlayerSendTextMessage(cid, MESSAGE_EVENT_DEFAULT, changedMessage)
				return 1
			else
				doPlayerSendCancel(cid, config.cancelMessage)
			end
		else
			doPlayerSendCancel(cid, config.cancelMessage)
		end
	end
	return 1
end


data\talkactions\scripts\outfits.lua

Code:
local config = {
	cooldown = 3,
	itemRead = 1988,
	cancelMessage = "You can't use any outfits yet.",
}

local outfits = {
	{monster = "Grim Reaper", storageValue = 1234, needed = 1},
	{monster = "Mummy", storageValue = 1235, needed = 1},
	{monster = "Bat", storageValue = 1236, needed = 1}
}	-- The monster, the storage key and the storage value that you need to use it

function onSay(cid, words, param, channel)
	creatures = {} -- don't change
	message = "You can currently use these monsters' outfits:\n" -- you can change, but only if you know how to [ up until the : ]
	singularMessage = "You can currently use this monster's outfit:\n" -- same as above


	for i, a in pairs(outfits) do
		if getPlayerStorageValue(cid, a.storageValue) == a.needed then
			table.insert(creatures, a.monster)
		end
	end

	if #creatures == 0 then
		doPlayerSendCancel(cid, config.cancelMessage)
		return 1
	end

	if #creatures > 0 then
		for i=1, #creatures do
			if i == #creatures-1 then
				message = message .. "" .. creatures[i] .. " and "
			elseif #creatures == i then
				message = message  .. "" .. creatures[i] .. "."
			elseif #creatures > 1 then
				message = message .. "" .. creatures[i] .. ", "
			end
		end
	elseif #creatures == 1 then
		message = singularMessage .. "" .. creatures .. "."
	end

	doShowTextDialog(cid, config.itemRead, message)
	return 1
end


Add in talkactions.xml
Code:
	<talkaction words="!outfits;/outfits" event="script" value="outfits.lua"/>
	<talkaction words="!outfit;/outfit" event="script" value="outfit.lua"/>


I can post up screens shots of "how this works" if anyone wants, but it is fairly easy to understand what this does.

Please post any bugs found while using this script, it's been tested, but I can always over look something.

Also post up anything you'd like to be added to the script, or ways for the script to be improved or shorten. First thing I can think of is the character saying something when he changes the outfit.

I can also post up the script of it including all monsters, but I felt like this is a cleaner, and shorter script than doing that. Also have the same script, but instead of changing into a monster outfit, you change into the look type of an item.
 
My friend... YOU ARE A GENIOUS!!!!

Dude i have been looking for something like this about 1/2 years... I love you!!! (no gay) really, love you!

You got my gratitude and a +rep if you want it...

LOVE YOU MEN, I LOVE YOU!!! <3 ahhahahahahhaha
 
I just get masseges like : You can't use this outfit."
Ingame I spoke like this: !outfit mummy
 
I just get masseges like : You can't use this outfit."
Ingame I spoke like this: !outfit mummy

This is because your character doesn't have the storage value to actually use the outfit.

The script doesn't automatically give you access to the outfits, thats the whole point of it using storage values.

Just set an item for on use to give you the storage value to the outfit you want.

example

data\actions\scripts\mummydoll.lua

Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)
		doCreatureSay(cid, "You have gained the mummy outfit!", TALKTYPE_ORANGE_1)
		setPlayerStorageValue(cid, 1235, 1)
		
		
		doSendMagicEffect(getCreaturePosition(cid), CONST_ME_HOLYDAMAGE)
	end

and in actions.xml put this

Code:
<action itemid="11201" event="script" value="mummydoll.lua"/>


Item 11201 is a mummy doll.

When you use the mummy doll, or any other player does, it will grant them access to use the mummy doll.

That script was made as a quick example of how this works, as a test. (the mummy doll one)

Try adding that, and get back to me if it is working or not. After you add in that script, and use the mummy doll, your character should be able to put on the mummy outfit.
 
very good script but a question, as I can add more
monster outfits?

Yes, that is why I even added the template of how to add in more monsters in the script itself.

For outfit, this is the template:

The monster, the id of the outfit, the storage key and the storage value that you need to use it, and the effect

Example:

Code:
{monster = "Grim Reaper", id = 300, storageValue = 1234, needed = 1, effect = 17}

For outfits it is just this:

The monster, the storage key and the storage value that you need to use it

Example:

Code:
{monster = "Grim Reaper", storageValue = 1234, needed = 1}


For you to add in a new monster, you'd have to write in the monster name where it says monster equals... then the ID of the monster... and a new unused storage value..



And not to be mean, but guys at least try to read through the script first, and not just copy and paste.
 
can i change the colors of my outfit?

This was intended for use for monster outfits, which the colours can't be changed.

Dwarf, Elf, Demon, Frog, the barbarians, and butterflys should be set in the outfits.xml, and you shouldn't use these scripts for it because they weren't intended to work with them.
 
Back
Top