joao2235 Posted September 4, 2019 Posted September 4, 2019 Estou tentando obter o valor inteiro do número de armas que o jogador possuí em mãos. Acabei encontrando alguns scripts na internet que informar no chat quais são as armas que o jogador tem, mas preciso obter o valor inteiro e não a lista de armas. Segue abaixo o script: function getPedWeapons(ped) local playerWeapons = {} if ped and isElement(ped) and getElementType(ped) == "ped" or getElementType(ped) == "player" then for i=2,9 do local wep = getPedWeapon(ped,i) if wep and wep ~= 0 then table.insert(playerWeapons,wep) end end else return false end return playerWeapons end function SaberArmas (player) outputChatBox("Armas (Caso tenha armas elas serão listadas abaixo!)",player,255,0,0) for i,wep in ipairs(getPedWeapons(player)) do outputChatBox("Você tem: " .. getWeaponNameFromID(wep),player,0,255,0) end end addEventHandler("onMarkerHit", MarkerInfo, SaberArmas) Preciso obter o valor inteiro, se alguém puder me ajudar. Desde já agradeço!
czarsight Posted September 4, 2019 Posted September 4, 2019 function getPedWeapons(ped) local playerWeapons = {} if ped and isElement(ped) and getElementType(ped) == "ped" or getElementType(ped) == "player" then for i=2,9 do local wep = getPedWeapon(ped,i) if wep and wep ~= 0 then table.insert(playerWeapons,wep) end end else return false end return playerWeapons end function SaberArmas (player) qtdArmas = 0 for i,wep in ipairs(getPedWeapons(player)) do qtdArmas = i end if qtdArmas > 0 then outputChatBox("Você tem: " ..qtdArmas.. " armas") else outputChatBox("Você não tem nenhum armamento!") end end addEventHandler("onMarkerHit", MarkerInfo, SaberArmas) Tente isso, meu jovem.
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