AN

Removendo Erro Withdraw Tfs E Tcs!

Por Antharaz, 23 de fev. de 2010 em Tutoriais de Scripting

2
1.6k
AntharazA
23 de fevereiro de 2010 às 13:56

Podem reparar que ao utilizarem a função doPlayerWithdrawMoney no console aparece um erro e o dinheiro não é transferido...

 

Como arrumar:

 

Abra o arquivo 050-function da pasta data/lib e reparem esta parte:

 

function doPlayerWithdrawMoney(cid, amount)

if(not getBooleanFromString(getConfigInfo('bankSystem'))) then

return false

end

local balance = getPlayerBalance(cid)

if ((amount > balance) or not (doPlayerAddMoney(cid, amount))) then

return false

end

 

doPlayerSetBalance(cid, balance - amount)

return true

end

 

Problema: O server interpreta o amount como uma string(tipo texto) e não consegue fazer a comparação com o balance que é do tipo number(número), então usamos a função tonumber() para transformar a string em number, ou seja, substitua a parte de vermelho por tonumber(amount) ficando assim:

 

function doPlayerWithdrawMoney(cid, amount)

if(not getBooleanFromString(getConfigInfo('bankSystem'))) then

return false

end

local balance = getPlayerBalance(cid)

if ((tonumber(amount) > balance) or not (doPlayerAddMoney(cid, amount))) then

return false

end

 

doPlayerSetBalance(cid, balance - amount)

return true

end

 

 

E voalá... funciona =D

 

 

Se postarem em outros lugares postem os créditos ¬¬

4 meses depois...
matheusrpM
13 de junho de 2010 às 10:36

Cara, o meu serve ta com bug de quando voce da !withdraw -10000 mesmo o player não tendo ganha o dinheiro :S o que eu posso fazer?

 

Valeu abraços!

Editado Junho 13 por matheusrp