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

[movement] add StepOut funtion to this movement

Crixpx

New Member
Joined
Jan 11, 2015
Messages
70
Reaction score
3
hello :D
I have a problem with this script. I need to add the function to the exit of the tile I return to the outfit I had when I step on it

is in TFS 0.4

Can somebody help me

this is the script

Code:
local female = {lookType = 126, lookHead = 79, lookBody = 91, lookLegs = 91, lookFeet = 91, lookTypeEx = 0, lookAddons = 3}

local male = {lookType = 127, lookHead = 86, lookBody = 86, lookLegs = 86, lookFeet = 86, lookTypeEx = 0, lookAddons = 3}


function onStepIn(cid, item, pos)

if isPlayer(cid) == TRUE then

if getPlayerSex(cid) == 0 then

doCreatureChangeOutfit(cid, female)

else

doCreatureChangeOutfit(cid, male)

end 

doSendMagicEffect(getThingPos(cid), 29)

doSendAnimatedText(getPlayerPosition(cid),"Wooaahh!", math.random(01,255))
end

return TRUE

end


thanks :D
 
Solution
For 0.4:
Code:
local female = createConditionObject(CONDITION_OUTFIT)
   setConditionParam(female, CONDITION_PARAM_TICKS, -1)
    addOutfitCondition(female, {lookType = 126, lookHead = 79, lookBody = 91, lookLegs = 91, lookFeet = 91, lookTypeEx = 0, lookAddons = 3}) -- female
   
local male = createConditionObject(CONDITION_OUTFIT)
    setConditionParam(male, CONDITION_PARAM_TICKS, -1)
    addOutfitCondition(male, {lookType = 127, lookHead = 86, lookBody = 86, lookLegs = 86, lookFeet = 86, lookTypeEx = 0, lookAddons = 3}) -- male

function onStepIn(cid, item, pos)
    if isPlayer(cid) and getCreatureCondition(cid, CONDITION_OUTFIT) == false then
        if getPlayerSex(cid) == 0 then
            doAddCondition(cid, female)
        elseif...
Code:
local female = {lookType = 126, lookHead = 79, lookBody = 91, lookLegs = 91, lookFeet = 91, lookTypeEx = 0, lookAddons = 3}
local male   = {lookType = 127, lookHead = 86, lookBody = 86, lookLegs = 86, lookFeet = 86, lookTypeEx = 0, lookAddons = 3}

local savedOutfits = {}

function onStepIn(cid, item, pos)
    if isPlayer(cid) then
        savedOutfits[getPlayerGUID(cid)] = getCreatureOutfit(cid)
        if getPlayerSex(cid) == PLAYERSEX_FEMALE then
            doCreatureChangeOutfit(cid, female)
        else
            doCreatureChangeOutfit(cid, male)
        end
        doSendMagicEffect(pos, CONST_ME_FIREWORK_YELLOW)
        doSendAnimatedText(pos, "Wooaahh!", math.random(255))
    end
    return true
end

function onStepOut(cid, item, pos)
    if isPlayer(cid) then
        local tmp = savedOutfits[getPlayerGUID(cid)]
        if tmp then
            doCreatureChangeOutfit(cid, tmp)
        end
    end
    return true
end
keep them in the same file and register stepIn/stepOut to the same file
 
It does not work :C
i have add
Code:
    <movevent type="StepIn" itemid="4820-4831" event="script" value="script.lua"/>
    <movevent type="stepOut" itemid="4820-4831" event="script" value="script.lua"/>
 
It does not work :C
i have add
Code:
    <movevent type="StepIn" itemid="4820-4831" event="script" value="script.lua"/>
    <movevent type="stepOut" itemid="4820-4831" event="script" value="script.lua"/>
well what doesn't work about it?
is there any errors?
 
It does not work :C
i have add
Code:
    <movevent type="StepIn" itemid="4820-4831" event="script" value="script.lua"/>
    <movevent type="stepOut" itemid="4820-4831" event="script" value="script.lua"/>
just realized you have an error in the 2nd line
it's StepOut not stepOut
 
yes If but when leaving the tile does not return my original otufit
Code:
local female = {lookType = 126, lookHead = 79, lookBody = 91, lookLegs = 91, lookFeet = 91, lookTypeEx = 0, lookAddons = 3}
local male   = {lookType = 127, lookHead = 86, lookBody = 86, lookLegs = 86, lookFeet = 86, lookTypeEx = 0, lookAddons = 3}

local savedOutfits = {}

function onStepIn(cid, item, pos)
    if isPlayer(cid) then
        savedOutfits[getPlayerGUID(cid)] = getCreatureOutfit(cid)
        if getPlayerSex(cid) == PLAYERSEX_FEMALE then
            doCreatureChangeOutfit(cid, female)
        else
            doCreatureChangeOutfit(cid, male)
        end
        doSendMagicEffect(pos, CONST_ME_FIREWORK_YELLOW)
        doSendAnimatedText(pos, "Wooaahh!", math.random(255))
    end
    return true
end

function onStepOut(cid, item, pos)
    print('sex')
    if isPlayer(cid) then
        local tmp = savedOutfits[getPlayerGUID(cid)]
        print(tmp)
        if tmp then
            doCreatureChangeOutfit(cid, tmp)
            savedOutfits[getPlayerGUID(cid)] = nil
        end
    end
    return true
end
tell me what this prints to your console
 
source.gif
 
Code:
local outfit = {}
outfit[1] = createConditionObject(CONDITION_OUTFIT)
    setConditionParam(outfit[1], CONDITION_PARAM_TICKS, -1)
    setConditionParam(outfit[1], CONDITION_PARAM_SUBID, 12345)
    addOutfitCondition(outfit[1], 0, 126, 79, 91, 91, 91) -- female
  
outfit[2] = createConditionObject(CONDITION_OUTFIT)
    setConditionParam(outfit[2], CONDITION_PARAM_TICKS, -1)
    setConditionParam(outfit[2], CONDITION_PARAM_SUBID, 12345)  
    addOutfitCondition(outfit[2], 0, 127, 86, 86, 86, 86) -- male

function onStepIn(cid, item, pos)
    if isPlayer(cid) then
        doAddCondition(cid, outfit[(getPlayerSex(cid) + 1)])
        doSendMagicEffect(pos, CONST_ME_FIREWORK_YELLOW)
        doSendAnimatedText(pos, "Wooaahh!", math.random(255))
    end
    return true
end

function onStepOut(cid, item, pos)
    return doRemoveCondition(cid, CONDITION_OUTFIT, 12345)
end


@edit
Don't test scripts as GM.

UWe1QMZ.jpg
 
I found few old TFS weren't able to handle subid in condition_outfit, so, use this:

For 0.3: (for 0.4 use: this)
Code:
<movevent type="StepIn" itemid="40000" event="script" value="Tile.lua" />
<movevent type="StepOut" itemid="40000" event="script" value="Tile.lua" />

Code:
local female = createConditionObject(CONDITION_OUTFIT)
    setConditionParam(female, CONDITION_PARAM_TICKS, -1)
    addOutfitCondition(female, 0, 126, 79, 91, 91, 91) -- female
 
local male = createConditionObject(CONDITION_OUTFIT)
    setConditionParam(male, CONDITION_PARAM_TICKS, -1)
    addOutfitCondition(male, 0, 127, 86, 86, 86, 86) -- male

function onStepIn(cid, item, pos)
    if isPlayer(cid) and getCreatureCondition(cid, CONDITION_OUTFIT) == false then
        if getPlayerSex(cid) == 0 then
            doAddCondition(cid, female)
        elseif getPlayerSex(cid) == 1 then
            doAddCondition(cid, male)
        else
            return false
        end
        doSendMagicEffect(pos, CONST_ME_FIREWORK_YELLOW)
        doSendAnimatedText(pos, "Wooaahh!", math.random(255))
    end
    return true
end

function onStepOut(cid, item, pos)
    return doRemoveCondition(cid, CONDITION_OUTFIT)
end

And like before, dont test as gm.
 
Last edited:
I found few old TFS weren't able to handle subid in condition_outfit, so, use this:

Code:
<movevent type="StepIn" itemid="40000" event="script" value="Tile.lua" />
<movevent type="StepOut" itemid="40000" event="script" value="Tile.lua" />

Code:
local female = createConditionObject(CONDITION_OUTFIT)
    setConditionParam(female, CONDITION_PARAM_TICKS, -1)
    addOutfitCondition(female, 0, 126, 79, 91, 91, 91) -- female
  
local male = createConditionObject(CONDITION_OUTFIT)
    setConditionParam(male, CONDITION_PARAM_TICKS, -1)
    addOutfitCondition(male, 0, 127, 86, 86, 86, 86) -- male

function onStepIn(cid, item, pos)
    if isPlayer(cid) and getCreatureCondition(cid, CONDITION_OUTFIT) == false then
        if getPlayerSex(cid) == 0 then
            doAddCondition(cid, female)
        elseif getPlayerSex(cid) == 1 then
            doAddCondition(cid, male)
        else
            return false
        end
        doSendMagicEffect(pos, CONST_ME_FIREWORK_YELLOW)
        doSendAnimatedText(pos, "Wooaahh!", math.random(255))
    end
    return true
end

function onStepOut(cid, item, pos)
    return doRemoveCondition(cid, CONDITION_OUTFIT)
end

And like before, dont test as gm.

u.u This script hates me ... is tfs 0.4
source.gif
 
For 0.4:
Code:
local female = createConditionObject(CONDITION_OUTFIT)
   setConditionParam(female, CONDITION_PARAM_TICKS, -1)
    addOutfitCondition(female, {lookType = 126, lookHead = 79, lookBody = 91, lookLegs = 91, lookFeet = 91, lookTypeEx = 0, lookAddons = 3}) -- female
   
local male = createConditionObject(CONDITION_OUTFIT)
    setConditionParam(male, CONDITION_PARAM_TICKS, -1)
    addOutfitCondition(male, {lookType = 127, lookHead = 86, lookBody = 86, lookLegs = 86, lookFeet = 86, lookTypeEx = 0, lookAddons = 3}) -- male

function onStepIn(cid, item, pos)
    if isPlayer(cid) and getCreatureCondition(cid, CONDITION_OUTFIT) == false then
        if getPlayerSex(cid) == 0 then
            doAddCondition(cid, female)
        elseif getPlayerSex(cid) == 1 then
            doAddCondition(cid, male)
        else
            return false
        end
        doSendMagicEffect(pos, CONST_ME_FIREWORK_YELLOW)
        doSendAnimatedText(pos, "Wooaahh!", math.random(255))
    end
    return true
end

function onStepOut(cid, item, pos)
    return doRemoveCondition(cid, CONDITION_OUTFIT)
end
 
Solution
For 0.4:
Code:
local female = createConditionObject(CONDITION_OUTFIT)
   setConditionParam(female, CONDITION_PARAM_TICKS, -1)
    addOutfitCondition(female, {lookType = 126, lookHead = 79, lookBody = 91, lookLegs = 91, lookFeet = 91, lookTypeEx = 0, lookAddons = 3}) -- female
  
local male = createConditionObject(CONDITION_OUTFIT)
    setConditionParam(male, CONDITION_PARAM_TICKS, -1)
    addOutfitCondition(male, {lookType = 127, lookHead = 86, lookBody = 86, lookLegs = 86, lookFeet = 86, lookTypeEx = 0, lookAddons = 3}) -- male

function onStepIn(cid, item, pos)
    if isPlayer(cid) and getCreatureCondition(cid, CONDITION_OUTFIT) == false then
        if getPlayerSex(cid) == 0 then
            doAddCondition(cid, female)
        elseif getPlayerSex(cid) == 1 then
            doAddCondition(cid, male)
        else
            return false
        end
        doSendMagicEffect(pos, CONST_ME_FIREWORK_YELLOW)
        doSendAnimatedText(pos, "Wooaahh!", math.random(255))
    end
    return true
end

function onStepOut(cid, item, pos)
    return doRemoveCondition(cid, CONDITION_OUTFIT)
end


<3 <3 omg work!! 100% no error thank you very much SOLVED!!
 
Back
Top