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

TFS 1.X+ Automatic Looktype Changer

Lava Titan

Developer
Joined
Jul 25, 2009
Messages
1,529
Solutions
1
Reaction score
85
Location
Portugal
heey <3

ok so, I'm working on making monsters for my server and obviously I don't know how every monster look-type looks like, normally I change all look-types by hand like

/newtype 1
/newtype 2
/newtype 3
/newtype 4

so I thought, why not make a script that changes these automatically, my issue is that the script stops when it reachs an invalid look-type

How can I make the script stop only when it reach look-type 367 but still avoid invalid look-types?

Lua:
local invalidTypes = {
    1, 135, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173,
    174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188,
    189, 190, 191
}

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

local function changeLooktype(param)
    local lookType = tonumber(param)
    if lookType >= 0 and lookType < 368 and not table.contains(invalidTypes, lookType) then
        local playerOutfit = player:getOutfit()
        playerOutfit.lookType = lookType
        player:setOutfit(playerOutfit)
        addEvent(changeLooktype, 1000, param + 1)
    else
        player:sendCancelMessage("A look type with that id does not exist.")
    end
end

    addEvent(changeLooktype, 1000, param + 1)
return true
end

thanks in advance <3
 
Solution
E
maybe something like this?
Lua:
-- keep it ordered
local invalidTypes = {
    1, 135, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173,
    174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188,
    189, 190, 191, 411, 415, 424, 439, 440, 468, 469, 474, 475, 476, 477, 478,
    479, 480, 481, 482, 483, 484, 485, 501, 518, 519, 520, 524, 525, 536, 543,
    549, 576, 581, 582, 597, 616, 623, 625, 638, 639, 640, 641, 642, 643, 645,
    646, 652, 653, 654, 655, 656, 657, 658, 659, 660, 661, 662, 663, 700, 701,
    702, 703, 704, 705, 706, 707, 708, 709, 710, 711, 713, 715, 718, 719, 722,
    723, 737, 741, 742, 743, 744, 748, 751, 752, 753, 754, 755, 756, 757, 758,
    764, 765, 766, 767, 768, 769, 770, 771...
maybe something like this?
Lua:
-- keep it ordered
local invalidTypes = {
    1, 135, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173,
    174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188,
    189, 190, 191, 411, 415, 424, 439, 440, 468, 469, 474, 475, 476, 477, 478,
    479, 480, 481, 482, 483, 484, 485, 501, 518, 519, 520, 524, 525, 536, 543,
    549, 576, 581, 582, 597, 616, 623, 625, 638, 639, 640, 641, 642, 643, 645,
    646, 652, 653, 654, 655, 656, 657, 658, 659, 660, 661, 662, 663, 700, 701,
    702, 703, 704, 705, 706, 707, 708, 709, 710, 711, 713, 715, 718, 719, 722,
    723, 737, 741, 742, 743, 744, 748, 751, 752, 753, 754, 755, 756, 757, 758,
    764, 765, 766, 767, 768, 769, 770, 771, 772, 773, 774, 775, 776, 777, 778,
    779, 780, 781, 782, 783, 784, 785, 786, 787, 788, 789, 790, 791, 792, 793,
    794, 795, 796, 797, 798, 798, 800, 801, 802, 803, 804, 805, 806, 807, 808,
    809, 810, 811, 812, 813, 814, 815, 816, 817, 818, 819, 820, 821, 822, 823,
    824, 825, 826, 827, 828, 829, 830, 831, 832, 833, 834, 835, 836, 837, 838,
    839, 840, 841, 861, 844, 845, 846, 847, 871, 872, 880, 891, 892, 893, 894,
    895, 896, 897, 898, 917, 930, 941, 942, 946, 953, 954, 995, 996, 997, 998,
    999, 1000, 1001, 1002, 1003, 1004, 1005, 1006, 1007, 1008, 1009, 1010, 1012,
    1014, 1015, 1016, 1022, 1028, 1074, 1075, 1080, 1081, 1082, 1083, 1084, 1085,
    1086, 1087, 1089, 1090, 1096, 1097, 1098, 1099, 1100, 1107, 1108, 1123, 1124,
    1125, 1126, 1129, 1130, 1131, 1132, 1140, 1141, 1145, 1153, 1154, 1155, 1156,
    1160, 1170, 1171, 1172, 1176, 1177, 1178, 1182, 1194, 1195, 1196, 1198, 1215,
    1216, 1218, 1219, 1222, 1223, 1225, 1226, 1227, 1228, 1235, 1236, 1237, 1237,
    1239, 1240, 1241, 1242, 1250, 1254, 1262, 1263, 1267, 1273, 1274
}

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

local function changeLooktype(param)
    local lookType = tonumber(param)
    if lookType >= 0 and lookType < 1286 and not table.contains(invalidTypes, lookType) then
        local playerOutfit = player:getOutfit()
        playerOutfit.lookType = lookType
        player:setOutfit(playerOutfit)
        local nextLook = lookType + 1
        addEvent(changeLooktype, 1000, nextLook and not table.contains(invalidTypes, nextLook))
    else
        player:sendCancelMessage("A look type with that id does not exist.")
    end
end
    addEvent(changeLooktype, 1000, nextLook and not table.contains(invalidTypes, nextLook))
    return false
end

or even better just use object builder and you can see them easily:
2019-12-02 10_38_03-Window.png
 
Solution
Back
Top