Post the script you're currently using.
function onUse(cid, item, fromPosition, itemEx, toPosition)
local c = {218}
if doPlayerRemoveItem(cid,2159,1) == TRUE then
local pPos = getPlayerPosition(cid)
doSendMagicEffect(pPos, 31)
doCreatureChangeOutfit(cid, {lookType = c[math.random(#c)]})
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You got a random outfit for 1 Token!")
else
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You need 1 Token!")
end
return TRUE
end
<action itemid="1945" script="Outfit Lever.lua"/>
local t = { -- outfit lookTypes
123, 456, 789
}
local token = 2159
function onUse(cid, item, fromPosition, itemEx, toPosition)
if(not doPlayerRemoveItem(cid, token, 1)) then
return doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You do not have a token."), doSendMagicEffect(getThingPos(cid), CONST_ME_POFF), false
end
doCreatureChangeOutfit(cid, {lookType = t[math.random(#t)]}, -1)
doSendMagicEffect(getThingPos(cid), CONST_ME_MAGIC_BLUE)
doCreatureSay(cid, "Enjoy your new outfit!", TALKTYPE_ORANGE_1)
return true
end
Now i only get debug.. and im using 0.3.6You may need to change: TALKTYPE_MONSTER to TALKTYPE_ORANGE_1 depending on which TFS you're using.LUA:local t = { -- outfit lookTypes 123, 456, 789 } local token = 2159 function onUse(cid, item, fromPosition, itemEx, toPosition) if(not doPlayerRemoveItem(cid, token, 1)) then return doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You do not have a token."), doSendMagicEffect(getThingPos(cid), CONST_ME_POFF), false end doSetCreatureOutfit(cid, {lookType = t[math.random(#t)]}, -1) doSendMagicEffect(getThingPos(cid), CONST_ME_MAGIC_BLUE) -- magic effect doCreatureSay(cid, "Enjoy your new outfit!", TALKTYPE_MONSTER) -- talkType message return true end
Now i only get debug.. and im using 0.3.6
Try it again. Remember to edit the lookTypes!
Letting us know which TFS you use in the first place can save us a lot of trouble.![]()
Try it again. Remember to edit the lookTypes!
Letting us know which TFS you use in the first place can save us a lot of trouble.![]()
Ye, the script works fine, but how can i use the same script but on 2 levers?
<action actionid="1200;1201;" event="script" value="script.lua"/>
local t = {
[1200] = {123}, -- [LEVER_ACTION_ID] = {lookType}
[1201] = {456},
}
local token = 2159
function onUse(cid, item, fromPosition, itemEx, toPosition)
local k = t[item.actionid]
if k then
if(not doPlayerRemoveItem(cid, token, 1)) then
return doPlayerSendCancel(cid, "You do not have a token"), doSendMagicEffect(getThingPos(cid), CONST_ME_POFF), false
end
doSetCreatureOutfit(cid, {lookType = k[1]}, -1)
doSendMagicEffect(getThingPos(cid), CONST_ME_MAGIC_BLUE)
doCreatureSay(cid, "Enjoy your new outfit!", TALKTYPE_ORANGE_1)
end
return true
end
You need to edit the actions.xml:
Here's the script: Remember to edit the lookType...XML:<action actionid="1200;1201;" event="script" value="script.lua"/>
LUA:local t = { [1200] = 123, -- [LEVER_ACTION_ID] = lookType [1201] = 456, } local token = 2159 function onUse(cid, item, fromPosition, itemEx, toPosition) local k = t[item.actionid] if k then if(not doPlayerRemoveItem(cid, token, 1)) then return doPlayerSendCancel(cid, "You do not have a token"), doSendMagicEffect(getThingPos(cid), CONST_ME_POFF), false end doCreatureChangeOutfit(cid, {lookType = k}, -1) doSendMagicEffect(getThingPos(cid), CONST_ME_MAGIC_BLUE) doCreatureSay(cid, "Enjoy your new outfit!", TALKTYPE_ORANGE_1) end return true end
You need to edit the actions.xml:
Here's the script: Remember to edit the lookType...XML:<action actionid="1200;1201;" event="script" value="script.lua"/>
LUA:local t = { [1200] = 123, -- [LEVER_ACTION_ID] = lookType [1201] = 456, } local token = 2159 function onUse(cid, item, fromPosition, itemEx, toPosition) local k = t[item.actionid] if k then if(not doPlayerRemoveItem(cid, token, 1)) then return doPlayerSendCancel(cid, "You do not have a token"), doSendMagicEffect(getThingPos(cid), CONST_ME_POFF), false end doCreatureChangeOutfit(cid, {lookType = k}, -1) doSendMagicEffect(getThingPos(cid), CONST_ME_MAGIC_BLUE) doCreatureSay(cid, "Enjoy your new outfit!", TALKTYPE_ORANGE_1) end return true end
[01/08/2013 18:04:30] [Error - Action Interface]
[01/08/2013 18:04:30] data/actions/scripts/outfit lever.lua:onUse
[01/08/2013 18:04:30] Description:
[01/08/2013 18:04:30] attempt to index a number value
[01/08/2013 18:04:30] stack traceback:
[01/08/2013 18:04:30] [C]: in function 'doCreatureChangeOutfit'
[01/08/2013 18:04:30] data/actions/scripts/outfit lever.lua:14: in function <data/actions/scripts/outfit lever.lua:7>
I've updated the post above.
---
Here's another script that will give random outfits:
LUA:local config = { token = 2159, useRandomOutfits = true } local t = { [1200] = {123, 237}, -- [LEVER_ACTION_ID] = lookType(s) [1201] = {123, 237}, } function onUse(cid, item, fromPosition, itemEx, toPosition) local k = t[item.actionid] if k then if(not doPlayerRemoveItem(cid, config.token, 1)) then return doPlayerSendCancel(cid, "You do not have a token"), doSendMagicEffect(getThingPos(cid), CONST_ME_POFF), false end if(config.useRandomOutfits) then doCreatureChangeOutfit(cid, {lookType = k[math.random(#k)]}, -1) else doCreatureChangeOutfit(cid, {lookType = k[1]}, -1) end doSendMagicEffect(getThingPos(cid), CONST_ME_MAGIC_BLUE) doCreatureSay(cid, "Enjoy your new outfit!", TALKTYPE_ORANGE_1) end return true end
[01/08/2013 18:16:14] [Error - Action Interface]
[01/08/2013 18:16:14] data/actions/scripts/outfit lever.lua:onUse
[01/08/2013 18:16:14] Description:
[01/08/2013 18:16:14] attempt to index a number value
[01/08/2013 18:16:14] stack traceback:
[01/08/2013 18:16:14] [C]: in function 'doCreatureChangeOutfit'
[01/08/2013 18:16:14] data/actions/scripts/outfit lever.lua:20: in function <data/actions/scripts/outfit lever.lua:11>
Use doSetCreatureOutift.![]()
now im confues, witch one should i use? haha sorry for being retarded.
Both work, but he's using TFS 0.3.6, and I don't think it has this one.
doCreatureChangeOutfit(cid, outfit)
doSetCreatureOutfit(cid, outfit, time)