Ir para conteúdo

Featured Replies

Postado
Mostrar conteúdo oculto

 

[22:51:05.905] [Error - CreatureScript Interface]
[22:51:05.906] data/creaturescripts/scripts/deathbroadcast.lua:onDeath
[22:51:05.906] Description:
[22:51:05.906] data/creaturescripts/scripts/deathbroadcast.lua:39: bad argument #2 to 'max' (number expected, got string)
[22:51:05.906] stack traceback:
[22:51:05.906]     [C]: in function 'max'
[22:51:05.906]     data/creaturescripts/scripts/deathbroadcast.lua:39: in function <data/creaturescripts/scripts/deathbroadcast.lua:35>

 

Postado

 data/creaturescripts/scripts/deathbroadcast.lua:39: bad argument #2 to 'max' (number expected, got string)

 

The error is quite clear it is telling you the line number, what the error is, the function which is causing the error, what is expect, what it received instead.

 

This is the code on line 39

local targetKills = math.max(0, getPlayerStorageValue(cid, config.killStorageValue)) + 1

The error is telling us the 2nd argument which is passed to math.max is returning a string rather than a number.

This is the 2nd argument.

getPlayerStorageValue(cid, config.killStorageValue)

The server believes you are returning a non-number value so there is a simple way to resolve this.

 

You can write a function which will check to see what type of data is being return, the purpose of a function is to provide a blueprint of checks, balances and some form of data manipulation.

 

Create a new function outside of onDeath

function getStorage(cid, storage)
	local value = getPlayerStorageValue(cid, storage)
	if type(value) == "string" then
		value = tonumber(value)
	end
	return value
end

And then you would change the code on line 39 from this

local targetKills = math.max(0, getPlayerStorageValue(cid, config.killStorageValue)) + 1

To this

local targetKills = math.max(0, getStorage(cid, config.killStorageValue)) + 1

 

Participe da conversa

Você pode postar agora e se cadastrar mais tarde. Se você tem uma conta, faça o login para postar com sua conta.

Visitante
Responder

Quem Está Navegando 0

  • Nenhum usuário registrado visualizando esta página.

Estatísticas dos Fóruns

  • Tópicos 96.9k
  • Posts 519.6k

Informação Importante

Confirmação de Termo