Ganhar Gold ao Matar Player Level 700+

surfnament
em Scripts

surfnament

avatar
Artesão
Artesão

INFOS

Grupo: ArtesãoRegistrado: 17/09/11Posts: 100

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

Lucas CP

avatar
Campones
Campones

INFOS

Grupo: CamponesRegistrado: 13/04/15Posts: 54

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

surfnament

avatar
Artesão
Artesão

INFOS

Grupo: ArtesãoRegistrado: 17/09/11Posts: 100

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

Lucas CP

avatar
Campones
Campones

INFOS

Grupo: CamponesRegistrado: 13/04/15Posts: 54

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"

surfnament

avatar
Artesão
Artesão

INFOS

Grupo: ArtesãoRegistrado: 17/09/11Posts: 100

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

Lucas CP

avatar
Campones
Campones

INFOS

Grupo: CamponesRegistrado: 13/04/15Posts: 54

Você ta registrando no login.lua?

surfnament

avatar
Artesão
Artesão

INFOS

Grupo: ArtesãoRegistrado: 17/09/11Posts: 100

Sim:

registerCreatureEvent(cid, "Gold")


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

 

 

Lucas CP

avatar
Campones
Campones

INFOS

Grupo: CamponesRegistrado: 13/04/15Posts: 54

registerCreatureEvent(cid, "Gold")

muda para

registerCreatureEvent(cid, gold")

surfnament

avatar
Artesão
Artesão

INFOS

Grupo: ArtesãoRegistrado: 17/09/11Posts: 100

Funcionou!! Obrigadooo!!!

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

Lucas CP

avatar
Campones
Campones

INFOS

Grupo: CamponesRegistrado: 13/04/15Posts: 54

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

surfnament

avatar
Artesão
Artesão

INFOS

Grupo: ArtesãoRegistrado: 17/09/11Posts: 100

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 CP

avatar
Campones
Campones

INFOS

Grupo: CamponesRegistrado: 13/04/15Posts: 54

deixa com onKill na script e no xml deixa assim:

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

Danihcv

I'm Coordenador, Bitch!
avatar
Conde
Conde

INFOS

Grupo: CondeRegistrado: 08/04/15Posts: 926Gênero: Masculino

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

Te ajudei?? REP+ e ficamos quites... happyy.png

Atenciosamente,
                    Danihcv.
                           Abraços!

felipy491

avatar
Campones
Campones

INFOS

Grupo: CamponesRegistrado: 26/07/16Posts: 1Gênero: Masculino

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