XS
dúvida

[Encerrado] Storage?

Por xscas, 07 de jan. de 2013 em Tópicos Sem Resposta

script
8
739
xscasX
08 de janeiro de 2013 às 05:31

Bom pessoal, poderiam me ajudar a deixar esse script de modo que o player só possa usar 1x o comando?

 

skill = {	item = 9971, -- Item
quantidade = 0, -- Quantidade
quantidadeskill = 90, -- Skill adicionada
limiteskill = 90 -- Limite
}

magicLevel = {
item = 9971,
quantidade = 0,
quantidademl = 90,
limitedeml = 90
}

skillID = {
["club"] = SKILL_CLUB,
["sword"]= SKILL_SWORD,
["axe"] = SKILL_AXE,
["distance"] = SKILL_DISTANCE,
["shielding"] = SKILL_SHIELD
}

vocationSkill = { -- Vocações - SKILL
["club"] = {4, 8},
["sword"] = {4, 8},
["axe"] = {4, 8},
["distance"] = {3, 7},
["shielding"] = {4, 8}
}

vocationMagicLevel = {1, 2, 5, 6} -- Vocações - MAGIC LEVEL
protectZone = "sim"
function onSay(cid, words, param, channel)
local pid = getPlayerGUID(cid)
if (protectZone == "sim") and (not getTilePzInfo(getCreaturePosition(cid))) then
	doPlayerSendCancel(cid, "Você precisa estar em protection zone pra poder comprar.")
end

if (param == '') then
	doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Como usar: !comprar club; !comprar magiclevel.")
	return true
end

local storage, duration = 5, 5
if (param == 'magiclevel') then
	if getPlayerMagLevel(cid) < magicLevel.limitedeml then
		if isInArray(vocationMagicLevel, getPlayerVocation(cid)) then
			if doPlayerRemoveItem(cid, magicLevel.item, magicLevel.quantidade) then
				if (os.time() - getPlayerStorageValue(cid, storage)) >= duration then
					setPlayerStorageValue(cid, storage, os.time())
					doRemoveCreature(cid, true)
					db.executeQuery("UPDATE `players` SET `maglevel` = `maglevel` + ".. magicLevel.quantidademl .." WHERE `id` = ".. pid)
				else
					doPlayerSendCancel(cid, "Espere ".. duration .." segundos para comprar novamente.")
				end
			else
				doPlayerSendCancel(cid, "Você não tem o item requerido.")
			end
		else
			doPlayerSendCancel(cid, "Voce não pode comprar magic level.")
		end
	else
		doPlayerSendCancel(cid, "Você chegou no limite de magic level.")
	end
	return true
end

if(skillID[param:lower()]) then
	if(getPlayerSkill(cid, skillID[param:lower()]) < skill.limiteskill) then
		if isInArray(vocationSkill[param:lower()], getPlayerVocation(cid)) then
			if doPlayerRemoveItem(cid, skill.item, skill.quantidade) then
				if (os.time() - getPlayerStorageValue(cid, storage)) >= duration then
					setPlayerStorageValue(cid, storage, os.time())
					doRemoveCreature(cid, true)
					db.executeQuery("UPDATE `player_skills` SET `value` = `value` + ".. skill.quantidadeskill .." WHERE `player_id` = ".. pid .. " and `skillID[` = ".. skillID[param:lower()])
				else
					doPlayerSendCancel(cid, "Espere ".. duration .." segundos para comprar novamente.")
				end
			else
				doPlayerSendCancel(cid, "Você não tem o item requerido.")
			end
		else
			doPlayerSendCancel(cid, "Voce não pode comprar este skill.")
		end
	else
		doPlayerSendCancel(cid, "Você chegou no limite de skill.")
	end
else
	doPlayerSendCancel(cid, "Skill desconhecida.")
end
return true
end

 

up

 

up

Editado Janeiro 7 por xscas

SmiXS
08 de janeiro de 2013 às 08:34
skill = {       item = 9971, -- Item
       quantidade = 0, -- Quantidade
       quantidadeskill = 90, -- Skill adicionada
       limiteskill = 90 -- Limite
}

magicLevel = {
       item = 9971,
       quantidade = 0,
       quantidademl = 90,
       limitedeml = 90
}

skillID = {
       ["club"] = SKILL_CLUB,
       ["sword"]= SKILL_SWORD,
       ["axe"] = SKILL_AXE,
       ["distance"] = SKILL_DISTANCE,
       ["shielding"] = SKILL_SHIELD
}

vocationSkill = { -- Vocações - SKILL
       ["club"] = {4, 8},
       ["sword"] = {4, 8},
       ["axe"] = {4, 8},
       ["distance"] = {3, 7},
       ["shielding"] = {4, 8}
}

vocationMagicLevel = {1, 2, 5, 6} -- Vocações - MAGIC LEVEL
protectZone = "sim"
function onSay(cid, words, param, channel)  
if getPlayerStorageValue(cid, 1839) <= 0 then
  setPlayerStorageValue(cid, 1839, 1)
       local pid = getPlayerGUID(cid)
       if (protectZone == "sim") and (not getTilePzInfo(getCreaturePosition(cid))) then
               doPlayerSendCancel(cid, "Você precisa estar em protection zone pra poder comprar.")
       end

       if (param == '') then
               doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Como usar: !comprar club; !comprar magiclevel.")
               return true
       end

       local storage, duration = 5, 5
       if (param == 'magiclevel') then
               if getPlayerMagLevel(cid) < magicLevel.limitedeml then
                       if isInArray(vocationMagicLevel, getPlayerVocation(cid)) then
                               if doPlayerRemoveItem(cid, magicLevel.item, magicLevel.quantidade) then
                                       if (os.time() - getPlayerStorageValue(cid, storage)) >= duration then
                                               setPlayerStorageValue(cid, storage, os.time())
                                               doRemoveCreature(cid, true)
                                               db.executeQuery("UPDATE `players` SET `maglevel` = `maglevel` + ".. magicLevel.quantidademl .." WHERE `id` = ".. pid)
                                       else
                                               doPlayerSendCancel(cid, "Espere ".. duration .." segundos para comprar novamente.")
                                       end
                               else
                                       doPlayerSendCancel(cid, "Você não tem o item requerido.")
                               end
                       else
                               doPlayerSendCancel(cid, "Voce não pode comprar magic level.")
                       end
               else
                       doPlayerSendCancel(cid, "Você chegou no limite de magic level.")
               end
               return true
       end

       if(skillID[param:lower()]) then
               if(getPlayerSkill(cid, skillID[param:lower()]) < skill.limiteskill) then
                       if isInArray(vocationSkill[param:lower()], getPlayerVocation(cid)) then
                               if doPlayerRemoveItem(cid, skill.item, skill.quantidade) then
                                       if (os.time() - getPlayerStorageValue(cid, storage)) >= duration then
                                               setPlayerStorageValue(cid, storage, os.time())
                                               doRemoveCreature(cid, true)
                                               db.executeQuery("UPDATE `player_skills` SET `value` = `value` + ".. skill.quantidadeskill .." WHERE `player_id` = ".. pid .. " and `skillID[` = ".. skillID[param:lower()])
                                       else
                                               doPlayerSendCancel(cid, "Espere ".. duration .." segundos para comprar novamente.")
                                       end
                               else
                                       doPlayerSendCancel(cid, "Você não tem o item requerido.")
                               end
                       else
                               doPlayerSendCancel(cid, "Voce não pode comprar este skill.")
                       end
               else
                       doPlayerSendCancel(cid, "Você chegou no limite de skill.")
               end
       else
               doPlayerSendCancel(cid, "Skill desconhecida.")
       end
else
   doPlayerSendCancel(cid, "Você já usou esse comando um vez.")
end
       return true
end

xscasX
08 de janeiro de 2013 às 19:20

Cara funcionou direitinho!, se puder também, como eu coloco para poder usar o comando se estiver ML 10 ou menos... ?? Brigadão

Editado Janeiro 8 por xscas

SmiXS
08 de janeiro de 2013 às 20:56

 

 

skill = {       item = 9971, -- Item
       quantidade = 0, -- Quantidade
       quantidadeskill = 90, -- Skill adicionada
       limiteskill = 90 -- Limite
}

magicLevel = {
       item = 9971,
       quantidade = 0,
       quantidademl = 90,
       limitedeml = 90
}

skillID = {
       ["club"] = SKILL_CLUB,
       ["sword"]= SKILL_SWORD,
       ["axe"] = SKILL_AXE,
       ["distance"] = SKILL_DISTANCE,
       ["shielding"] = SKILL_SHIELD
}

vocationSkill = { -- Vocações - SKILL
       ["club"] = {4, 8},
       ["sword"] = {4, 8},
       ["axe"] = {4, 8},
       ["distance"] = {3, 7},
       ["shielding"] = {4, 8}
}

vocationMagicLevel = {1, 2, 5, 6} -- Vocações - MAGIC LEVEL
protectZone = "sim"
function onSay(cid, words, param, channel)
if getPlayerMagLevel(cid) <= 10 then  
if getPlayerStorageValue(cid, 1839) <= 0 then
  setPlayerStorageValue(cid, 1839, 1)
       local pid = getPlayerGUID(cid)
       if (protectZone == "sim") and (not getTilePzInfo(getCreaturePosition(cid))) then
               doPlayerSendCancel(cid, "Você precisa estar em protection zone pra poder comprar.")
       end

       if (param == '') then
               doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Como usar: !comprar club; !comprar magiclevel.")
               return true
       end

       local storage, duration = 5, 5
       if (param == 'magiclevel') then
               if getPlayerMagLevel(cid) < magicLevel.limitedeml then
                       if isInArray(vocationMagicLevel, getPlayerVocation(cid)) then
                               if doPlayerRemoveItem(cid, magicLevel.item, magicLevel.quantidade) then
                                       if (os.time() - getPlayerStorageValue(cid, storage)) >= duration then
                                               setPlayerStorageValue(cid, storage, os.time())
                                               doRemoveCreature(cid, true)
                                               db.executeQuery("UPDATE `players` SET `maglevel` = `maglevel` + ".. magicLevel.quantidademl .." WHERE `id` = ".. pid)
                                       else
                                               doPlayerSendCancel(cid, "Espere ".. duration .." segundos para comprar novamente.")
                                       end
                               else
                                       doPlayerSendCancel(cid, "Você não tem o item requerido.")
                               end
                       else
                               doPlayerSendCancel(cid, "Voce não pode comprar magic level.")
                       end
               else
                       doPlayerSendCancel(cid, "Você chegou no limite de magic level.")
               end
               return true
       end

       if(skillID[param:lower()]) then
               if(getPlayerSkill(cid, skillID[param:lower()]) < skill.limiteskill) then
                       if isInArray(vocationSkill[param:lower()], getPlayerVocation(cid)) then
                               if doPlayerRemoveItem(cid, skill.item, skill.quantidade) then
                                       if (os.time() - getPlayerStorageValue(cid, storage)) >= duration then
                                               setPlayerStorageValue(cid, storage, os.time())
                                               doRemoveCreature(cid, true)
                                               db.executeQuery("UPDATE `player_skills` SET `value` = `value` + ".. skill.quantidadeskill .." WHERE `player_id` = ".. pid .. " and `skillID[` = ".. skillID[param:lower()])
                                       else
                                               doPlayerSendCancel(cid, "Espere ".. duration .." segundos para comprar novamente.")
                                       end
                               else
                                       doPlayerSendCancel(cid, "Você não tem o item requerido.")
                               end
                       else
                               doPlayerSendCancel(cid, "Voce não pode comprar este skill.")
                       end
               else
                       doPlayerSendCancel(cid, "Você chegou no limite de skill.")
               end
       else
               doPlayerSendCancel(cid, "Skill desconhecida.")
       end
else
   doPlayerSendCancel(cid, "Você já usou esse comando um vez.")
end
else 
doPlayerSendCancel(cid, "Você precisa ter ML igual ou menor que 10 para usar este comando.")
end
       return true
end

 

 

 

Tenta ai.

xscasX
08 de janeiro de 2013 às 22:32

Deu certinho cara, brigadão!

AkatsukyiA
09 de janeiro de 2013 às 23:47

Resolvido

StigalS
09 de janeiro de 2013 às 23:58

Movido!

5 anos depois...
StigalS
20 de abril de 2018 às 00:52
A questão neste tópico de suporte foi encerrada por falta de respostas. Este tópico está fechado e foi movido para Suporte - Tópicos Sem Resposta.

+ Caso a dúvida não tenha sido resolvida você poderá criar outro tópico solicitando ajuda.
* Lembre-se que é permitido dar UP no tópico a cada 24 horas para assim o destacar e manter movimentado.