• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

Monster on lever, must have tokens

Niioxce

Otland lurker
Joined
Jun 22, 2012
Messages
324
Reaction score
4
Location
Sweden
Hey, i want a script that they can get a random outfit, from a lever with a token... so it reduces 1 token, when right clicking on the lever, thanks!

- - - Updated - - -

bump
 
Yee, i want a room where you can CHOOSE outfits, with tokens, ive got the script but now, How can i use different "scripts" on the same lever?!

PS." i have the room" xD
 
Post the script you're currently using.

Ye sure, here's outfit lever.lua
Code:
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.xml
Code:
	<action itemid="1945" script="Outfit Lever.lua"/>
 
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
 
Last edited:
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
You may need to change: TALKTYPE_MONSTER to TALKTYPE_ORANGE_1 depending on which TFS you're using.
Now i only get debug.. and im using 0.3.6
 
Last edited:
Ye, the script works fine, but how can i use the same script but on 2 levers?

You need to edit the actions.xml:

XML:
<action actionid="1200;1201;" event="script" value="script.lua"/>
Here's the script: Remember to edit the lookType...

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
 
Last edited:
You need to edit the actions.xml:

XML:
<action actionid="1200;1201;" event="script" value="script.lua"/>
Here's the script: Remember to edit the lookType...

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

Dude, if this works.. Man.. finally a good answer! lets try it out...

- - - Updated - - -

You need to edit the actions.xml:

XML:
<action actionid="1200;1201;" event="script" value="script.lua"/>
Here's the script: Remember to edit the lookType...

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

i got this when i tryed the lever
Code:
[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

Still got this.. :/ any Idéa?
Code:
[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>
 
Both work, but he's using TFS 0.3.6, and I don't think it has this one.

It's nothing wrong with the TFS version, you just made a tiny typo that's all. :p
LUA:
doCreatureChangeOutfit(cid, outfit)
LUA:
doSetCreatureOutfit(cid, outfit, time)
 
Back
Top