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

Lua Script Convertion from TFS 0.4 to TFS 1.2

Lava Titan

Developer
Joined
Jul 25, 2009
Messages
1,551
Solutions
1
Reaction score
88
Location
Portugal
Hey could someone convert this script from TFS 0.4 to TFS 1.2 please?

This is a basic newtype.lua script except that this one works like newtype and chameleon rune at same time, like:

/newtype 274 -> squirrel outfit
/newtype 2160 -> crystal coin outfit

Thanks in Advance :P

Code:
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])
    local disabled = {507, 508, 510, 510}
    if(isInArray(disabled, t[1])) then
        return true
    end
  
    if(t[1] <= 1 or t[1] == 135 or t[1] == 453 or t[1] == 542 or (t[1] > 160 and t[1] < 192) or t[1] > 573) 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]

    doCreatureChangeOutfit(pid, tmp)
    return true
end
 
Code:
function onSay(cid, words, param)
     local player = Player(cid)
     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
 
EDIT
Sorry i just reloaded ur answer wasnt there.
and how is that ? i posted 1 min before ur, and ur post is still 1ST.

----------------------------------------

1ST add thoses function to your lib.lua

PHP:
function string.explode(inputstr, sep)
        if sep == nil then
                sep = "%s"
        end
        local t={} ; i=1
        for str in string.gmatch(inputstr, "([^"..sep.."]+)") do
                t[i] = str
                i = i + 1
        end
        return t
end


function isNumeric(foo)
    foo = tonumber(foo)
    return 'number' == type(foo)
end


function getMonsterInfo( param )
    local target = Creature(param)
    if target == nil then
        return false
    end
    return target
end



function getItemInfo( param )
    local itemType = ItemType( param )
    if itemType:getId() == 0 then
        itemType = ItemType(tonumber( param ))
        if itemType:getId() == 0 then
            return false
        end
    end
    return true
end
 
Last edited:
Code:
function onSay(cid, words, param)
     local player = Player(cid)
     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

@Techrlz This one doesn't work for items, at least I tried /newtype 2160 and it said outfit does not exist.


@sailorv5 you mean if I add those functions to lib, the 0.4 newtype script will work? XD (sorry for asking without test, but I'm on phone, will only be at comp in 30 mins)
 
sorry for double post, but does any1 have updated newtypes for 10.9? if not 10.9 the last one avaible will do the work, ill find the other ones myself and post here later :p
 
Code:
//doSetItemOutfit(cid, item, time)
lua_register(m_luaState, "doSetItemOutfit", LuaScriptInterface::luaSetItemOutfit);
 

Similar threads

Back
Top