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

Action Addon System

Code:
--[[
	~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	Addon System by Shawak (Maxi)
	Version v1.0
	~~~ Rememeber ~~~~~~~~~~~~~~~
	This script set storagevalues
	to save the addons.
	Storage = 14000 + actionid of
	item.
	~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
]]--
	
local config = {

	[4001] = {
		name = "First Citizen Addon", -- name
		addon_type = 1,               -- addon
		outfit = {136,128},           -- female / male
		cost = 0,                     -- cost
		items = {{5878,100}},         -- items
	},
	[4002] = {
		name = "Second Citizen Addon",
		addon_type = 2,
		outfit = {136,128},
		cost = 0,
		items = {{5890,100},{5902,50},{2480,1}},
	},
	[4003] = {
		name = "First Hunter Addon",
		addon_type = 1,
		outfit = {137,129},
		cost = 0,
		items = {{5947,1},{5876,100},{5948,100},{5889,1},{5887,1},{5888,1},{5891,5}},
	},
	[4004] = {
		name = "Second Hunter Addon",
		addon_type = 2,
		outfit = {137,129},
		cost = 0,
		items = {{5875,1}},
	},
	[4005] = {
		name = "First Mage Addon",
		addon_type = 1,
		outfit = {138,130},
		cost = 0,
		items = {{5958,1}},
	},
	[4006] = {
		name = "Second Mage Addon",
		addon_type = 2,
		outfit = {138,130},
		cost = 0,
		items = {{5903,1}},
	},
	[4007] = {
		name = "First Knight Addon",
		addon_type = 1,
		outfit = {139,131},
		cost = 0,
		items = {{5880,100}},
	},
	[4008] = {
		name = "Second Knight Addon",
		addon_type = 2,
		outfit = {139,131},
		cost = 0,
		items = {{5893,100},{5924,1},{5885,1},{5887,1}},
	},
	[4009] = {
		name = "First Nobleman Addon",
		addon_type = 1,
		outfit = {140,132},
		cost = 150000,
		items = {},
	},
	[4010] = {
		name = "Second Nobleman Addon",
		addon_type = 2,
		outfit = {140,132},
		cost = 150000,
		items = {},
	},

	[4011] = {
		name = "First Summoner Addon",
		addon_type = 1,
		outfit = {141,133},
		cost = 0,
		items = {{5958,1}},
	},
	[4012] = {
		name = "Second Summoner Addon",
		addon_type = 2,
		outfit = {141,133},
		cost = 0,
		items = {{5894,70},{5911,20},{5883,40},{5905,30},{5904,15},{5882,40},{5881,60},{5886,10},{5922,35}},
	},
	[4013] = {
		name = "First Warrior Addon",
		addon_type = 1,
		outfit = {142,134},
		cost = 0,
		items = {{5899,100},{5925,100},{5884,1},{5919,1}},
	},
	[4014] = {
		name = "Second Warrior Addon",
		addon_type = 2,
		outfit = {142,134},
		cost = 0,
		items = {{5887,1},{5880,100}},
	},
	[4015] = {
		name = "First Barbarian Addon",
		addon_type = 1,
		outfit = {147,143},
		cost = 0,
		items = {{5885,1},{5884,1},{5911,50},{5910,50},{5886,10}},
	},
	[4016] = {
		name = "Second Barbarian Addon",
		addon_type = 2,
		outfit = {147,143},
		cost = 0,
		items = {{5892,1},{5880,100},{5893,50},{5876,50}},
	},
	[4017] = {
		name = "First Druid Addon",
		addon_type = 1,
		outfit = {148,144},
		cost = 0,
		items = {{5897,50},{5896,50}},
	},
	[4018] = {
		name = "Second Druid Addon",
		addon_type = 2,
		outfit = {148,144},
		cost = 0,
		items = {{5940,1},{5938,1},{5937,1},{5942,1},{5906,100}},
	},
	[4019] = {
		name = "First Wizard Addon",
		addon_type = 1,
		outfit = {149,145},
		cost = 0,
		items = {{2488,1},{2123,1},{2492,1},{2536,1}},
	},
	[4020] = {
		name = "Second Wizard Addon",
		addon_type = 2,
		outfit = {149,145},
		cost = 0,
		items = {{5922,50},},
	},
	[4021] = {
		name = "First Oriental Addon",
		addon_type = 1,
		outfit = {150,146},
		cost = 0,
		items = {{5945,1}},
	},
	[4022] = {
		name = "Second Oriental Addon",
		addon_type = 2,
		outfit = {150,146},
		cost = 0,
		items = {{5883,100},{5895,100},{5891,2},{5912,100}},
	},
	[4023] = {
		name = "First Pirate Addon",
		addon_type = 1,
		outfit = {155,151},
		cost = 0,
		items = {{6126,100},{6097,100},{6098,100}},
	},
	[4024] = {
		name = "Second Pirate Addon",
		addon_type = 2,
		outfit = {155,151},
		cost = 0,
		items = {{2385,1},{6098,1},{6095,1},{6096,1}},
	},
	[4025] = {
		name = "First Assassin Addon",
		addon_type = 1,
		outfit = {156,152},
		cost = 0,
		items = {{5898,30},{5882,10},{5881,30},{5895,20},{5905,20},{5906,10},{5885,1}},
	},
	[4026] = {
		name = "Second Assassin Addon",
		addon_type = 2,
		outfit = {156,152},
		cost = 0,
		items = {{5909,50},{5910,50},{5911,50},{5912,50},{5913,50},{5914,50},{5886,10}},
	},
	[4027] = {
		name = "First Beggar Addon",
		addon_type = 1,
		outfit = {157,153},
		cost = 20000,
		items = {{5883,100}},
	},
	[4028] = {
		name = "Second Beggar Addon",
		addon_type = 2,
		outfit = {157,153},
		cost = 0,
		items = {{6107,1}},
	},
	[4029] = {
		name = "First Shaman Addon",
		addon_type = 1,
		outfit = {158,154},
		cost = 0,
		items = {{3955,5},{5015,1}},
	},
	[4030] = {
		name = "Second Shaman Addon",
		addon_type = 2,
		outfit = {158,154},
		cost = 0,
		items = {{3966,5},{3967,5}},
	},
	[4031] = {
		name = "First Norseman Addon",
		addon_type = 1,
		outfit = {252,251},
		cost = 0,
		items = {{7290,5}},
	},
	[4032] = {
		name = "Second Norseman Addon",
		addon_type = 2,
		outfit = {252,251},
		cost = 0,
		items = {{7290,10}},
	},
	[4033] = {
		name = "First Nightmare Addon",
		addon_type = 1,
		outfit = {269,268},
		cost = 0,
		items = {{6500,500}},
	},
	[4034] = {
		name = "Second Nightmare Addon",
		addon_type = 2,
		outfit = {269,268},
		cost = 0,
		items = {{6500,1500}},
	},
	[4035] = {
		name = "First Jester Addon",
		addon_type = 1,
		outfit = {270,273},
		cost = 0,
		items = {{5879,1},{5878,4}},
	},
	[4036] = {
		name = "Second Jester Addon",
		addon_type = 2,
		outfit = {270,273},
		cost = 0,
		items = {{5909,5}},
	},
	[4037] = {
		name = "First Brotherhood Addon",
		addon_type = 1,
		outfit = {279,278},
		cost = 0,
		items = {{6500,500}},
	},
	[4038] = {
		name = "Second Brotherhood Addon",
		addon_type = 2,
		outfit = {279,278},
		cost = 0,
		items = {{6500,1500}},
	},
	[4039] = {
		name = "First Demonhunter Addon",
		addon_type = 1,
		outfit = {288,289},
		cost = 150000,
		items = {},
	},
	[4040] = {
		name = "Second Demonhunter Addon",
		addon_type = 2,
		outfit = {288,289},
		cost = 150000,
		items = {},
	},
	[4041] = {
		name = "First Yalaharian Addon",
		addon_type = 1,
		outfit = {324,325},
		cost = 150000,
		items = {},
	},
	[4042] = {
		name = "Second Yalaharian Addon",
		addon_type = 2,
		outfit = {324,325},
		cost = 150000,
		items = {},
	},

} -------- config end -------
local storage = 14000
function onUse(cid, item, fromPosition, itemEx, toPosition)
	local addon, removeItems, removeMoney = config[item.actionid], 0, false
	if getPlayerStorageValue(cid, storage + item.actionid) < 1 then
		if getPlayerMoney(cid) >= addon.cost then
			removeMoney = true
		end
		if #addon.items > 0 then
			for i = 1, #addon.items do
				if getPlayerItemCount(cid, addon.items[i][1]) >= addon.items[i][2] then
					removeItems = removeItems + 1
				end
			end
		end
		if removeMoney and removeItems == #addon.items then
			for i = 1, #addon.items do
				doPlayerRemoveItem(cid, addon.items[i][1], addon.items[i][2])
			end
			doPlayerRemoveMoney(cid, addon.cost)
			doPlayerAddOutfit(cid, addon.outfit[1], addon.addon_type)
			doPlayerAddOutfit(cid, addon.outfit[2], addon.addon_type)
			setPlayerStorageValue(cid, storage + item.actionid, 1)
			doPlayerSendTextMessage(cid, 21, "Now you can use the "..addon.name..".")
		else
			local msg = addon.cost > 0 and "You need "..addon.cost.." gold coins and " or "You need "
			if #addon.items > 0 then
				for i = 1, #addon.items do
					msg = msg .. addon.items[i][2].."x "..getItemName(addon.items[i][1]).." "
				end
			end
			doPlayerSendTextMessage(cid, 21, msg.."for the "..addon.name..".")
		end
	else
		doPlayerSendTextMessage(cid, 21, "You already have the "..addon.name..".")
	end
	return TRUE
end

And the actions.xml part..
Code:
local msg = ""
for i = 1, 42 do
msg = msg .. '<action actionid="'.. 4000+i ..'" script="addons.lua"/>\n'
end
return msg
Which results in:
Code:
<action actionid="4001" script="addons.lua"/>
<action actionid="4002" script="addons.lua"/>
<action actionid="4003" script="addons.lua"/>
<action actionid="4004" script="addons.lua"/>
<action actionid="4005" script="addons.lua"/>
<action actionid="4006" script="addons.lua"/>
<action actionid="4007" script="addons.lua"/>
<action actionid="4008" script="addons.lua"/>
<action actionid="4009" script="addons.lua"/>
<action actionid="4010" script="addons.lua"/>
<action actionid="4011" script="addons.lua"/>
<action actionid="4012" script="addons.lua"/>
<action actionid="4013" script="addons.lua"/>
<action actionid="4014" script="addons.lua"/>
<action actionid="4015" script="addons.lua"/>
<action actionid="4016" script="addons.lua"/>
<action actionid="4017" script="addons.lua"/>
<action actionid="4018" script="addons.lua"/>
<action actionid="4019" script="addons.lua"/>
<action actionid="4020" script="addons.lua"/>
<action actionid="4021" script="addons.lua"/>
<action actionid="4022" script="addons.lua"/>
<action actionid="4023" script="addons.lua"/>
<action actionid="4024" script="addons.lua"/>
<action actionid="4025" script="addons.lua"/>
<action actionid="4026" script="addons.lua"/>
<action actionid="4027" script="addons.lua"/>
<action actionid="4028" script="addons.lua"/>
<action actionid="4029" script="addons.lua"/>
<action actionid="4030" script="addons.lua"/>
<action actionid="4031" script="addons.lua"/>
<action actionid="4032" script="addons.lua"/>
<action actionid="4033" script="addons.lua"/>
<action actionid="4034" script="addons.lua"/>
<action actionid="4035" script="addons.lua"/>
<action actionid="4036" script="addons.lua"/>
<action actionid="4037" script="addons.lua"/>
<action actionid="4038" script="addons.lua"/>
<action actionid="4039" script="addons.lua"/>
<action actionid="4040" script="addons.lua"/>
<action actionid="4041" script="addons.lua"/>
<action actionid="4042" script="addons.lua"/>
 
Code:
--[[
	~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	Addon System by Shawak (Maxi)
	Version v1.0
	~~~ Rememeber ~~~~~~~~~~~~~~~
	This script set storagevalues
	to save the addons.
	Storage = 14000 + actionid of
	item.
	~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
]]--
	
local config = {

	[4001] = {
		name = "First Citizen Addon", -- name
		addon_type = 1,               -- addon
		outfit = {136,128},           -- female / male
		cost = 0,                     -- cost
		items = {{5878,100}},         -- items
	},
	[4002] = {
		name = "Second Citizen Addon",
		addon_type = 2,
		outfit = {136,128},
		cost = 0,
		items = {{5890,100},{5902,50},{2480,1}},
	},
	[4003] = {
		name = "First Hunter Addon",
		addon_type = 1,
		outfit = {137,129},
		cost = 0,
		items = {{5947,1},{5876,100},{5948,100},{5889,1},{5887,1},{5888,1},{5891,5}},
	},
	[4004] = {
		name = "Second Hunter Addon",
		addon_type = 2,
		outfit = {137,129},
		cost = 0,
		items = {{5875,1}},
	},
	[4005] = {
		name = "First Mage Addon",
		addon_type = 1,
		outfit = {138,130},
		cost = 0,
		items = {{5958,1}},
	},
	[4006] = {
		name = "Second Mage Addon",
		addon_type = 2,
		outfit = {138,130},
		cost = 0,
		items = {{5903,1}},
	},
	[4007] = {
		name = "First Knight Addon",
		addon_type = 1,
		outfit = {139,131},
		cost = 0,
		items = {{5880,100}},
	},
	[4008] = {
		name = "Second Knight Addon",
		addon_type = 2,
		outfit = {139,131},
		cost = 0,
		items = {{5893,100},{5924,1},{5885,1},{5887,1}},
	},
	[4009] = {
		name = "First Nobleman Addon",
		addon_type = 1,
		outfit = {140,132},
		cost = 150000,
		items = {},
	},
	[4010] = {
		name = "Second Nobleman Addon",
		addon_type = 2,
		outfit = {140,132},
		cost = 150000,
		items = {},
	},

	[4011] = {
		name = "First Summoner Addon",
		addon_type = 1,
		outfit = {141,133},
		cost = 0,
		items = {{5958,1}},
	},
	[4012] = {
		name = "Second Summoner Addon",
		addon_type = 2,
		outfit = {141,133},
		cost = 0,
		items = {{5894,70},{5911,20},{5883,40},{5905,30},{5904,15},{5882,40},{5881,60},{5886,10},{5922,35}},
	},
	[4013] = {
		name = "First Warrior Addon",
		addon_type = 1,
		outfit = {142,134},
		cost = 0,
		items = {{5899,100},{5925,100},{5884,1},{5919,1}},
	},
	[4014] = {
		name = "Second Warrior Addon",
		addon_type = 2,
		outfit = {142,134},
		cost = 0,
		items = {{5887,1},{5880,100}},
	},
	[4015] = {
		name = "First Barbarian Addon",
		addon_type = 1,
		outfit = {147,143},
		cost = 0,
		items = {{5885,1},{5884,1},{5911,50},{5910,50},{5886,10}},
	},
	[4016] = {
		name = "Second Barbarian Addon",
		addon_type = 2,
		outfit = {147,143},
		cost = 0,
		items = {{5892,1},{5880,100},{5893,50},{5876,50}},
	},
	[4017] = {
		name = "First Druid Addon",
		addon_type = 1,
		outfit = {148,144},
		cost = 0,
		items = {{5897,50},{5896,50}},
	},
	[4018] = {
		name = "Second Druid Addon",
		addon_type = 2,
		outfit = {148,144},
		cost = 0,
		items = {{5940,1},{5938,1},{5937,1},{5942,1},{5906,100}},
	},
	[4019] = {
		name = "First Wizard Addon",
		addon_type = 1,
		outfit = {149,145},
		cost = 0,
		items = {{2488,1},{2123,1},{2492,1},{2536,1}},
	},
	[4020] = {
		name = "Second Wizard Addon",
		addon_type = 2,
		outfit = {149,145},
		cost = 0,
		items = {{5922,50},},
	},
	[4021] = {
		name = "First Oriental Addon",
		addon_type = 1,
		outfit = {150,146},
		cost = 0,
		items = {{5945,1}},
	},
	[4022] = {
		name = "Second Oriental Addon",
		addon_type = 2,
		outfit = {150,146},
		cost = 0,
		items = {{5883,100},{5895,100},{5891,2},{5912,100}},
	},
	[4023] = {
		name = "First Pirate Addon",
		addon_type = 1,
		outfit = {155,151},
		cost = 0,
		items = {{6126,100},{6097,100},{6098,100}},
	},
	[4024] = {
		name = "Second Pirate Addon",
		addon_type = 2,
		outfit = {155,151},
		cost = 0,
		items = {{2385,1},{6098,1},{6095,1},{6096,1}},
	},
	[4025] = {
		name = "First Assassin Addon",
		addon_type = 1,
		outfit = {156,152},
		cost = 0,
		items = {{5898,30},{5882,10},{5881,30},{5895,20},{5905,20},{5906,10},{5885,1}},
	},
	[4026] = {
		name = "Second Assassin Addon",
		addon_type = 2,
		outfit = {156,152},
		cost = 0,
		items = {{5909,50},{5910,50},{5911,50},{5912,50},{5913,50},{5914,50},{5886,10}},
	},
	[4027] = {
		name = "First Beggar Addon",
		addon_type = 1,
		outfit = {157,153},
		cost = 20000,
		items = {{5883,100}},
	},
	[4028] = {
		name = "Second Beggar Addon",
		addon_type = 2,
		outfit = {157,153},
		cost = 0,
		items = {{6107,1}},
	},
	[4029] = {
		name = "First Shaman Addon",
		addon_type = 1,
		outfit = {158,154},
		cost = 0,
		items = {{3955,5},{5015,1}},
	},
	[4030] = {
		name = "Second Shaman Addon",
		addon_type = 2,
		outfit = {158,154},
		cost = 0,
		items = {{3966,5},{3967,5}},
	},
	[4031] = {
		name = "First Norseman Addon",
		addon_type = 1,
		outfit = {252,251},
		cost = 0,
		items = {{7290,5}},
	},
	[4032] = {
		name = "Second Norseman Addon",
		addon_type = 2,
		outfit = {252,251},
		cost = 0,
		items = {{7290,10}},
	},
	[4033] = {
		name = "First Nightmare Addon",
		addon_type = 1,
		outfit = {269,268},
		cost = 0,
		items = {{6500,500}},
	},
	[4034] = {
		name = "Second Nightmare Addon",
		addon_type = 2,
		outfit = {269,268},
		cost = 0,
		items = {{6500,1500}},
	},
	[4035] = {
		name = "First Jester Addon",
		addon_type = 1,
		outfit = {270,273},
		cost = 0,
		items = {{5879,1},{5878,4}},
	},
	[4036] = {
		name = "Second Jester Addon",
		addon_type = 2,
		outfit = {270,273},
		cost = 0,
		items = {{5909,5}},
	},
	[4037] = {
		name = "First Brotherhood Addon",
		addon_type = 1,
		outfit = {279,278},
		cost = 0,
		items = {{6500,500}},
	},
	[4038] = {
		name = "Second Brotherhood Addon",
		addon_type = 2,
		outfit = {279,278},
		cost = 0,
		items = {{6500,1500}},
	},
	[4039] = {
		name = "First Demonhunter Addon",
		addon_type = 1,
		outfit = {288,289},
		cost = 150000,
		items = {},
	},
	[4040] = {
		name = "Second Demonhunter Addon",
		addon_type = 2,
		outfit = {288,289},
		cost = 150000,
		items = {},
	},
	[4041] = {
		name = "First Yalaharian Addon",
		addon_type = 1,
		outfit = {324,325},
		cost = 150000,
		items = {},
	},
	[4042] = {
		name = "Second Yalaharian Addon",
		addon_type = 2,
		outfit = {324,325},
		cost = 150000,
		items = {},
	},

} -------- config end -------
local storage = 14000
function onUse(cid, item, fromPosition, itemEx, toPosition)
	local addon, removeItems, removeMoney = config[item.actionid], 0, false
	if getPlayerStorageValue(cid, storage + item.actionid) < 1 then
		if getPlayerMoney(cid) >= addon.cost then
			removeMoney = true
		end
		if #addon.items > 0 then
			for i = 1, #addon.items do
				if getPlayerItemCount(cid, addon.items[i][1]) >= addon.items[i][2] then
					removeItems = removeItems + 1
				end
			end
		end
		if removeMoney and removeItems == #addon.items then
			for i = 1, #addon.items do
				doPlayerRemoveItem(cid, addon.items[i][1], addon.items[i][2])
			end
			doPlayerRemoveMoney(cid, addon.cost)
			doPlayerAddOutfit(cid, addon.outfit[1], addon.addon_type)
			doPlayerAddOutfit(cid, addon.outfit[2], addon.addon_type)
			setPlayerStorageValue(cid, storage + item.actionid, 1)
			doPlayerSendTextMessage(cid, 21, "Now you can use the "..addon.name..".")
		else
			local msg = addon.cost > 0 and "You need "..addon.cost.." gold coins and " or "You need "
			if #addon.items > 0 then
				for i = 1, #addon.items do
					msg = msg .. addon.items[i][2].."x "..getItemName(addon.items[i][1]).." "
				end
			end
			doPlayerSendTextMessage(cid, 21, msg.."for the "..addon.name..".")
		end
	else
		doPlayerSendTextMessage(cid, 21, "You already have the "..addon.name..".")
	end
	return TRUE
end

And the actions.xml part..
Code:
local msg = ""
for i = 1, 42 do
msg = msg .. '<action actionid="'.. 4000+i ..'" script="addons.lua"/>\n'
end
return msg
Which results in:
Code:
<action actionid="4001" script="addons.lua"/>
<action actionid="4002" script="addons.lua"/>
<action actionid="4003" script="addons.lua"/>
<action actionid="4004" script="addons.lua"/>
<action actionid="4005" script="addons.lua"/>
<action actionid="4006" script="addons.lua"/>
<action actionid="4007" script="addons.lua"/>
<action actionid="4008" script="addons.lua"/>
<action actionid="4009" script="addons.lua"/>
<action actionid="4010" script="addons.lua"/>
<action actionid="4011" script="addons.lua"/>
<action actionid="4012" script="addons.lua"/>
<action actionid="4013" script="addons.lua"/>
<action actionid="4014" script="addons.lua"/>
<action actionid="4015" script="addons.lua"/>
<action actionid="4016" script="addons.lua"/>
<action actionid="4017" script="addons.lua"/>
<action actionid="4018" script="addons.lua"/>
<action actionid="4019" script="addons.lua"/>
<action actionid="4020" script="addons.lua"/>
<action actionid="4021" script="addons.lua"/>
<action actionid="4022" script="addons.lua"/>
<action actionid="4023" script="addons.lua"/>
<action actionid="4024" script="addons.lua"/>
<action actionid="4025" script="addons.lua"/>
<action actionid="4026" script="addons.lua"/>
<action actionid="4027" script="addons.lua"/>
<action actionid="4028" script="addons.lua"/>
<action actionid="4029" script="addons.lua"/>
<action actionid="4030" script="addons.lua"/>
<action actionid="4031" script="addons.lua"/>
<action actionid="4032" script="addons.lua"/>
<action actionid="4033" script="addons.lua"/>
<action actionid="4034" script="addons.lua"/>
<action actionid="4035" script="addons.lua"/>
<action actionid="4036" script="addons.lua"/>
<action actionid="4037" script="addons.lua"/>
<action actionid="4038" script="addons.lua"/>
<action actionid="4039" script="addons.lua"/>
<action actionid="4040" script="addons.lua"/>
<action actionid="4041" script="addons.lua"/>
<action actionid="4042" script="addons.lua"/>

That's for 0.2.5 ? :eek:
 
When you are using few variables in a row as a string, you should use:
Code:
var1, var2, var3, var4 = 10, "blakgjakj", 165, "lol"
str = var1..var2..var3..var4
--instead of
str2 = var1 .."".. var2 .."".. var3 .. "" .. var4

And hm, nice idea with this addon system, but BlackDemon's idea in Neravia was much better (you had to put needed addon items for any addon on a table and pull a lever -> %&^#$&POOF -> addon unlocked) :)
 
i think shawak are making better posting a non-optimized script because all need the same oportunity for understend the script (advanced or not advanced scripter) and all not have the same ability of understend... thanks shawak, this script is one of the most helping! sorry for my bad english
 
i think shawak are making better posting a non-optimized script because all need the same oportunity for understend the script (advanced or not advanced scripter) and all not have the same ability of understend... thanks shawak, this script is one of the most helping! sorry for my bad english

Thanks for your post :peace:.
 
@Shawak:
Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)
	local addon, removeItems, removeMoney = config[item.actionid], 0, 0
	if (getPlayerStorageValue(cid, storage + item.actionid) == 1) then
		return doPlayerSendTextMessage(cid, 21, "You already have the "..addon.name..".")
	end

	if (getPlayerMoney(cid) < addon.cost) then
		return doPlayerSendTextMessage(cid, 21, "You need more money. (Cost: ".. addon.cost ..")")
	end

	if (#addon.items > 0) then
		for i = 1, #addon.items do
			if (getPlayerItemCount(cid, addon.items[i][1]) < addon.items[i][2]) then
				countinue
				local str = ""
				for x, item in ipairs(item[i][1]) do
					str = str .. x > 1 and ", " or " ".. addon.items[i][2].."x ".. getItemNameById(addon.items[i][1])
				end
				return doPlayerSendTextMessage(cid, 21, "You don't have required items. (Cost: ".. addon.cost .." | Items: ".. str ..")")
			end
		end
	end

	for i = 1, #addon.items do
		doPlayeRemoveItem(cid, addon.items[i][1], addon.items[i][2])
	end

	doPlayerRemoveMoney(cid, addon.cost)
	doPlayerAddOutfit(cid, addon.outfit[1], addon.addon_type)
	doPlayerAddOutfit(cid, addon.outfit[2], addon.addon_type)
	setPlayerStorageValue(cid, storage + item.actionid, 1)
	doPlayerSendTextMessage(cid, 21, "Now you can use the ".. addon.name ..".")

	return true
end

:F
 
@Shawak:
Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)
	local addon, removeItems, removeMoney = config[item.actionid], 0, 0
	if (getPlayerStorageValue(cid, storage + item.actionid) == 1) then
		return doPlayerSendTextMessage(cid, 21, "You already have the "..addon.name..".")
	end

	if (getPlayerMoney(cid) < addon.cost) then
		return doPlayerSendTextMessage(cid, 21, "You need more money. (Cost: ".. addon.cost ..")")
	end

	if (#addon.items > 0) then
		for i = 1, #addon.items do
			if (getPlayerItemCount(cid, addon.items[i][1]) < addon.items[i][2]) then
				countinue
				local str = ""
				for x, item in ipairs(item[i][1]) do
					str = str .. x > 1 and ", " or " ".. addon.items[i][2].."x ".. getItemNameById(addon.items[i][1])
				end
				return doPlayerSendTextMessage(cid, 21, "You don't have required items. (Cost: ".. addon.cost .." | Items: ".. str ..")")
			end
		end
	end

	for i = 1, #addon.items do
		doPlayeRemoveItem(cid, addon.items[i][1], addon.items[i][2])
	end

	doPlayerRemoveMoney(cid, addon.cost)
	doPlayerAddOutfit(cid, addon.outfit[1], addon.addon_type)
	doPlayerAddOutfit(cid, addon.outfit[2], addon.addon_type)
	setPlayerStorageValue(cid, storage + item.actionid, 1)
	doPlayerSendTextMessage(cid, 21, "Now you can use the ".. addon.name ..".")

	return true
end

:F
uhm, countinue?
 
Awesome system, will use it! Thanks Shawak!

Edit: You must spread some Reputation around before giving it to Shawak again.
 
The script doesn't work for me... :( (TFS 0.3.5pl1)

[15/12/2009 15:29:38] .../actions/scripts/Quests/Demonhunter Outfit Lever.lua:35: attempt to index local 'addon' (a nil value)
[15/12/2009 15:29:38] stack traceback:
[15/12/2009 15:29:38] .../actions/scripts/Quests/Demonhunter Outfit Lever.lua:35: in function <.../actions/scripts/Quests/Demonhunter Outfit Lever.lua:32>
 
The script doesn't work for me... :( (TFS 0.3.5pl1)

[15/12/2009 15:29:38] .../actions/scripts/Quests/Demonhunter Outfit Lever.lua:35: attempt to index local 'addon' (a nil value)
[15/12/2009 15:29:38] stack traceback:
[15/12/2009 15:29:38] .../actions/scripts/Quests/Demonhunter Outfit Lever.lua:35: in function <.../actions/scripts/Quests/Demonhunter Outfit Lever.lua:32>
plz post your script ;s
 
where are my credits I got the idea

lol?

The script doesn't work for me... :( (TFS 0.3.5pl1)

[15/12/2009 15:29:38] .../actions/scripts/Quests/Demonhunter Outfit Lever.lua:35: attempt to index local 'addon' (a nil value)
[15/12/2009 15:29:38] stack traceback:
[15/12/2009 15:29:38] .../actions/scripts/Quests/Demonhunter Outfit Lever.lua:35: in function <.../actions/scripts/Quests/Demonhunter Outfit Lever.lua:32>

as Cykotitan said.
 
Back
Top