AlvareZ_ Posted May 26, 2015 Posted May 26, 2015 (edited) Hola, ps como dice el titulo, Como podria obtener todas las Armas que posee un jugador y pasarlas a una gridlist? Edited May 28, 2015 by Guest
MTA Team 0xCiBeR Posted May 26, 2015 MTA Team Posted May 26, 2015 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 DevOps Engineer, Cloud Advocate & Security Engineer(Red Team) | Coffee, Containers & Burp
AlvareZ_ Posted May 26, 2015 Author Posted May 26, 2015 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 )
Tomas Posted May 26, 2015 Posted May 26, 2015 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. Currently developing for International Gaming Community - Join us!
MTA Team 0xCiBeR Posted May 26, 2015 MTA Team Posted May 26, 2015 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. DevOps Engineer, Cloud Advocate & Security Engineer(Red Team) | Coffee, Containers & Burp
Enargy, Posted May 27, 2015 Posted May 27, 2015 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 - Inactivo.
AlvareZ_ Posted May 27, 2015 Author Posted May 27, 2015 Listo, Me funciono, Muchas gracias a todos los que respondieron, Pero tengo otra duda que función podría usar para obtener la cantidad de balas? intente getSlotFromWeapon me funciono pero no me devuelve la cantidad de balas.
Enargy, Posted May 27, 2015 Posted May 27, 2015 Listo, Me funciono, Muchas gracias a todos los que respondieron, Pero tengo otra duda que función podría usar para obtener la cantidad de balas? intente getSlotFromWeapon me funciono pero no me devuelve la cantidad de balas. dentro del mismo for loops, usas getPedTotalAmmo. - Inactivo.
AlvareZ_ Posted May 28, 2015 Author Posted May 28, 2015 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 )
Tomas Posted May 28, 2015 Posted May 28, 2015 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 ) Currently developing for International Gaming Community - Join us!
AlvareZ_ Posted May 28, 2015 Author Posted May 28, 2015 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 ?
Enargy, Posted May 28, 2015 Posted May 28, 2015 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. - Inactivo.
Tomas Posted May 28, 2015 Posted May 28, 2015 Ése i es igual al índice del loop que se está ejecutando, es decir, puede ser 1, 2, 3, 4 o 5 ( ya que fué el máximo que estipulaste ). De todas formas, deberías cambiar ese 5 por un 12, ya que hay 12 slots. Currently developing for International Gaming Community - Join us!
AlvareZ_ Posted May 28, 2015 Author Posted May 28, 2015 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)
Tomas Posted May 28, 2015 Posted May 28, 2015 Debes crearlo desde server-side. Currently developing for International Gaming Community - Join us!
Recommended Posts