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

Solved Help with my lua script please!

kaspertje100

Member
Joined
May 8, 2008
Messages
236
Reaction score
7
Hi Otlanders,

I'm having some trouble with my script to unmount.

error:
Code:
[12/05/2013 22:13:38] [Error - Action Interface] 
[12/05/2013 22:13:38] data/actions/scripts/other/demount.lua:onUse
[12/05/2013 22:13:38] Description: 
[12/05/2013 22:13:38] data/lib/011-string.lua:16: bad argument #1 to 'find' (string expected, got nil)
[12/05/2013 22:13:38] stack traceback:
[12/05/2013 22:13:38] 	[C]: in function 'find'
[12/05/2013 22:13:38] 	data/lib/011-string.lua:16: in function '(for generator)'
[12/05/2013 22:13:38] 	data/lib/011-string.lua:16: in function 'explode'
[12/05/2013 22:13:38] 	data/actions/scripts/other/demount.lua:17: in function <data/actions/scripts/other/demount.lua:5>

LUA:
local foncig = {
	acceptedOutfits = {136, 128, 137, 129, 138, 130, 139, 131, 140, 132, 141, 133, 142, 134, 147, 143, 148, 144, 149, 145, 150, 146, 155, 151, 156, 152, 157, 153, 158, 154, 252, 251, 269, 268, 270, 273, 279, 278, 288, 289, 324, 325, 336, 335, 366, 367, 329, 328}
}
 
function onUse(cid, item)
local currentOutfit = getCreatureOutfit(cid)
if(isInArray(foncig.acceptedOutfits, currentOutfit.lookType)) then
doCreatureSetStorage(cid, foncig.outfitSlots[t[1]].storage, "_".. currentOutfit.lookType ..",_".. currentOutfit.lookHead ..",_".. currentOutfit.lookBody ..",_".. currentOutfit.lookLegs ..",_".. currentOutfit.lookFeet ..",_".. currentOutfit.lookAddons)
	doCreatureSay(cid, "You dismounted your horse", 19)
	doChangeSpeed(cid, -100)
	doSendMagicEffect(getCreaturePosition(cid), 2)
	doRemoveItem(item.uid, 1)
	doPlayerAddItem(cid, 2354, 1)
else
	doPlayerSendCancel(cid, "Sorry not possible.")
end
	local t = string.explode(param, ",")
	t[1] = tonumber(t[1])
	local o = tostring(getCreatureStorage(cid, foncig.outfitSlots[t[1]].storage)):gsub('_', ''):explode(',')
	if(o[6]) then
		doCreatureChangeOutfit(cid, {lookType = o[1], lookHead = o[2], lookBody = o[3], lookLegs = o[4], lookFeet = o[5], lookAddons = o[6]})
	end
 end

I need the player restore too their outfit which they had before they used the mount function, please help me doing this!


p.s im using this script too mount: (maybe I should some storage here so the server knows which outfit the player was wearing?)

LUA:
function onUse(cid, item)
	doCreatureSay(cid, "You mounted your horse!", 19)
	doChangeSpeed(cid, 100)
	doSendMagicEffect(getCreaturePosition(cid), 34)
	doCreatureChangeOutfit(cid, {lookType = 342})
	doRemoveItem(item.uid, 1)
	doPlayerAddItem(cid, 2193, 1)
end

well please help me!
Iam not a very experienced scripter;s most of the codes I used examples which where standing on Otland xD however im trying to become better and better please help me and teach me!
 
param is used for talkactions, to get the words someone said, in this script you are checking for words, but it's an action script which only works with use on an item.
What you can do is set storage for lookType, lookHead, etc in the mount script and check for this storage in the dismount script with changing the outfit.
 
right, so could you maybe give a example of that cuz im not that experienced with lua scripting yet;/

I would really appreciate it!

- - - Updated - - -

bump!, please help
 
To save the outfit.
LUA:
local foncig = {
	acceptedOutfits = {136, 128, 137, 129, 138, 130, 139, 131, 140, 132, 141, 133, 142, 134, 147, 143, 148, 144, 149, 145, 150, 146, 155, 151, 156, 152, 157, 153, 158, 154, 252, 251, 269, 268, 270, 273, 279, 278, 288, 289, 324, 325, 336, 335, 366, 367, 329, 328}
}

local currentOutfit = getCreatureOutfit(cid)
if(isInArray(foncig.acceptedOutfits, currentOutfit.lookType)) then
	doCreatureSetStorage(cid, "outfit", "_".. currentOutfit.lookType ..",_".. currentOutfit.lookHead ..",_".. currentOutfit.lookBody ..",_".. currentOutfit.lookLegs ..",_".. currentOutfit.lookFeet ..",_".. currentOutfit.lookAddons)
end

To restore outfit.
LUA:
local o = tostring(getCreatureStorage(cid, "outfit")):gsub('_', ''):explode(',')
if(o[6]) then
	doCreatureChangeOutfit(cid, {lookType = o[1], lookHead = o[2], lookBody = o[3], lookLegs = o[4], lookFeet = o[5], lookAddons = o[6]})
end
 
thank you very much!

- - - Updated - - -

New bug :P

my new code:

mount:
LUA:
function onUse(cid, item)
	local currentOutfit = getCreatureOutfit(cid)
	doCreatureSetStorage(cid, "outfit", "_".. currentOutfit.lookType ..",_".. currentOutfit.lookHead ..",_".. currentOutfit.lookBody ..",_".. currentOutfit.lookLegs ..",_".. currentOutfit.lookFeet ..",_".. currentOutfit.lookAddons)
	doCreatureSay(cid, "You mounted your horse!", 19)
	doChangeSpeed(cid, 100)
	doSendMagicEffect(getCreaturePosition(cid), 34)
	doCreatureChangeOutfit(cid, {lookType = 342})
	doRemoveItem(item.uid, 1)
	doPlayerAddItem(cid, 2193, 1)
end

demount:
LUA:
function onUse(cid, item)
	doCreatureSay(cid, "You dismounted your horse", 19)
	doChangeSpeed(cid, -100)
	doSendMagicEffect(getCreaturePosition(cid), 2)
	doRemoveItem(item.uid, 1)
	doPlayerAddItem(cid, 2354, 1)
	end	
	local o = tostring(getCreatureStorage(cid, "outfit")):gsub('_', ''):explode(',')
	if(o[6]) then
		doCreatureChangeOutfit(cid, {lookType = o[1], lookHead = o[2], lookBody = o[3], lookLegs = o[4], lookFeet = o[5], lookAddons = o[6]})
end

error:
Code:
[13/05/2013 23:26:26] [Error - Action Interface] 
[13/05/2013 23:26:26] data/actions/scripts/other/demount.lua
[13/05/2013 23:26:26] Description: 
[13/05/2013 23:26:26] (luaGetCreatureStorage) Creature not found


and how do I add that people cant change their outfit while they are mounted?
I tried: allowChangeOutfit = false
but didnt work:P
 
Last edited:
At the demount script you end function onUse under doPlayerAddItem. So the lines you added are outside the function/script.
You need to add it inside the function so above the end from function onUse.
 
it works!!, now how can I make a system that people can't change their outfit while they are "mounted" since im using 8.60 the mount is a new outfit so its lame if they change their outfit again:p
 
You can add a storage to the mount script, then remove the storage in the dismount script, then use function onOutfit and return false if someone has that storage.
Example:
LUA:
function onOutfit(cid, old, current)
        if getPlayerStorageValue(cid, 10837) >= 1 then
		doPlayerSendCancel(cid, "You cannot change your outfit while using a mount.")
		return false
	end
	return true
end
If you are not sure how to add it.
creaturescripts.xml
XML:
<event type="outfit" name="Outfit" event="script" value="outfitchange.lua"/>
You can choose the name and the lua file name.
Also register the name in login.lua
LUA:
registerCreatureEvent(cid, "Outfit")
 
Last edited:
Did work awesome! but now when im trying remove the mount (with the unmount script) I also have the message you can't change your outfit while mounted hehe. I can make a exception in the script that it doesnt check the outfit at that point?
 
Edited my post, try to do it like that, set storage to -1 before changing the outfit in the unmount script.
 
Last edited:
Back
Top