Untitled

 avatar
unknown
lua
2 years ago
1.0 kB
4
Indexable
local effects = {
	[{1, 5, 13}] = {
		["death"] = {7, CONST_ME_MORTAREA}, 
		["fire"] = {4, CONST_ME_HITBYFIRE}
	},

	[{2, 6, 14}] = {
		["ice"] = {5, CONST_ME_ICEATTACK}, 
		["earth"] = {3, CONST_ME_SMALLPLANTS}
	}
}

local storage = 6999
function onSay(cid, words, param, channel)

	if not isSorcerer(cid) or not isDruid(cid) then
		return doPlayerSendCancel(cid, "Only mages and druids can use this command.")
	end

	if(not checkExhausted(cid, 690, 7)) then
		return true
	end

	for k, v in pairs(effects) do
		if isInArray(k, getPlayerVocation(cid)) then
			local p = v[param]
			if p then
				setPlayerStorageValue(cid, storage, p[1])
				doSendMagicEffect(getCreaturePosition(cid), p[2])
			else
				local str = {}
				for x, _ in pairs(v) do str[#str + 1] = x end
				doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "The attack elements available are: "..table.concat(str, ", "):gsub("(.*),", "%1 and")..".") 
			end
			break
		end
	end
	return false
end