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

pass movement script to action

thokito

New Member
Joined
Aug 11, 2011
Messages
19
Reaction score
0
hello guys, how are you?
I would like to pass a movement script to action.

Explaining how the script works: you put an item in the slot and get another outfit, I would like to click on the item and get the other outfit. would?

function onEquip(cid, item, slot, topos)

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
doPlayerSendCancel(cid,"you cannot change your outfit in a protected area.")
return TRUE
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

function onDeEquip(cid, item, slot)
doRemoveCondition(cid, CONDITION_OUTFIT)
return true
end
Post automatically merged:

up
Post automatically merged:

up
 
Last edited:
Solution
XML:
<action itemid="YOUR_ITEM_ID" event="script" value="YOUR_FILE.lua"/>

Lua:
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
}

function onUse(cid, item, fromPos, itemEx, toPos)
    if...
XML:
<action itemid="YOUR_ITEM_ID" event="script" value="YOUR_FILE.lua"/>

Lua:
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
}

function onUse(cid, item, fromPos, itemEx, toPos)
    if getTilePzInfo(getPlayerPosition(cid)) then
        doPlayerSendCancel(cid, 'you cannot change your outfit in a protected area.')
        return true
    end

    local p = getCreatureOutfit(cid)
    if not cfg[p.lookType] then
        return true
    end

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

    doSetCreatureOutfit(cid, looktype, -1)
    return true
end
 
Solution
nice man, thanks :D
does it work if you click, how do you click again and it goes back to normal?
Lua:
local outfit = {
    [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
}

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

function onUse(cid, item, fromPos, itemEx, toPos)
    if getTilePzInfo(getPlayerPosition(cid)) then
        doPlayerSendCancel(cid, 'you cannot change your outfit in a protected area.')
        return true
    end

    local p = getCreatureOutfit(cid)
    local pLookType = nil
    if outfitTable[p.lookType] then
        pLookType = outfit[p.lookType]
    elseif outfitReverse[p.lookType] then
        pLookType = outfitReverse[p.lookType]
    else
        return true
    end

    local looktype = {
        lookType = pLookType,
        lookHead = p.lookHead,
        lookBody = p.lookBody,
        lookLegs = p.lookLegs,
        lookFeet = p.lookFeet,
        lookAddons = p.lookAddons
    }

    doSetCreatureOutfit(cid, looktype, -1)
    return true
end
 
Lua:
local outfit = {
    [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
}

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

function onUse(cid, item, fromPos, itemEx, toPos)
    if getTilePzInfo(getPlayerPosition(cid)) then
        doPlayerSendCancel(cid, 'you cannot change your outfit in a protected area.')
        return true
    end

    local p = getCreatureOutfit(cid)
    local pLookType = nil
    if outfitTable[p.lookType] then
        pLookType = outfit[p.lookType]
    elseif outfitReverse[p.lookType] then
        pLookType = outfitReverse[p.lookType]
    else
        return true
    end

    local looktype = {
        lookType = pLookType,
        lookHead = p.lookHead,
        lookBody = p.lookBody,
        lookLegs = p.lookLegs,
        lookFeet = p.lookFeet,
        lookAddons = p.lookAddons
    }

    doSetCreatureOutfit(cid, looktype, -1)
    return true
end
the script gave this error

attempt to index global 'outfitTable' (a nil value)
 
the script gave this error

attempt to index global 'outfitTable' (a nil value)

Lua:
local outfitTable = {
    [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
}

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

function onUse(cid, item, fromPos, itemEx, toPos)
    if getTilePzInfo(getPlayerPosition(cid)) then
        doPlayerSendCancel(cid, 'you cannot change your outfit in a protected area.')
        return true
    end

    local p = getCreatureOutfit(cid)
    local pLookType = nil
    if outfitTable[p.lookType] then
        pLookType = outfitTable[p.lookType]
    elseif outfitReverse[p.lookType] then
        pLookType = outfitReverse[p.lookType]
    else
        return true
    end

    local looktype = {
        lookType = pLookType,
        lookHead = p.lookHead,
        lookBody = p.lookBody,
        lookLegs = p.lookLegs,
        lookFeet = p.lookFeet,
        lookAddons = p.lookAddons
    }

    doSetCreatureOutfit(cid, looktype, -1)
    return true
end
 
now it happens that when it changes, the addons do not appear ...
Post automatically merged:

I managed to fix it, thank you very much !! <3 rep +++
Post automatically merged:

how do i use only who has the item?

= / it is happening that, the character drops. the friend clicks and gets the outfit too
 
Last edited:
Back
Top