• 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
 

Im still getting this
Code:
[01/08/2013 18:29:38] [Error - Action Interface] 
[01/08/2013 18:29:38] data/actions/scripts/outfit lever.lua:onUse
[01/08/2013 18:29:38] Description: 
[01/08/2013 18:29:38] attempt to index a number value
[01/08/2013 18:29:38] stack traceback:
[01/08/2013 18:29:38] 	[C]: in function 'doCreatureChangeOutfit'
[01/08/2013 18:29:38] 	data/actions/scripts/outfit lever.lua:14: in function <data/actions/scripts/outfit lever.lua:7>

I've got 2 levers here, and i did /attr actionid 1200 and on the other /attr actionid 1201, so am i doing something wrong?
 
Im still getting this
Code:
[01/08/2013 18:29:38] [Error - Action Interface] 
[01/08/2013 18:29:38] data/actions/scripts/outfit lever.lua:onUse
[01/08/2013 18:29:38] Description: 
[01/08/2013 18:29:38] attempt to index a number value
[01/08/2013 18:29:38] stack traceback:
[01/08/2013 18:29:38] 	[C]: in function 'doCreatureChangeOutfit'
[01/08/2013 18:29:38] 	data/actions/scripts/outfit lever.lua:14: in function <data/actions/scripts/outfit lever.lua:7>

I've got 2 levers here, and i did /attr actionid 1200 and on the other /attr actionid 1201, so am i doing something wrong?

Try this one:

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

This one is untested, but I thought you might want random outfits:

LUA:
local config = {
	token = 2159,
	useRandomOutfits = true -- false will use the first outfit in the sequence {123, 237}
}
 
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 == true) then
			for _, v in pairs(t) do
				doSetCreatureOutfit(cid, {lookType = v[math.random(#v)]}, -1)
			end
		else
			if(config.useRandomOutfits == false) then
				doSetCreatureOutfit(cid, {lookType = k[1]}, -1)
			end
		end
		
		doSendMagicEffect(getThingPos(cid), CONST_ME_MAGIC_BLUE)
		doCreatureSay(cid, "Enjoy your new outfit!", TALKTYPE_ORANGE_1)
	end
	return true
end
 
Last edited:
Try this one:

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

This one is untested, but I thought maybe you want random outfits:

LUA:
local config = {
	token = 2159,
	useRandomOutfits = true -- false will use the first outfit in the sequence {123, 237}
}
 
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
			for _, v in pairs(t) do
				doSetCreatureOutfit(cid, {lookType = v[math.random(#v)]}, -1)
			end
		else
			doSetCreatureOutfit(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

Now i get this xd
Code:
[01/08/2013 18:34:30] [Error - LuaScriptInterface::loadFile] data/actions/scripts/outfit lever.lua:1: '=' expected near 'config'
[01/08/2013 18:34:31] [Warning - Event::loadScript] Cannot load script (data/actions/scripts/outfit lever.lua)
[01/08/2013 18:34:31] data/actions/scripts/outfit lever.lua:1: '=' expected near 'config'
 
Did you try the first script? The second one is untested. :p

That worked the second one, but now it only gives the same outfit..
Code:
local t = {
	[1200] = {6}, -- [LEVER_ACTION_ID] = lookType(s)
	[1201] = {92},
i changed it to that, but it only give me the 92..
 
OMG ITS WORKING, Bro im so happy.. you dont even know!!!!.. oh man! Thanks for taking YOUR time to help a noob xD bro, is it possible to give rep?

Good. Yes, click the little star beneath my username to the left.

Ninja was right... The way I used doCreatureChangeOutfit had an extra variable for time, which is for doSetCreatureOutfit. Good catch, Ninja. I mixed them up. ;)
 
Good. Yes, click the little star beneath my username to the left.

Ninja was right... The way I used doCreatureChangeOutfit had an extra variable for time, which is for doSetCreatureOutfit. Good catch, Ninja. I mixed them up. ;)
Code:
Thanks for adding reputation to this user. May you be lucky enough to receive the same Reputation back in turn
There you go, thanks again...

- - - Updated - - -

SOLVED! Thanks J.Dre
 
Back
Top