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

TalkAction TFS 1.X rainbow outfit

silveralol

Advanced OT User
Joined
Mar 16, 2010
Messages
1,480
Solutions
9
Reaction score
212
hello, I'm here to release this little script, can be useless to you, but I have fun :p
this script will make the outfits color change every 0.5 second or you can choose the interval
in talkactions/talkactions.xml paste it:
Code:
<talkaction words="!rainbow" separator=" " script="rainbowoutfit.lua"/>
in talkactions/scripts create a new file called rainbowoutfit.lua and paste it:
Code:
function onSay(player, words, param)
    if param == 'on' or param == 'ON' then
        player:setStorageValue(8178237, 1)
        player:sendCancelMessage("rainbow outfit is actived.")
    elseif param == 'off' or param == 'OFF' then
        player:setStorageValue(8178237, 0)
        player:sendCancelMessage("rainbow outfit is disabled.")
    else
        player:sendCancelMessage("wrong parameter, use on or off.")
    end
    return false
end
in globalevents/globalevents.xml paste it: (here is the interval, 500 = 0.5 second, 1000 = 1 second...)
Code:
<globalevent name="Rainbow" interval="500" script="others/rainbow_outfit.lua"/>
in globalevents/scripts/others create a new file called rainbow_outfit.lua and paste it:
Code:
function onThink(interval)
    for _, player in ipairs(Game.getPlayers()) do
        if player:getStorageValue(8178237) == 1 then -- here is the storage to check if is "on" or "off"
            local outfit = player:getOutfit()
            outfit.lookHead = math.random(0, 132)
            outfit.lookBody = math.random(0, 132)
            outfit.lookLegs = math.random(0, 132)
            outfit.lookFeet = math.random(0, 132)
            player:setOutfit(outfit)
            player:getPosition():sendMagicEffect(CONST_ME_MAGIC_GREEN)
        end
    end
    return true
end
 
Last edited:
I don't know about it, then you said about recursion, I'm using it now:
remove the globalevent part, just create the talkaction with this:
Code:
local function rainbow(player)
    if player:getStorageValue(8178237) == 1 then
        local outfit = player:getOutfit()
        outfit.lookHead = math.random(0, 132)
        outfit.lookBody = math.random(0, 132)
        outfit.lookLegs = math.random(0, 132)
        outfit.lookFeet = math.random(0, 132)
        player:setOutfit(outfit)
        player:getPosition():sendMagicEffect(CONST_ME_MAGIC_GREEN)
    else
        return true
    end
    addEvent(rainbow, 500, player)
end
function onSay(player, words, param)
    if param == 'on' or param == 'ON' then
        if player:getStorageValue(8178237) == 1 then
            player:sendCancelMessage("rainbow outfit is already actived.")
            return false
        end
        player:setStorageValue(8178237, 1)
        player:sendCancelMessage("rainbow outfit is actived.")
        rainbow(player)
    elseif param == 'off' or param == 'OFF' then
        player:setStorageValue(8178237, 0)
        player:sendCancelMessage("rainbow outfit is disabled.")
        rainbow(player)
    else
        player:sendCancelMessage("wrong parameter, use on or off.")
    end
    return false
end
 
Last edited:
@silveralol It's not working on my tfs 1.2 :( It simply don't do anything. If i say "!rainbow" it sends the msg of "ON or OFF". Any idea about that?

Try this, already tested and working:
Code:
<talkaction words="!rainbow" script="rainbowoutfit.lua"/>

Code:
local rainbow = {}
local function rainbowPlayer(cid)
    local player = Player(cid)
    if not player then
        return true
    end
    local outfit = player:getOutfit()
    outfit.lookHead, outfit.lookBody, outfit.lookLegs, outfit.lookFeet = math.random(0, 132), math.random(0, 132), math.random(0, 132), math.random(0, 132)
    player:setOutfit(outfit)
    player:getPosition():sendMagicEffect(CONST_ME_MAGIC_GREEN)
    rainbow[cid] = addEvent(rainbowPlayer, 500, cid)
end

function onSay(player, words, param)
    local cid = player:getId()
    if rainbow[cid] == nil then
        rainbow[cid] = addEvent(rainbowPlayer, 500, cid)
        player:sendCancelMessage("Rainbow outfit is now actived.")
    else
        stopEvent(rainbow[cid])
        rainbow[cid] = nil
        player:sendCancelMessage("Rainbow outfit is now disabled.")
    end
    return true
end
 
@Ricardo Tavares Thx dude. I found the bug as coincidence. I'll try your script.

Now I'm trying to Add Random Mounts, but i can't put all the mounts, can u help me?
I was trying to use an array but seems don't work too :c
Code:
function onThink(interval)
    for _, player in ipairs(Game.getPlayers()) do
        if player:getStorageValue(8178237) == 1 then -- here is the storage to check if is "on" or "off"
            local outfit = player:getOutfit()
            outfit.lookHead = math.random(0, 132)
            outfit.lookBody = math.random(0, 132)
            outfit.lookLegs = math.random(0, 132)
            outfit.lookFeet = math.random(0, 132)
            outfit.lookAddons = math.random(0, 3)
            outfit.lookMount = math.random(368, 379) <- I was trying this, but doesn't work good.
            player:setOutfit(outfit)
            player:getPosition():sendMagicEffect(CONST_ME_MAGIC_GREEN)
        end
    end
    return true
end
 
@Ricardo Tavares Thx dude. I found the bug as coincidence. I'll try your script.

Now I'm trying to Add Random Mounts, but i can't put all the mounts, can u help me?
I was trying to use an array but seems don't work too :c
Code:
function onThink(interval)
    for _, player in ipairs(Game.getPlayers()) do
        if player:getStorageValue(8178237) == 1 then -- here is the storage to check if is "on" or "off"
            local outfit = player:getOutfit()
            outfit.lookHead = math.random(0, 132)
            outfit.lookBody = math.random(0, 132)
            outfit.lookLegs = math.random(0, 132)
            outfit.lookFeet = math.random(0, 132)
            outfit.lookAddons = math.random(0, 3)
            outfit.lookMount = math.random(368, 379) <- I was trying this, but doesn't work good.
            player:setOutfit(outfit)
            player:getPosition():sendMagicEffect(CONST_ME_MAGIC_GREEN)
        end
    end
    return true
end
Idk where in TFS 1.X they are but I know they are listed from 1 -> X

So you'd have to do
eg: math.random(1, 30) -- (Idk how many mounts you have in your server)

But pretty much use the mountID's not the clientID's
 
Idk where in TFS 1.X they are but I know they are listed from 1 -> X

So you'd have to do
eg: math.random(1, 30) -- (Idk how many mounts you have in your server)

But pretty much use the mountID's not the clientID's

Code:
<mounts>
    <mount id="1" clientid="368" name="Widow Queen" speed="20" premium="yes" />
</mounts>

So i can "use" something like outfit.lookMountIDs = math.random(1, 100), right? I'll test it.
I Found this on players.cpp
Code:
defaultOutfit.lookMount = currentMount->clientId;
 
Last edited:
Code:
<mounts>
    <mount id="1" clientid="368" name="Widow Queen" speed="20" premium="yes" />
</mounts>

So i can "use" something like outfit.lookMountIDs = math.random(1, 100), right? I'll test it.
I Found this on players.cpp
Code:
defaultOutfit.lookMount = currentMount->clientId;
generally yes, but the '100' would be the max mountID your server supports.

outfit.lookMount = math.random(1, whatever_your_max_mountID_is)
 
Well looks like the method doesn't exist. I tried many times, but still using the cid instead of mountid (no exist) :(
Code:
<mounts>
    <mount id="1" clientid="368" name="Widow Queen" speed="20" premium="yes" />
</mounts>
<mount id="1"
What do you mean it doesn't exist?
You literally posted it.
 
Code:
outfit.lookMount = math.random(1, 10)
try with 10. tell me what happens.

Edit #1
--------
Code:
outfit.lookMount = math.random(1, 10)
try with 10. tell me what happens.

Actually, I bow down and say I'm wrong.
I am most definitely wrong.
I'm actually sorry for not trying it out first.

It uses the creature id's.. not the mount id's.
I'll get something working for you here soon.

Alright.. you just have to add more mounts to the list if I'm missing any.

Code:
local mount_ids = {368, 369, 370, 371, 372, 373, 374, 375, 376, 377, 378, 379, 387, 388, 389, 390, 392, 401, 402, 405, 406, 421, 426, 427, 437, 438, 447, 450, 502, 503, 506, 515}

function onThink(interval)
     for _, player in ipairs(Game.getPlayers()) do
         if player:getStorageValue(8178237) == 1 then
             local outfit = player:getOutfit()
             outfit.lookHead = math.random(0, 132)
             outfit.lookBody = math.random(0, 132)
             outfit.lookLegs = math.random(0, 132)
             outfit.lookFeet = math.random(0, 132)
             outfit.lookAddons = math.random(0, 3)
             local mount_id = math.random(#mount_ids)
             outfit.lookMount = mount_ids[mount_id]
             player:setOutfit(outfit)
             player:getPosition():sendMagicEffect(CONST_ME_MAGIC_GREEN)
         end
     end
     return true
end


Edit #2
-----------

Added in outfits as well.. just in case you wanted to do that as well.
Again.. I'm using 9.6.. so probably lot's of outfits/mounts missing.

Yalaharian outfits can have both addons together.. but they look screwy.. cuz they are only meant to have addon 1 OR addon 2, so I implemented that into the script as well.

Good luck!

zBzhECS.gif

Code:
local mount_ids = {368, 369, 370, 371, 372, 373, 374, 375, 376, 377, 378, 379, 387, 388, 389, 390, 392, 401, 402, 405, 406, 421, 426, 427, 437, 438, 447, 450, 502, 503, 506, 515}
local outfit_ids = {136, 128, 137, 129, 138, 130, 139, 131, 140, 132, 141, 133, 142, 134, 147, 143, 148, 144, 149, 145, 150, 146, 155, 151, 156, 152, 157, 153, 158, 154, 252, 251, 269, 268, 270, 273, 279, 278, 288, 289, 324, 325, 336, 335, 366, 367, 329, 328, 431, 430, 433, 432, 464, 463, 466, 465, 471, 472, 513, 512, 514, 516}

function onThink(interval)
     for _, player in ipairs(Game.getPlayers()) do
         if player:getStorageValue(8178237) == 1 then
             local outfit = player:getOutfit()
             local outfit_id = math.random(#outfit_ids)
             outfit.lookType = outfit_ids[outfit_id]
             outfit.lookHead = math.random(0, 132)
             outfit.lookBody = math.random(0, 132)
             outfit.lookLegs = math.random(0, 132)
             outfit.lookFeet = math.random(0, 132)
             if outfit.lookType == 324 or outfit.lookType == 325 then
                 outfit.lookAddons = math.random(0, 2)
             else
                 outfit.lookAddons = math.random(0, 3)
             end
             local mount_id = math.random(#mount_ids)
             outfit.lookMount = mount_ids[mount_id]
             player:setOutfit(outfit)
             player:getPosition():sendMagicEffect(CONST_ME_MAGIC_GREEN)
         end
     end
     return true
end

0.3.7 code.. in case anyone wants it
Code:
local mount_ids = {368, 369, 370, 371, 372, 373, 374, 375, 376, 377, 378, 379, 387, 388, 389, 390, 392, 401, 402, 405, 406, 421, 426, 427, 437, 438, 447, 450, 502, 503, 506, 515}
local outfit_ids = {136, 128, 137, 129, 138, 130, 139, 131, 140, 132, 141, 133, 142, 134, 147, 143, 148, 144, 149, 145, 150, 146, 155, 151, 156, 152, 157, 153, 158, 154, 252, 251, 269, 268, 270, 273, 279, 278, 288, 289, 324, 325, 336, 335, 366, 367, 329, 328, 431, 430, 433, 432, 464, 463, 466, 465, 471, 472, 513, 512, 514, 516}

function onThink(cid, interval, lastExecution)
     for _, cid in ipairs(getPlayersOnline()) do
         local outfit = getCreatureOutfit(cid)
         local outfit_id = math.random(#outfit_ids)
         outfit.lookType = outfit_ids[outfit_id]
         outfit.lookHead = math.random(0, 132)
         outfit.lookBody = math.random(0, 132)
         outfit.lookLegs = math.random(0, 132)
         outfit.lookFeet = math.random(0, 132)
         if outfit.lookType == 324 or outfit.lookType == 325 then
             outfit.lookAddons = math.random(0, 2)
         else
             outfit.lookAddons = math.random(0, 3)
         end
         local mount_id = math.random(#mount_ids)
         outfit.lookMount = mount_ids[mount_id]
         doCreatureChangeOutfit(cid, outfit)
     end
     return true
end
 
Last edited:
Code:
outfit.lookMount = math.random(1, 10)
try with 10. tell me what happens.

Edit #1
--------


Actually, I bow down and say I'm wrong.
I am most definitely wrong.
I'm actually sorry for not trying it out first.

It uses the creature id's.. not the mount id's.
I'll get something working for you here soon.

Alright.. you just have to add more mounts to the list if I'm missing any.

Code:
local mount_ids = {368, 369, 370, 371, 372, 373, 374, 375, 376, 377, 378, 379, 387, 388, 389, 390, 392, 401, 402, 405, 406, 421, 426, 427, 437, 438, 447, 450, 502, 503, 506, 515}

function onThink(interval)
     for _, player in ipairs(Game.getPlayers()) do
         if player:getStorageValue(8178237) == 1 then
             local outfit = player:getOutfit()
             outfit.lookHead = math.random(0, 132)
             outfit.lookBody = math.random(0, 132)
             outfit.lookLegs = math.random(0, 132)
             outfit.lookFeet = math.random(0, 132)
             outfit.lookAddons = math.random(0, 3)
             local mount_id = math.random(#mount_ids)
             outfit.lookMount = mount_ids[mount_id]
             player:setOutfit(outfit)
             player:getPosition():sendMagicEffect(CONST_ME_MAGIC_GREEN)
         end
     end
     return true
end


Edit #2
-----------

Added in outfits as well.. just in case you wanted to do that as well.
Again.. I'm using 9.6.. so probably lot's of outfits/mounts missing.

Yalaharian outfits can have both addons together.. but they look screwy.. cuz they are only meant to have addon 1 OR addon 2, so I implemented that into the script as well.

Good luck!

zBzhECS.gif

Code:
local mount_ids = {368, 369, 370, 371, 372, 373, 374, 375, 376, 377, 378, 379, 387, 388, 389, 390, 392, 401, 402, 405, 406, 421, 426, 427, 437, 438, 447, 450, 502, 503, 506, 515}
local outfit_ids = {136, 128, 137, 129, 138, 130, 139, 131, 140, 132, 141, 133, 142, 134, 147, 143, 148, 144, 149, 145, 150, 146, 155, 151, 156, 152, 157, 153, 158, 154, 252, 251, 269, 268, 270, 273, 279, 278, 288, 289, 324, 325, 336, 335, 366, 367, 329, 328, 431, 430, 433, 432, 464, 463, 466, 465, 471, 472, 513, 512, 514, 516}

function onThink(interval)
     for _, player in ipairs(Game.getPlayers()) do
         if player:getStorageValue(8178237) == 1 then
             local outfit = player:getOutfit()
             local outfit_id = math.random(#outfit_ids)
             outfit.lookType = outfit_ids[outfit_id]
             outfit.lookHead = math.random(0, 132)
             outfit.lookBody = math.random(0, 132)
             outfit.lookLegs = math.random(0, 132)
             outfit.lookFeet = math.random(0, 132)
             if outfit.lookType == 324 or outfit.lookType == 325 then
                 outfit.lookAddons = math.random(0, 2)
             else
                 outfit.lookAddons = math.random(0, 3)
             end
             local mount_id = math.random(#mount_ids)
             outfit.lookMount = mount_ids[mount_id]
             player:setOutfit(outfit)
             player:getPosition():sendMagicEffect(CONST_ME_MAGIC_GREEN)
         end
     end
     return true
end

0.3.7 code.. in case anyone wants it
Code:
local mount_ids = {368, 369, 370, 371, 372, 373, 374, 375, 376, 377, 378, 379, 387, 388, 389, 390, 392, 401, 402, 405, 406, 421, 426, 427, 437, 438, 447, 450, 502, 503, 506, 515}
local outfit_ids = {136, 128, 137, 129, 138, 130, 139, 131, 140, 132, 141, 133, 142, 134, 147, 143, 148, 144, 149, 145, 150, 146, 155, 151, 156, 152, 157, 153, 158, 154, 252, 251, 269, 268, 270, 273, 279, 278, 288, 289, 324, 325, 336, 335, 366, 367, 329, 328, 431, 430, 433, 432, 464, 463, 466, 465, 471, 472, 513, 512, 514, 516}

function onThink(cid, interval, lastExecution)
     for _, cid in ipairs(getPlayersOnline()) do
         local outfit = getCreatureOutfit(cid)
         local outfit_id = math.random(#outfit_ids)
         outfit.lookType = outfit_ids[outfit_id]
         outfit.lookHead = math.random(0, 132)
         outfit.lookBody = math.random(0, 132)
         outfit.lookLegs = math.random(0, 132)
         outfit.lookFeet = math.random(0, 132)
         if outfit.lookType == 324 or outfit.lookType == 325 then
             outfit.lookAddons = math.random(0, 2)
         else
             outfit.lookAddons = math.random(0, 3)
         end
         local mount_id = math.random(#mount_ids)
         outfit.lookMount = mount_ids[mount_id]
         doCreatureChangeOutfit(cid, outfit)
     end
     return true
end


It's working dude. As i said from start, i was going to need a array with the ids xD.

Thx so much to take your time and make it work.

s2
 
I just added all outfits/mounts until the version 10.96
Features
  • Random Outfits
  • Random Mounts
  • Random Colors for head, body, legs and feet
  • TFS 1.2 (Working 100% without bugs).
  • If someone needs the code for version "0.3.7". You can it find above. Credits: @Xikini
Code:
local mount_ids = {368, 369, 370, 371, 372, 373, 374, 375, 376, 377, 378, 379, 387, 388, 389, 390, 392, 401, 402, 405, 406, 421, 426, 427, 437, 438, 447, 450, 502, 503, 506, 515, 521, 522, 526, 546, 547, 548, 559, 571, 572, 580, 596, 606, 621, 622, 624, 626, 627, 628, 629, 630, 631, 644, 647, 648, 649, 650, 651, 669, 670, 671, 672, 673, 674, 688, 689, 690, 691, 692, 693, 682, 685, 686, 687, 726, 727, 728, 734, 735, 736, 738, 739, 740, 761, 762, 763, 848, 849, 850, 851, 868, 869, 870, 883, 886, 887, 888, 889, 890}
local outfit_ids = {136, 128, 137, 129, 138, 130, 139, 131, 140, 132, 141, 133, 142, 134, 147, 143, 148, 144, 149, 145, 150, 146, 155, 151, 156, 152, 157, 153, 158, 154, 252, 251, 269, 268, 270, 273, 279, 278, 288, 289, 324, 325, 336, 335, 366, 367, 329, 328, 431, 430, 433, 432, 464, 463, 466, 465, 471, 472, 513, 512, 514, 516, 542, 541, 575, 574, 577, 578, 618, 610, 620, 619, 632, 633, 635, 634, 636, 637, 664, 665, 667, 666, 683, 684, 695, 694, 696, 697, 699, 698, 724, 725, 732, 733, 745, 746, 749, 750, 759, 760, 845, 846, 852, 853, 873, 874, 885, 884}

function onThink(interval)
     for _, player in ipairs(Game.getPlayers()) do
         if player:getStorageValue(8178237) == 1 then
             local outfit = player:getOutfit()
             local outfit_id = math.random(#outfit_ids)
             outfit.lookType = outfit_ids[outfit_id]
             outfit.lookHead = math.random(0, 132)
             outfit.lookBody = math.random(0, 132)
             outfit.lookLegs = math.random(0, 132)
             outfit.lookFeet = math.random(0, 132)
             if outfit.lookType == 324 or outfit.lookType == 325 then
                 outfit.lookAddons = math.random(0, 2)
             else
                 outfit.lookAddons = math.random(0, 3)
             end
             local mount_id = math.random(#mount_ids)
             outfit.lookMount = mount_ids[mount_id]
             player:setOutfit(outfit)
             player:getPosition():sendMagicEffect(CONST_ME_MAGIC_GREEN)
         end
     end
     return true
end
Special Thanks
- @silveralol
- @Xikini
 
Great script! My only concern is that I would love if the rainbow automatically stopped when a player logged out (current version it only stops by giving the command in-game !rainbow off).
Anyone wanna help me sort this out for me?
I'm using TFS 1.5.
 
Back
Top