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

wear item and get outfit

thokito

New Member
Joined
Aug 11, 2011
Messages
19
Reaction score
0
I would like to improve this script and I'm not getting it.
This script works like this: you place an item on your arrows and get an outfit.
what I need is that when the player enters pz or changes outfit colors, the original outfit is restored.

Lua:
function onEquip(cid, item, slot)
    local cfg = {
        [128] = 369,
        [136] = 370,
        [129] = 371,
        [130] = 373,
        [131] = 375,
        [132] = 377,
        [133] = 379,
        [134] = 381,
        [135] = 371,
        [137] = 372,
        [138] = 374,
        [139] = 376,
        [140] = 378,
        [141] = 380,
        [142] = 382,
        [143] = 383,
        [144] = 385,
        [145] = 387,
        [146] = 389,
        [147] = 384,
        [148] = 386,
        [149] = 388,
        [150] = 390,
        [151] = 391,
        [152] = 368,
        [153] = 395,
        [154] = 397,
        [155] = 392,
        [156] = 394,
        [157] = 396,
        [158] = 398,
        [366] = 414,
        [367] = 413,
        [335] = 411,
        [336] = 412,
        [324] = 410,
        [325] = 409,
        [288] = 408,
        [289] = 407,
        [278] = 405,
        [279] = 406,
        [268] = 401,
        [269] = 402,
        [270] = 404,
        [273] = 403,
        [251] = 399,
        [252] = 400,
    }
    --[[
        [128] = 389
        [looktype current outfit] = looktype new outfit
    ]]

    if getTilePzInfo(getPlayerPosition (cid)) then
        print('pz')
        doPlayerSendCancel(cid, "Você não pode equipar esse item no PZ.")
        return
    end

    local p = getCreatureOutfit(cid)
    local looktype = {
        lookType = cfg[p.lookType],
        lookHead = p.lookHead,
        lookBody = p.lookBody,
        lookLegs = p.lookLegs,
        lookFeet = p.lookFeet,
        lookAddons = p.lookAddons
    }

    if cfg[p.lookType] ~= nil then 
        doSetCreatureOutfit(cid, looktype, -1)
    end

    return true
end
 
When changing the outfit for the first time (when wearing the item) you can set a storage where the value is original outfit lookType,
and later you can use the following creaturescript to check if player is in PZ.

Lua:
local config = {
    storageKey = 131214
}
function onThink(cid, interval)
    local originalOutfit = tonumber(getCreatureStorage(cid, config.storageKey))
    if not originalOutfit or originalOutfit <= 0 then
        return true
    end

    if getTileInfo(getCreaturePosition(cid)).protection then
        local o = getCreatureOutfit(cid)
        o.lookType = originalOutfit
        doCreatureChangeOutfit(cid, o)
        doCreatureSetStorage(cid, config.storageKey, 0)
    end
    return true
end
 
When changing the outfit for the first time (when wearing the item) you can set a storage where the value is original outfit lookType,
and later you can use the following creaturescript to check if player is in PZ.

Lua:
local config = {
    storageKey = 131214
}
function onThink(cid, interval)
    local originalOutfit = tonumber(getCreatureStorage(cid, config.storageKey))
    if not originalOutfit or originalOutfit <= 0 then
        return true
    end

    if getTileInfo(getCreaturePosition(cid)).protection then
        local o = getCreatureOutfit(cid)
        o.lookType = originalOutfit
        doCreatureChangeOutfit(cid, o)
        doCreatureSetStorage(cid, config.storageKey, 0)
    end
    return true
end
where do i use this cod?
 
where do i use this cod?
creaturescripts.xml
XML:
<event type="think" name="outfitCheck" event="script" value="outfitCheck.lua"/>

creaturescripts/scripts/login.lua
Lua:
registerCreatureEvent(cid, 'outfitCheck')

creaturescripts/scripts/outfitCheck.lua
Lua:
local config = {
    storageKey = 131214
}
function onThink(cid, interval)
    local originalOutfit = tonumber(getCreatureStorage(cid, config.storageKey))
    if not originalOutfit or originalOutfit <= 0 then
        return true
    end
    if getTileInfo(getCreaturePosition(cid)).protection then
        local o = getCreatureOutfit(cid)
        o.lookType = originalOutfit
        doCreatureChangeOutfit(cid, o)
        doCreatureSetStorage(cid, config.storageKey, 0)
    end
    return true
end
 
did nothing :(
creaturescripts.xml
XML:
<event type="think" name="outfitCheck" event="script" value="outfitCheck.lua"/>

creaturescripts/scripts/login.lua
Lua:
registerCreatureEvent(cid, 'outfitCheck')

creaturescripts/scripts/outfitCheck.lua
Lua:
local config = {
    storageKey = 131214
}
function onThink(cid, interval)
    local originalOutfit = tonumber(getCreatureStorage(cid, config.storageKey))
    if not originalOutfit or originalOutfit <= 0 then
        return true
    end
    if getTileInfo(getCreaturePosition(cid)).protection then
        local o = getCreatureOutfit(cid)
        o.lookType = originalOutfit
        doCreatureChangeOutfit(cid, o)
        doCreatureSetStorage(cid, config.storageKey, 0)
    end
    return true
end
Post automatically merged:

up?
 
Last edited:
Back
Top