Jump to content

Dudas sobre creación de un Inventario


Recommended Posts

  • Administrators

Usas un for-loop en combinación con getPedWeapon

local cantidadWeapons = 5--Un ejemplo no se cuantos slots hay en total. 
for i=1, cantidadWeapons do 
local weap = getPedWeapon(player,i) 
if not weap == 0 then 
--Obtener nombre y agregar a gridlist 
end 
end 

Link to comment

Intente esto, Pero no me resulto

local cantidadWeapons = 5 
for i=1, cantidadWeapons do 
local weap = getPedWeapon(localPlayer,i) 
if not weap == 0 then 
local row = guiGridListAddRow ( itemgrid ) 
guiGridListSetItemText ( itemgrid, row, colu, weap, false, false ) 

Link to comment
Intente esto, Pero no me resulto
local cantidadWeapons = 5 
for i=1, cantidadWeapons do 
local weap = getPedWeapon(localPlayer,i) 
if not weap == 0 then 
local row = guiGridListAddRow ( itemgrid ) 
guiGridListSetItemText ( itemgrid, row, colu, weap, false, false ) 

Postea la función completa.

Link to comment
Además eso solo te va a agregar ID's al gridlist, debes obtener el nombre del arma según ID, si eso es lo que quieres lograr.
local cantidadWeapons = 5 
for i=1, cantidadWeapons do 
local weap = getPedWeapon(localPlayer,i) 
if weap ~= getPedWeapon(localPlayer,0) then 
local row = guiGridListAddRow ( itemgrid ) 
guiGridListSetItemText ( itemgrid, row, 1, getWeaponNameFromID(weap), false, false ) 
end 
end 

Link to comment

Intente con me resulto, perooo, me coloca es todas la cantidad que de balas pero en el arma actual

local cantidadWeapons = 10 
  for i=1, cantidadWeapons do 
   local weap = getPedWeapon(localPlayer,i) 
     if weap ~= getPedWeapon(localPlayer,0) then 
      local row = guiGridListAddRow ( itemgrid ) 
      guiGridListSetItemText ( itemgrid, row, 1,getWeaponNameFromID(weap), false, false ) 
      guiGridListSetItemText ( itemgrid, row, 2,getPedTotalAmmo(localPlayer), false, false ) 

luego al probar esto,se me crashea mta

tidadWeapons do 
   local weap = getPedWeapon(localPlayer,i) 
     if weap ~= getPedWeapon(localPlayer,0) then 
      local row = guiGridListAddRow ( itemgrid ) 
      guiGridListSetItemText ( itemgrid, row, 1,getWeaponNameFromID(weap), false, false ) 
      guiGridListSetItemText ( itemgrid, row, 2,getPedTotalAmmo(localPlayer, weap), false, false ) 

Link to comment
  
    tidadWeapons do 
       local weap = getPedWeapon(localPlayer,i) 
         if weap ~= getPedWeapon(localPlayer,0) then 
          local row = guiGridListAddRow ( itemgrid ) 
          guiGridListSetItemText ( itemgrid, row, 1,getWeaponNameFromID(weap), false, false ) 
          guiGridListSetItemText ( itemgrid, row, 2,getPedTotalAmmo(localPlayer, i), false, false ) 
  

Link to comment
  
    tidadWeapons do 
       local weap = getPedWeapon(localPlayer,i) 
         if weap ~= getPedWeapon(localPlayer,0) then 
          local row = guiGridListAddRow ( itemgrid ) 
          guiGridListSetItemText ( itemgrid, row, 1,getWeaponNameFromID(weap), false, false ) 
          guiGridListSetItemText ( itemgrid, row, 2,getPedTotalAmmo(localPlayer, i), false, false ) 
  

Perfecto me funciono gracias, Pero ahora la pregunta del millon, porque i? si me dice que i es igual a 1, no ?

Link to comment
  
    tidadWeapons do 
       local weap = getPedWeapon(localPlayer,i) 
         if weap ~= getPedWeapon(localPlayer,0) then 
          local row = guiGridListAddRow ( itemgrid ) 
          guiGridListSetItemText ( itemgrid, row, 1,getWeaponNameFromID(weap), false, false ) 
          guiGridListSetItemText ( itemgrid, row, 2,getPedTotalAmmo(localPlayer, i), false, false ) 
  

Perfecto me funciono gracias, Pero ahora la pregunta del millon, porque i? si me dice que i es igual a 1, no ?

es el indice que te otorga el for loops, lo que hiciste para definir todas las armas funciona igual para sus municiones.

Link to comment

Haaa ok perfecto, ya entendí por esa parte, Use bone_attach para crearle una mochila a el jugador quedándome de la siguiente manera:

jugador = getLocalPlayer() 
mochilero = createObject(371,0,0,0) 
exports.bone_attach:attachElementToBone(mochilero,jugador,3,0,-0.1,0,0,0,0) 

Pero el problema es que debido a que es client, solo se muestra a el jugador no a todo el server, Intente triggearlo desde el server pero no me resulto:

function MochilaPed() 
 triggerClientEvent("alIniciar", resourceRoot) 
end 
addEventHandler("onResourceStart", root, MochilaPed) 

function crearMochila() 
jugador = getLocalPlayer() 
 mochilero = createObject(371,0,0,0) 
 exports.bone_attach:attachElementToBone(mochilero,jugador,3,0,-0.1,0,0,0,0) 
end 
addEvent("alIniciar", true) 
addEventHandler("alIniciar", root, crearMochila) 

Link to comment
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...