Duff1995 Posted June 24, 2021 Posted June 24, 2021 function voolscomercial () if (getPlayerMoney(source) < 5) then outputChatBox("#000000[ #FF0000AEROPORTO #000000] #ffffffVocê não tem dinheiro suficiente $"..PrecoLSComercial.."", source, 255, 255, 255, true) else takePlayerMoney(source, ""..PrecoLSComercial.."") --Remover Dinheiro setElementPosition ( source, 1642.058, -2334.951, 13.547 ) outputChatBox("#000000[ #FF0000AEROPORTO #000000] #ffffffVocê acaba de ir para LS por R$"..PrecoLSComercial.." ", player, 255,255,255,true) end end addEvent("comercials",true) addEventHandler ( "comercials", getRootElement(), voolscomercial ) no caso eu queria adicionar o ( "..PrecoLSComercial.." ) na linha 2 no lugar do numero 5 mas retorna erro no debug (attempt to compare number whit string)
Other Languages Moderators androksi Posted June 25, 2021 Other Languages Moderators Posted June 25, 2021 Olá. Basta você colocar o PrecoLSComercial ali no lugar do 5. Não precisa concatenar. Pra ter certeza de que será um número, use: tonumber(PrecoLSComercial) 1
Duff1995 Posted June 25, 2021 Author Posted June 25, 2021 function voolscomercial () if (getPlayerMoney(source) < PrecoLSComercial) then if tonumber(PrecoLSComercial) then --if (getPlayerMoney(source) < 5) then outputChatBox("#000000[ #FF0000AEROPORTO #000000] #ffffffVocê não tem dinheiro suficiente $"..PrecoLSComercial.."", source, 255, 255, 255, true) else takePlayerMoney(source, ""..PrecoLSComercial.."") --Remover Dinheiro setElementPosition ( source, 1642.058, -2334.951, 13.547 ) outputChatBox("#000000[ #FF0000AEROPORTO #000000] #ffffffVocê acaba de ir para LS por R$"..PrecoLSComercial.." ", player, 255,255,255,true) end end end addEvent("comercials",true) addEventHandler ( "comercials", getRootElement(), voolscomercial ) então na teoria ficaria assim? porem mesmo retornou o mesmo problema no debug, "sou iniciante", vou explicar melhor como estou fazendo o mod pois pode ser algo errado Minha pasta do mod https://imgur.com/JAENiUB dentro do edits está assim PrecoLSComercial = "5000" é dai que estou tirando o PrecoLSComercial que estou colocando no Duff_S server, e que quero colocar na getPlayerMoney
Other Languages Moderators androksi Posted June 25, 2021 Other Languages Moderators Posted June 25, 2021 Apenas remova as aspas do "5000", pois é pra ser um número. A partir do momento que você coloca " (aspas) ela vira uma string. Sendo assim, a função getPlayerMoney retorna o dinheiro do jogador (número), ao comparar ali na condição, o número seria diferente de uma string, por isso o erro. Recomendo que você dê uma lida neste tutorial. Além disso, na função takePlayerMoney, você não deve usar aspas. Apenas deixe a variável.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now