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

Solved TFS 1.1 /looktype command

Shadow Dan

Sh4dowDan
Joined
Jun 5, 2010
Messages
344
Reaction score
90
Location
Poland
It is not supporting names of looktype, just numbers like /looktype 122
Can anyone upgrade this script to work with an example: /looktype demon

After writing "/looktype demon" there is an error:
Code:
Lua Script Error: [TalkAction Interface]
data/talkactions/scripts/looktype.lua:onSay
data/talkactions/scripts/looktype.lua:7: attempt to compare number with nil
stack traceback:
        [C]: in function '__le'
        data/talkactions/scripts/looktype.lua:7: in function <data/talkactions/scripts/looktype.lua:1>
Script:
Code:
function onSay(player, words, param)
    if not player:getGroup():getAccess() then
        return true
    end

    local lookType = tonumber(param)
    if lookType >= 0 and lookType ~= 1 and lookType ~= 135 and lookType ~= 411 and lookType ~= 415 and lookType ~= 424 and (lookType <= 160 or lookType >= 192) and lookType ~= 439 and lookType ~= 440 and lookType ~= 468 and lookType ~= 469 and (lookType < 474 or lookType > 485) and lookType ~= 501 and lookType ~= 518 and lookType ~= 519 and lookType ~= 520 and lookType ~= 524 and lookType ~= 525 and lookType ~= 536 and lookType ~= 543 and lookType ~= 549 and lookType ~= 576 and lookType ~= 581 and lookType ~= 582 and lookType <= 595 then
        local playerOutfit = player:getOutfit()
        playerOutfit.lookType = lookType
        player:setOutfit(playerOutfit)
    else
        player:sendCancelMessage("A look type with that id does not exist.")
    end
    return false
end

Working example for older TFS versions:
Code:
local function checkType(value)
    return not (
        value <= 1 or
        value == 135 or
        (value > 160 and value < 192) or
        value == 411 or
        value == 415 or
        value == 424 or
        (value > 438 and value < 441) or
        (value > 466 and value < 470) or
        value == 474 or
        value == 485 or
        value == 501 or
        value > 590
    )
end

function onSay(cid, words, param, channel)
    if(param == '') then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Command param required.")
        return true
    end

    local t, pid = string.explode(param, ","), cid
    if(t[2]) then
        pid = getPlayerByNameWildcard(t[2])
        if(not pid or (isPlayerGhost(pid) and getPlayerGhostAccess(pid) > getPlayerGhostAccess(cid))) then
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Player " .. t[2] .. " not found.")
            return true
        end
    end

    local period, tmp = -1, tonumber(t[3])
    if(t[3] and tmp) then
        period = tmp
    end

    if(not isNumeric(t[1])) then
        if(getMonsterInfo(t[1])) then
            doSetMonsterOutfit(pid, t[1], period)
        else
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Such outfit does not exist.")
        end

        return true
    end

    t[1] = tonumber(t[1])
    if(not checkType(t[1])) then
        local item = getItemInfo(t[1])
        if(item) then
            doSetItemOutfit(pid, t[1], period)
            return true
        end

        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Such outfit does not exist.")
        return true
    end

    local tmp = getCreatureOutfit(pid)
    tmp.lookType = t[1]

    if(t[3]) then
        t[3] = tonumber(t[3])
        if(checkType(t[3])) then
            tmp.lookMount = t[3]
        end
    end

    doCreatureChangeOutfit(pid, tmp)
    return true
end

Problem solved, here is script made by Limos:
Code:
function onSay(player, words, param)
     if not player:getGroup():getAccess() then
         return true
     end

     local lookType = tonumber(param)
     if not lookType then
         lookType = MonsterType(param) and MonsterType(param):getOutfit().lookType
         if not lookType then
             player:sendCancelMessage("A monster with that name does not exist.")
             return false
         end
     end
     if lookType >= 0 and lookType ~= 1 and lookType ~= 135 and lookType ~= 411 and lookType ~= 415 and lookType ~= 424 and (lookType <= 160 or lookType >= 192) and lookType ~= 439 and lookType ~= 440 and lookType ~= 468 and lookType ~= 469 and (lookType < 474 or lookType > 485) and lookType ~= 501 and lookType ~= 518 and lookType ~= 519 and lookType ~= 520 and lookType ~= 524 and lookType ~= 525 and lookType ~= 536 and lookType ~= 543 and lookType ~= 549 and lookType ~= 576 and lookType ~= 581 and lookType ~= 582 and lookType <= 595 then
         local playerOutfit = player:getOutfit()
         playerOutfit.lookType = lookType
         player:setOutfit(playerOutfit)
     else
         player:sendCancelMessage("A look type with that id does not exist.")
     end
     return false
end
 
Last edited:
It is but i have no idea how to switch from items to monsters
I was working on 8.6 client till now and for 10.41 i need some tips before i get started.
Anyone can help?

chameleon.lua
Code:
local condition = Condition(CONDITION_OUTFIT, CONDITIONID_COMBAT)
condition:setTicks(-1)

function onSay(player, words, param)
    if not player:getGroup():getAccess() then
        return true
    end

    if player:getAccountType() < ACCOUNT_TYPE_GOD then
        return false
    end

    local itemType = ItemType(param)
    if itemType:getId() == 0 then
        itemType = ItemType(tonumber(param))
        if itemType:getId() == 0 then
            player:sendCancelMessage("There is no item with that id or name.")
            return false
        end
    end

    condition:setOutfit(itemType:getId())
    player:addCondition(condition)
    return false
end
 
Code:
function onSay(player, words, param)
     if not player:getGroup():getAccess() then
         return true
     end

     local lookType = tonumber(param)
     if not lookType then
         lookType = MonsterType(param) and MonsterType(param):getOutfit().lookType
         if not lookType then
             player:sendCancelMessage("A monster with that name does not exist.")
             return false
         end
     end
     if lookType >= 0 and lookType ~= 1 and lookType ~= 135 and lookType ~= 411 and lookType ~= 415 and lookType ~= 424 and (lookType <= 160 or lookType >= 192) and lookType ~= 439 and lookType ~= 440 and lookType ~= 468 and lookType ~= 469 and (lookType < 474 or lookType > 485) and lookType ~= 501 and lookType ~= 518 and lookType ~= 519 and lookType ~= 520 and lookType ~= 524 and lookType ~= 525 and lookType ~= 536 and lookType ~= 543 and lookType ~= 549 and lookType ~= 576 and lookType ~= 581 and lookType ~= 582 and lookType <= 595 then
         local playerOutfit = player:getOutfit()
         playerOutfit.lookType = lookType
         player:setOutfit(playerOutfit)
     else
         player:sendCancelMessage("A look type with that id does not exist.")
     end
     return false
end
 
Also added name, so you can also set the looktype to other people.
Code:
/looktype id, playername
/looktype monstername, playername
Code:
function onSay(player, words, param)
     if not player:getGroup():getAccess() then
         return true
     end

     local t = param:split(",")
     local lookType = tonumber(t[1])
     if not lookType then
         lookType = MonsterType(t[1]) and MonsterType(t[1]):getOutfit().lookType
         if not lookType then
             player:sendCancelMessage("A monster with that name does not exist.")
             return false
         end
     end
     if t[2] then
         playerx, player = player, Player(t[2]:gsub("^%s*(.-)%s*$", "%1"))
         if not player then
             playerx:sendCancelMessage("A player with that name does not exist or is not online.")
             return false
         end
     end
     if lookType >= 0 and lookType ~= 1 and lookType ~= 135 and lookType ~= 411 and lookType ~= 415 and lookType ~= 424 and (lookType <= 160 or lookType >= 192) and lookType ~= 439 and lookType ~= 440 and lookType ~= 468 and lookType ~= 469 and (lookType < 474 or lookType > 485) and lookType ~= 501 and lookType ~= 518 and lookType ~= 519 and lookType ~= 520 and lookType ~= 524 and lookType ~= 525 and lookType ~= 536 and lookType ~= 543 and lookType ~= 549 and lookType ~= 576 and lookType ~= 581 and lookType ~= 582 and lookType <= 595 then
         local playerOutfit = player:getOutfit()
         playerOutfit.lookType = lookType
         player:setOutfit(playerOutfit)
     else
         player = playerx or player
         player:sendCancelMessage("A look type with that id does not exist.")
     end
     return false
end
 
Back
Top