MA
action

TFS 1.X Rainbow Outfit

Por Marco Oliveira, 10 de fev. de 2016 em Actions e Talkactions

2
1.4k
10 de fevereiro de 2016 às 21:42

Em talkactions/talkactions.xml:

<talkaction words="!rainbow" separator=" " script="rainbowoutfit.lua"/>

Em talkactions/scripts crie um arquivo chamado rainbowoutfit.lua dentro dele coloque:

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

Em globalevents/globalevents.xml:

<globalevent name="Rainbow" interval="500" script="others/rainbow_outfit.lua"/>

Em globalevents/scripts/others crie um arquivo chamado rainbow_outfit.lua:

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
SkymagnumS
12 de fevereiro de 2016 às 01:00

Nossa, tu criou um onThink pra checar entre todos os players online quem tem a storage ? wtf '-', era so criar um event dentro da talkaction, anyway ficou legal até.