SU
tfs 1.0

Ganhar Gold ao Matar Player Level 700+

Por surfnament, 29 de fev. de 2016 em Scripts

resolvido
script
15
2.5k
surfnamentS
29 de fevereiro de 2016 às 18:42

Ola galera

Alguem poderia me ajudar com esse script?
Eu quero que players ganhem gold ao matar jogadores high level (700+)

Utilizo TFS 1.0....

Esta pode ser uma boa base

function onKill(cid, target)

    if isPlayer(cid) and isPlayer(target) then
        broadcastMessage(getCreatureName(target).."["..getPlayerLevel(target).."] acabou de ser morto pelo jogador "..getCreatureName(cid).."["..getPlayerLevel(cid).."].", MESSAGE_EVENT_ADVANCE)
    end

    return true
end

Editado Fevereiro 29 por Prototype

Lucas CPL
01 de março de 2016 às 09:58
Melhor resposta

Tente assim:

local config = {
	level = 700, -- level que ganha o dinheiro
	coin = 10000 -- coin é em gold coin, ou seja, 1 é 1 gold coin, 100 é 1 platinum coin, 10000 é 1 crystal coin
}
function onKill(cid, target)

    if isPlayer(cid) and isPlayer(target) then
		if getPlayerLevel(target) >= config.level then
			broadcastMessage(getCreatureName(target).."["..getPlayerLevel(target).."] acabou de ser morto pelo jogador "..getCreatureName(cid).."["..getPlayerLevel(cid).."].", MESSAGE_EVENT_ADVANCE)
			Player(cid):addMoney(config.coin)
			Player(cid):sendTextMessage(MESSAGE_STATUS_DEFAULT, string.format('Você ganhou %d golds por matar o jogador %s.',config.coin, getCreatureName(target)))
		end
    end

    return true
end
surfnamentS
01 de março de 2016 às 19:26

Opa obrigado por ajudar....
Não funcionou e não apareceu erro nenhum...

Lucas CPL
02 de março de 2016 às 12:33

tenta assim:

local config = {
	level = 700, -- level que ganha o dinheiro
	coin = 10000 -- coin é em gold coin, ou seja, 1 é 1 gold coin, 100 é 1 platinum coin, 10000 é 1 crystal coin
}
function onPrepareDeath(cid, killer)

    if isPlayer(killer) then
		if getPlayerLevel(cid) >= config.level then
			broadcastMessage(getCreatureName(cid).."["..getPlayerLevel(cid).."] acabou de ser morto pelo jogador "..getCreatureName(killer).."["..getPlayerLevel(killer).."].", MESSAGE_EVENT_ADVANCE)
			Player(killer):addMoney(config.coin)
			Player(killer):sendTextMessage(MESSAGE_STATUS_DEFAULT, string.format('Você ganhou %d golds por matar o jogador %s.',config.coin, getCreatureName(cid)))
		end
    end

    return true
end

e em creaturescript.xml

vc muda type="kill" para type="preparedeath"

surfnamentS
02 de março de 2016 às 18:00

Nao funcionou e também nao aparece erro algum no console oO

Lucas CPL
02 de março de 2016 às 18:05

Você ta registrando no login.lua?

surfnamentS
02 de março de 2016 às 18:27

Sim:

registerCreatureEvent(cid, "Gold")


<event type="preparedeath" name="gold" script="gold.lua"/>

 

 

Lucas CPL
02 de março de 2016 às 18:35

registerCreatureEvent(cid, "Gold")

muda para

registerCreatureEvent(cid, gold")

surfnamentS
02 de março de 2016 às 22:05

Funcionou!! Obrigadooo!!!

Seria muito dificil adicionar para cada level dar uma quantidade?
Ex:
700+= 100k
800+= 200k
900+=300k

Lucas CPL
02 de março de 2016 às 22:29

tenta assim:

local tabela = {
	{de = 700, ate = 799,coin = 10*10000},
	{de = 800, ate = 899,coin = 20*10000},
	{de = 900, ate = 999,coin = 30*10000},
	
}
function onKill(cid, target)

    if Player(cid) and Player(target) then
		for i= 1, #tabela do
			if getPlayerLevel(target) >= tabela[i].de and getPlayerLevel(target) <= tabela[i].ate then
				broadcastMessage(getCreatureName(target).."["..getPlayerLevel(target).."] acabou de ser morto pelo jogador "..getCreatureName(cid).."["..getPlayerLevel(cid).."].", MESSAGE_EVENT_ADVANCE)
				Player(cid):addMoney(tabela[i].coin)
				Player(cid):sendTextMessage(MESSAGE_STATUS_DEFAULT, string.format('Você ganhou %d golds por matar o jogador %s.',tabela[i].coin, getCreatureName(target)))
				return true
			end
		end
    end

    return true
end

esta com onKill

surfnamentS
03 de março de 2016 às 00:14

Deu este erro ...

 

https://uploaddeimagens.com.br/imagens/erro-png--379

Tentei trocar a tag no xml para kill e tbm nao funcionou '-'
Tentei tbm mudar os 2 para preparedeath / preparedeath(cid,killer) e tbm nao foi...

Lucas CPL
03 de março de 2016 às 09:14

deixa com onKill na script e no xml deixa assim:

<event type="kill" name="gold" script="gold.lua"/>
surfnamentS
03 de março de 2016 às 18:04

Nao funcionou e nao deu erro nenhum... To pensando em ficar com o script normal mesmo '-'

Voce poderia me ajudar em um outro script? Tava precisando muito de um npc para finalizar um sistema meu....

http://www.xtibia.com/forum/topic/239676-tfs-10-npc-que-sumona-boss-em-troca-de-sacrificios/


2 semanas depois...
DanihcvD
13 de março de 2016 às 20:38

Tópico movido para dúvidas / pedidos resolvidos.

5 meses depois...
felipy491F
13 de agosto de 2016 às 02:01

Desculpem reviver o topico, mais eu testei o script  e não funciou aqui e também n deu erro no console, meu servidor é um mapa baiak 10.10