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
data\talkactions\scripts\outfits.lua
Add in talkactions.xml
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.
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.