• 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
Best answers
0
Reaction score
375
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
 

Cornex

Web Developer
Staff member
Global Moderator
Joined
Jun 15, 2008
Messages
3,447
Best answers
5
Reaction score
1,059
Location
Sweden
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
 

Swiff

Member
Joined
Apr 6, 2009
Messages
366
Best answers
0
Reaction score
12
Location
Sweden
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..
 
OP
vTune

vTune

KakelmästareN^
Joined
Jun 14, 2012
Messages
3,675
Best answers
0
Reaction score
375
Location
Sweden
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..
Exactly!
Anyone?
 
OP
vTune

vTune

KakelmästareN^
Joined
Jun 14, 2012
Messages
3,675
Best answers
0
Reaction score
375
Location
Sweden
bump any1?
 

StreamSide

Joseluis Gonzalez
Support Team
Joined
Aug 31, 2007
Messages
3,408
Best answers
39
Reaction score
905
Location
Arica - Chile
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
 
OP
vTune

vTune

KakelmästareN^
Joined
Jun 14, 2012
Messages
3,675
Best answers
0
Reaction score
375
Location
Sweden
Thanks you! Works great! :)
 
Top