• logo_cipsoft
    Nowe serwery zostały otwarte 19 Lut 2025:
    Noctalia (Open PvP) Ignitera (Open PvP) us_logo Xybra (Open PvP)

Lua Functions [LIB] 035-outfits.lua

Status
Zamknięty.

Gandhi

Active User
Dołączył
Sierpień 7, 2013
Posty
80
Liczba reakcji
19
Siema.

Przedstawiam wam mojego ma?ego liba dla leniwych, kt?rym troch? u?atwi ?ycie z manipulacj? outfit?w.

W ?rodku tak?e tabela z nazwami kolor?w, kt?ra mo?e by? wykorzystana do wszystkiego.

Wgra? do data/lib/035-outfits.lua:

[lua]outfits = {}

outfits.random = function (types, addons)
local outfit, sex = {lookType = 128, lookHead = 0, lookBody = 0, lookLegs = 0, lookFeet = 0, lookAddons = (addons and addons or 0)}, tonumber(types)
if(sex ~= nil) then
if(sex == PLAYERSEX_MALE) then
outfit.lookType = choose(maleOutfits)
elseif(sex == PLAYERSEX_FEMALE) then
outfit.lookType = choose(femaleOutfits)
end
elseif(types == 'monsters') then
repeat
outfit.lookType = math.random(2, 365)
until (not table.find(maleOutfits, outfit.lookType) and not table.find(femaleOutfits, outfit.lookType) and not table.find(gamemasterOutfits, outfit.lookType) and not (table.find({126, 127, 135, 267}, outfit.lookType) or (outfit.lookType > 160 and outfit.lookType < 192)))
elseif(types == 'all') then
repeat
outfit.lookType = math.random(2, 367)
until (not table.find({126, 127, 135}, outfit.lookType) and not table.find(gamemasterOutfits, outfit.lookType) and not (outfit.lookType > 160 and outfit.lookType < 192))
end
return outfits.randomizeColors(outfit)
end

outfits.randomColor = function(color) return (color ~= nil and color or math.random(0, 18)) * math.random(COLOR_MODS_MAX) end
outfits.randomizeColors = function (outfit, color)
outfit.lookHead = outfits.randomColor(color)
outfit.lookBody = outfits.randomColor(color)
outfit.lookLegs = outfits.randomColor(color)
outfit.lookFeet = outfits.randomColor(color)
return outfit
end

outfits.serialize = function (outfit)
return '{lookType='..outfit.lookType..', lookHead='..outfit.lookHead..', lookBody='..outfit.lookBody..', lookLegs='..outfit.lookLegs..', lookFeet='..outfit.lookFeet..', lookAddons='..outfit.lookAddons..(type(outfit.lookTypeEx) ~= nil and (', lookTypeEx='..outfit.lookTypeEx) or '')..'}'
end

outfits.unserialize = function (str)
return loadstring('return '..str)()
end

[/lua]
 
Status
Zamknięty.
Do góry