Jump to content

ayuda con buscar player en una lista


JuanM27

Recommended Posts

Posted

hola que tal, tengo un problema.

hice una gui con un Texto (guiCreateEdit), y una lista que carga todos los players.

hasta hay vamos bien. lo que pasa es que no me funciona el evento onClientGUIChanged (porque seguramente lo hice mal)

bueno en el evento puse lo siguente.

function BuscaPlayer () 
if ( source == BuscaPlayer ) then -- el editbox 
guiGridListClear ( Players ) 
local text = guiGetText ( BuscaPlayer ) 
if ( text == "" ) then 
for id, player in ipairs(getElementsByType("player")) do 
local row = guiGridListAddRow ( Players ) 
guiGridListSetItemText ( Players, row, column, getPlayerName ( player ), false, false ) 
end 
else 
for id, player in ipairs ( getElementsByType ( "player" ) ) do 
if ( string.find ( string.upper ( getPlayerName ( player ) ), string.upper ( text ), 1, true ) ) then 
guiGridListSetItemText ( Players, row, column, getPlayerName ( player ), false, false ) 
end 
end 
end  
end 
end 

pero no lo hace, y en el debugscript no me sale ningun error, ni warning, por que sera?

saludos

n-560x95_FFFFFF_FFFFFF_000000_000000.png
Posted

Talvez el problema no este en esa funcion, postea el resto del script.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted
Talvez el problema no este en esa funcion, postea el resto del script.
Celular2 = guiCreateStaticImage( 450,0,350,1000, "imagenes/ipad.png", false) 
info20 = guiCreateLabel(0.40,0.13,0.9,0.3,"Marcar Players",true,Celular2) 
guiLabelSetColor(info20, 0, 255, 0) 
BuscaPlayer = guiCreateEdit(0.13, 0.17, 0.50, 0.06, "", true, Celular2) 
Find = guiCreateStaticImage( 250,115,20,20, "imagenes/search.png", false, Celular2) 
Players = guiCreateGridList(0.12, 0.25, 0.76, 0.50, true, Celular2) 
column = guiGridListAddColumn( Players, "Players", 0.93, true, Celular2 ) 
function cargaplayer() 
for id, player in ipairs(getElementsByType("player")) do 
local row = guiGridListAddRow ( Players ) 
guiGridListSetItemText ( Players, row, column, getPlayerName ( player ), false, false ) 
end 
end 

function guiClick1 (button, state, absoluteX, absoluteY) 
    if (source == PlayerBl) then   -- Para player blips. 
    guiGridListClear ( Players ) 
    cargaplayer() 
    addEventHandler ( "onClientGUIChanged", Celular2, BuscaPlayer ) 
        guiSetVisible ( Celular2, true ) 
        guiSetVisible ( Celular, false ) 
    end 
  end 
  
addEventHandler ("onClientGUIClick", getRootElement(), guiClick1) 

ese es el codigo que hice, si hace falta pongo la otra parte de codigo que es del menu del cecular que estoy haciendo.

n-560x95_FFFFFF_FFFFFF_000000_000000.png
Posted

Como queres que funcione si de elemento le pones la imagen, no el edit para buscar.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

ah listo hay lo modifique y (anda) pero con un error.

cuando escribo algo en el edit la lista de player se vacia, y en debugscript me dice lo siguiente

Bad argument @ 'guiGridListSetItemText' [Expedted number at argument 2, got nil]

ah debido a que sale ese waning?

n-560x95_FFFFFF_FFFFFF_000000_000000.png
Posted

Te olvidaste de:

local row = guiGridListAddRow ( Players ) 

despues del 'if'.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted
Te olvidaste de:
local row = guiGridListAddRow ( Players ) 

despues del 'if'.

ah no me di cuenta.

bueno hay funciona, muchas gracias solid

n-560x95_FFFFFF_FFFFFF_000000_000000.png
Posted

No hay de que.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

  • Recently Browsing   0 members

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