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

Save looktype + chaneg to the saved looktype

vTune

KakelmästareN^
Joined
Jun 14, 2012
Messages
3,675
Reaction score
395
Location
Sweden
Hello otland!

I want to request 2 scipts.

The first one is a script where you can save your looktype by clicking on an item/lever or what ever
and the second one is that you change to this saved looktype by clicking on another item / lever!

I dont have much time atm so if you want an better explanation just ask me and I will explain soon!

Hope you understand​

Kind Regards vTune
 
I would like to get an better explanation ;p if i understand right, you want the "item" to save the looktype, and when you wanna use it again you just click it? Sorry mate didn't get it ;p
 
onUse item x to save looktype
onUse item y to load looktype

I guess this is what he wants, unfortunately I have too little knowledge to make it..
 
well, i use mysql so i made it for mysql

>sql query
SQL:
ALTER TABLE `players` ADD `outfit` VARCHAR ( 255 ) NOT NULL DEFAULT '0-0-0-0-0-0';

>actions.xml
XML:
<action itemid="2143;2144" event="script" value="outfit.lua"/>

2143 --> white pearl
2144 --> black pearl

>scripts/outfit.lua
Lua:
local config = {
	saveitem = 2143,			-- item id to save
	savestorage = 2345,			-- save storage
	saveex = 30,				-- exhausted after save in secods
	loaditem = 2144,			-- item id to load
	loadstorage = 5432,			-- load storage
	loadex = 30					-- exhasted after load in seconds
}

function onUse(cid, item, fromPosition, itemEx, toPosition)

	if item.itemid == config.loaditem then
		if getPlayerStorageValue(cid, config.loadstorage) > os.time() then
			return doPlayerSendTextMessage(cid, 19, "You can use this command only all "..config.loadex.." seconds.")
		end

		local result = db.getResult("SELECT `outfit` FROM `players` WHERE `name` = '"..getCreatureName(cid).."';")
		if result:getID() == -1 then
			return true
		end

		saved_outfit = string.explode(result:getDataString("outfit"), "-")
		result:free()
	
		local outfit = {
			lookType = saved_outfit[1],
			lookHead = saved_outfit[2],
			lookBody = saved_outfit[3],
			lookLegs = saved_outfit[4],
			lookFeet = saved_outfit[5],
			lookAddons = saved_outfit[6]
		}
	
		setPlayerStorageValue(cid, config.loadstorage, os.time() + config.loadex)

		if outfit.lookType == 0 then
			return doPlayerSendTextMessage(cid, 19, "Use "..getItemNameById(config.saveitem).." to save an outfit.")
		end

		doCreatureChangeOutfit(cid, outfit)
		doPlayerSendTextMessage(cid, 19, "Outfit loaded.")

	elseif item.itemid == config.saveitem then
		if getPlayerStorageValue(cid, config.savestorage) > os.time() then
			return doPlayerSendTextMessage(cid, 19, "You can use this command only all "..config.saveex.." seconds.")
		end

		local outfit = getCreatureOutfit(cid)
	
		setPlayerStorageValue(cid, config.savestorage, os.time() + config.saveex)
		db.executeQuery("UPDATE `players` SET `outfit` = '"..outfit.lookType.."-"..outfit.lookHead.."-"..outfit.lookBody.."-"..outfit.lookLegs.."-"..outfit.lookFeet.."-"..outfit.lookAddons.."' WHERE `name` = '"..getCreatureName(cid).."';")
		doPlayerSendTextMessage(cid, 19, "Outfit saved, use "..getItemNameById(config.loaditem).." to load it.")
	end
	
	return true
end

enjoy
 
Back
Top