Plate Posted January 20, 2013 Posted January 20, 2013 Hola tengo una duda como se puede obtener todas las armas que tiene un jugador y ponerlas en una gridlist?
Castillo Posted January 20, 2013 Posted January 20, 2013 Usa un for-loop con: getPedWeapon guiGridListAddRow guiGridListSetItemText
Plate Posted January 20, 2013 Author Posted January 20, 2013 Me parece que hize cualquier cosa function armas() local weapons = getPedWeapon(source) for _,weapons in ipairs(weapons) local row = guiGridListAddRow ( lista ) guiGridListSetItemText ( lista, row, armas, weapons, false, false ) end end o capas que function armas() for _,weapons in ipairs(getPedWeapon(source)) local row = guiGridListAddRow ( lista ) guiGridListSetItemText ( lista, row, armas, weapons, false, false ) end end
Castillo Posted January 20, 2013 Posted January 20, 2013 Si, me temo que hiciste cualquier cosa. function armas ( ) for slot = 0, 12 do local weapon = getPedWeapon ( localPlayer, slot ) if ( weapon > 0 ) then local row = guiGridListAddRow ( lista ) guiGridListSetItemText ( lista, row, armas, getWeaponNameFromID ( weapon ), false, false ) end end end getPedWeapon no es una tabla, devuelve un arma, el for-loop era de 0 a 12 ( el slot ).
Plate Posted January 20, 2013 Author Posted January 20, 2013 GUIEditor_TabPanel = {} GUIEditor_TabPanel[1] = guiCreateTabPanel(315,183,290,299,false) Tab_Armas = guiCreateTab("Armas",GUIEditor_TabPanel[1]) lista = guiCreateGridList(38,36,208,187,false,Tab_Armas) guiGridListSetSelectionMode(lista,2) armas = guiGridListAddColumn(lista,"Armas",0.6) guiGridListAddColumn(lista,"Municion",0.5) equipar = guiCreateButton(36,229,65,25,"Equipar",false,Tab_Armas) Tirar = guiCreateButton(149,230,65,25,"Tirar",false,Tab_Armas) Tab_Medicinas = guiCreateTab("Medicinas",GUIEditor_TabPanel[1]) Grid_Medicina = guiCreateGridList(34,21,218,185,false,Tab_Medicinas) guiGridListSetSelectionMode(Grid_Medicina,2) guiGridListAddColumn(Grid_Medicina,"Medicinas",0.2) Usar = guiCreateButton(33,222,74,26,"Usar",false,Tab_Medicinas) tirar_medicina = guiCreateButton(139,222,74,26,"Tirar",false,Tab_Medicinas) guiSetVisible(GUIEditor_TabPanel[1], false) function ver() guiSetVisible(GUIEditor_TabPanel[1], true) showCursor(true) end addCommandHandler("prueva",ver) function lol() guiSetVisible(GUIEditor_TabPanel[1], false) showcursor(false) end addCommandHandler("prueva2",lol) function armas ( ) for slot = 0, 12 do local weapon = getPedWeapon ( localPlayer, slot ) if ( weapon > 0 ) then local row = guiGridListAddRow ( lista ) guiGridListSetItemText ( lista, row, armas, getWeaponNameFromID ( weapon ), false, false ) end end end
Castillo Posted January 20, 2013 Posted January 20, 2013 GUIEditor_TabPanel = {} GUIEditor_TabPanel[1] = guiCreateTabPanel(315,183,290,299,false) Tab_Armas = guiCreateTab("Armas",GUIEditor_TabPanel[1]) lista = guiCreateGridList(38,36,208,187,false,Tab_Armas) guiGridListSetSelectionMode(lista,2) guiGridListAddColumn(lista,"Armas",0.6) guiGridListAddColumn(lista,"Municion",0.5) equipar = guiCreateButton(36,229,65,25,"Equipar",false,Tab_Armas) Tirar = guiCreateButton(149,230,65,25,"Tirar",false,Tab_Armas) Tab_Medicinas = guiCreateTab("Medicinas",GUIEditor_TabPanel[1]) Grid_Medicina = guiCreateGridList(34,21,218,185,false,Tab_Medicinas) guiGridListSetSelectionMode(Grid_Medicina,2) guiGridListAddColumn(Grid_Medicina,"Medicinas",0.2) Usar = guiCreateButton(33,222,74,26,"Usar",false,Tab_Medicinas) tirar_medicina = guiCreateButton(139,222,74,26,"Tirar",false,Tab_Medicinas) guiSetVisible(GUIEditor_TabPanel[1], false) function ver() guiSetVisible(GUIEditor_TabPanel[1], true) showCursor(true) armas ( ) end addCommandHandler("prueba",ver) function lol() guiSetVisible(GUIEditor_TabPanel[1], false) showCursor(false) end addCommandHandler("prueba2",lol) function armas ( ) for slot = 0, 12 do local weapon = getPedWeapon ( localPlayer, slot ) if ( weapon > 0 ) then local row = guiGridListAddRow ( lista ) guiGridListSetItemText ( lista, row, 1, getWeaponNameFromID ( weapon ), false, false ) end end end No estabas ejecutando "armas" en ninguna parte, ademas de haber llamado a una variable "armas" igual que la funcion. P.D: Es "prueba" no "prueva".
Plate Posted January 20, 2013 Author Posted January 20, 2013 Gracias solid pero si yo pongo un suponer /prueba /prueba /prueba (muchas veces) empiesa a aparecer muchas veces el arma que tengo equipada en la gridlist
Castillo Posted January 21, 2013 Posted January 21, 2013 Antes del for-loop pone: guiGridListClear ( lista )
Plate Posted January 21, 2013 Author Posted January 21, 2013 Y como puedo poner la municion de cada arma que tiene el usuario y que cuando toque el boton "equipar" se le cambie a esa arma
Alexs Posted January 21, 2013 Posted January 21, 2013 setPedWeaponSlot getSlotFromWeapon getWeaponIDFromName
Castillo Posted January 21, 2013 Posted January 21, 2013 Y como puedo poner la municion de cada arma que tiene el usuario y que cuando toque el boton "equipar" se le cambie a esa arma getPedTotalAmmo Lee los argumentos, no es una tabla.
Plate Posted January 22, 2013 Author Posted January 22, 2013 Hace como 2 horas que estoy probando y me sale siempre lo mismo Bad Argument setPedWeaponSlot y getSlotFromWeapon function setweapon() local ID = getSlotFromWeapon(name) setPedWeaponSlot(source, ID) end addEventHandler("onClientGUIClick", equipar, setweapon, false)
MTA Team 0xCiBeR Posted January 24, 2013 MTA Team Posted January 24, 2013 Te da mal xq usas source...Usa localplayer
Alexs Posted January 24, 2013 Posted January 24, 2013 No defines 'name' y usas 'source' cuando en ese evento el Source es el GUI que clickeas, cámbialo por localPlayer.
Plate Posted January 24, 2013 Author Posted January 24, 2013 Bad argument getSlotFromWeapon y setPedWeaponSlot
Plate Posted January 24, 2013 Author Posted January 24, 2013 function setweapon() local ID = getSlotFromWeapon() setPedWeaponSlot(localPlayer, ID) end addEventHandler("onClientGUIClick", equipar, setweapon, false) y tambien probe con function setweapon() local name = getWeaponNameFromID() local ID = getSlotFromWeapon(name) setPedWeaponSlot(localPlayer, ID) end addEventHandler("onClientGUIClick", equipar, setweapon, false)
Recommended Posts