AY

[Resolvido] Verificar se tem pokemon.

Por Ayron5, 09 de mai. de 2017 em Resolvidos

6
1.3k
Ayron5A
09 de maio de 2017 às 09:14

Queria colocar uma verificação na minha script, caso o player tenha pokemons na bag desse um:

 

doTeleportThing(cid, fromPosition, true)
        doPlayerSendCancel(cid, "Você não pode entrar com Pokemons na bag")
        doSendMagicEffect(getThingPos(cid), CONST_ME_MAGIC_BLUE)

Spoiler
function onStepIn(cid, item, position, fromPosition)     	 	if not isPlayer(cid) then return true end	if getPlayerAccess(cid) > 3 then return doTeleportThing(cid, zombie_config.teleport[2]) end	if getPlayerLevel(cid) < zombie_config.min_Level then		doTeleportThing(cid, fromPosition, true)		doPlayerSendCancel(cid, "Você precisa ter pelo menos nível " .. zombie_config.min_Level .. ".")		doSendMagicEffect(getThingPos(cid), CONST_ME_MAGIC_BLUE)		return true	end

Caso não tenha ele passa-se de boa ^ ^ 

Tentei umas formas aqui mão não consegui... Noob ainda ^ ^ 

Editado Novembro 30 por Stigal

samlecterS
10 de maio de 2017 às 12:31
Melhor resposta

Adiciona isso e testa aí:

-- se não funcionar, tenta trocar os parâmetros thing por cid, ex:  ...getPlayerSlotItem(cid, 3).uid)...local ballsCount = 0		  ballsCount = #getPokeballsInContainer(getPlayerSlotItem(thing, 3).uid)		  if getPlayerSlotItem(thing, 8).uid ~= 0 and isPokeball(getPlayerSlotItem(thing, 8).itemid) then		     ballsCount = ballsCount+1		  end		  if getPlayerSlotItem(thing, 10).uid ~= 0 and isPokeball(getPlayerSlotItem(thing, 10).itemid) then		     ballsCount = ballsCount+1		  end         if ballsCount > 0 then                doTeleportThing(cid, fromPosition, true)		doPlayerSendCancel(cid, "Guarde seus pokemons primeiro.")		doSendMagicEffect(getThingPos(cid), CONST_ME_MAGIC_BLUE)         end

 

Ayron5A
10 de maio de 2017 às 14:50
2 horas atrás, samlecter disse:

Adiciona isso e testa aí:

-- se não funcionar, tenta trocar os parâmetros thing por cid, ex:  ...getPlayerSlotItem(cid, 3).uid)...local ballsCount = 0		  ballsCount = #getPokeballsInContainer(getPlayerSlotItem(thing, 3).uid)		  if getPlayerSlotItem(thing, 8).uid ~= 0 and isPokeball(getPlayerSlotItem(thing, 8).itemid) then		     ballsCount = ballsCount+1		  end		  if getPlayerSlotItem(thing, 10).uid ~= 0 and isPokeball(getPlayerSlotItem(thing, 10).itemid) then		     ballsCount = ballsCount+1		  end         if ballsCount > 0 then                doTeleportThing(cid, fromPosition, true)		doPlayerSendCancel(cid, "Guarde seus pokemons primeiro.")		doSendMagicEffect(getThingPos(cid), CONST_ME_MAGIC_BLUE)         end

 

Quando chegar em casa eu tento ^^ 

6 meses depois...
StigalS
29 de novembro de 2017 às 15:21
Citar

A pedidos do dono do tópico, re-aberto para definir melhor resposta.

 

Editado Novembro 30 por Stigal

Ayron5A
30 de novembro de 2017 às 11:29
Em 10/05/2017 at 12:31, samlecter disse:

Adiciona isso e testa aí:

-- se não funcionar, tenta trocar os parâmetros thing por cid, ex:  ...getPlayerSlotItem(cid, 3).uid)...local ballsCount = 0		  ballsCount = #getPokeballsInContainer(getPlayerSlotItem(thing, 3).uid)		  if getPlayerSlotItem(thing, 8).uid ~= 0 and isPokeball(getPlayerSlotItem(thing, 8).itemid) then		     ballsCount = ballsCount+1		  end		  if getPlayerSlotItem(thing, 10).uid ~= 0 and isPokeball(getPlayerSlotItem(thing, 10).itemid) then		     ballsCount = ballsCount+1		  end         if ballsCount > 0 then                doTeleportThing(cid, fromPosition, true)		doPlayerSendCancel(cid, "Guarde seus pokemons primeiro.")		doSendMagicEffect(getThingPos(cid), CONST_ME_MAGIC_BLUE)         end

 

Funcionou com a troca dos thing's por cid's, adicionei um return true no final antes do ultimo end.

Bom, Obg pela ajuda ^^ Reputado! 

 

 

StigalS
30 de novembro de 2017 às 11:41
A questão neste tópico de suporte foi respondida e/ou o autor do tópico resolveu o problema. Este tópico está fechado e foi movido para Suporte - Resolvidos. Se você tiver outras dúvidas, crie um novo tópico.