Jump to content

help with EditBox


Blaawee

Recommended Posts

Posted

i'm tryn to make an edit box to search for the payer in the freeroam gamemode , this is what i did :

function warpsearch( player )  
    guiGridListClear ( search ) 
    if ( source == wndWarp.search ) then 
        guiGridListClear ( playerlist ) 
        local text = guiGetText ( source ) 
        if ( text == "" ) then 
            for id, player in ipairs ( getElementsByType ( "player" ) ) do 
                guiGridListSetItemPlayerName ( playerlist, guiGridListAddRow ( playerlist ), 1, getPlayerName ( player ), false, false ) 
            end 
        end  
    end 
end 
addEventHandler ( "onClientGUIChanged", search, warpsearch ) 

{'txt', id='search', text='', width=250}, 

need help with it

Posted

Ok, this should work:

--------------------------- 
-- Warp to player window 
--------------------------- 
  
function warpInit() 
    local players = table.map(getElementsByType('player'), function(p) return { name = getPlayerName(p) } end) 
    table.sort(players, function(a, b) return a.name < b.name end) 
    bindGridListToTable(wndWarp, 'playerlist', players, true) 
    local gui = getControl(wndWarp, 'search') 
    addEventHandler ( "onClientGUIChanged", gui, findPlayer, false ) 
end 
  
function findPlayer () 
local text = guiGetText ( source ) 
if (text == "") then 
    local players = table.map(getElementsByType('player'), function(p) return { name = getPlayerName(p) } end) 
    table.sort(players, function(a, b) return a.name < b.name end) 
    bindGridListToTable(wndWarp, 'playerlist', players, true) 
    return 
end 
local matches = {} 
for index, playeritem in ipairs (getElementsByType("player")) do 
    if ( string.find ( string.upper ( getPlayerName ( playeritem ) ), string.upper ( text ), 1, true ) ) then 
        table.insert(matches, playeritem) 
    end 
end 
local players = table.map(matches, function(p) return { name = getPlayerName(p) } end) 
table.sort(players, function(a, b) return a.name < b.name end) 
bindGridListToTable(wndWarp, 'playerlist', players, true) 
end 
  
function warpTo(leaf) 
    if not leaf then 
        leaf = getSelectedGridListLeaf(wndWarp, 'playerlist') 
        if not leaf then 
            return 
        end 
    end 
    local player = getPlayerFromNick(leaf.name) 
    if player then 
        server.warpMe(player) 
    end 
    closeWindow(wndWarp) 
end 
  
wndWarp = { 
    'wnd', 
    text = 'Warp to player', 
    width = 300, 
    controls = { 
        {'txt', id='search', text='', width=280}, 
        { 
            'lst', 
            id='playerlist', 
            width=280, 
            height=300, 
            columns={ 
                {text='Player', attr='name'} 
            }, 
            onitemdoubleclick=warpTo 
        }, 
        {'btn', id='warp', onclick=warpTo}, 
        {'btn', id='cancel', closeswindow=true} 
    }, 
    oncreate = warpInit 
} 

I only tested it with myself, so I'm not sure if it completely works.

Posted

I don't understand what do you mean, this script will search for part of names, you can remove HEX codes from the player name just before add to gridlist.

Posted
function findPlayer () 
    local text = guiGetText ( source ) 
    if (text == "") then 
    local players = table.map(getElementsByType('player'), function(p) return { name = getPlayerName(p):gsub("#%x%x%x%x%x%x","") } end) 
    table.sort(players, function(a, b) return a.name < b.name end) 
    bindGridListToTable(wndWarp, 'playerlist', players, true) 
    return end 
    local matches = {} 
    for index, playeritem in ipairs (getElementsByType("player")) do 
        if ( string.find ( string.upper ( getPlayerName ( playeritem ) ), string.upper ( text ), 1, true ) ) then 
        table.insert(matches, playeritem) 
    end 
end 
    local players = table.map(matches, function(p) return { name = getPlayerName(p):gsub("#%x%x%x%x%x%x","") } end) 
    table.sort(players, function(a, b) return a.name < b.name end) 
    bindGridListToTable(wndWarp, 'playerlist', players, true) 
end 

that's what i did

Posted
function warpInit() 
    local players = table.map(getElementsByType('player'), function(p) return { name = getPlayerName(p):gsub("#%x%x%x%x%x%x","") } end) 
    table.sort(players, function(a, b) return a.name < b.name end) 
    bindGridListToTable(wndWarp, 'playerlist', players, true) 
    local gui = getControl(wndWarp, 'search') 
    removeEventHandler ( "onClientGUIChanged", gui, findPlayer, false ) 
    addEventHandler ( "onClientGUIChanged", gui, findPlayer, false ) 
end 
  
function findPlayer () 
    local text = guiGetText ( source ) 
    if (text == "") then 
        local players = table.map(getElementsByType('player'), function(p) return { name = getPlayerName(p):gsub("#%x%x%x%x%x%x","") } end) 
        table.sort(players, function(a, b) return a.name < b.name end) 
        bindGridListToTable(wndWarp, 'playerlist', players, true) 
        return 
    end 
    local matches = {} 
    for index, playeritem in ipairs (getElementsByType("player")) do 
        if ( string.find ( string.upper ( getPlayerName ( playeritem ):gsub("#%x%x%x%x%x%x","") ), string.upper ( text ), 1, true ) ) then 
            table.insert(matches, playeritem) 
        end 
    end 
    local players = table.map(matches, function(p) return { name = getPlayerName(p):gsub("#%x%x%x%x%x%x","") } end) 
    table.sort(players, function(a, b) return a.name < b.name end) 
    bindGridListToTable(wndWarp, 'playerlist', players, true) 
end 

Posted

go to the "gui.lua"

and in the line 199 add this :

guiLabelSetColor ( elem, math.random(0, 255), math.random(0, 255), math.random(0, 255) ) 

I'm not sure if it will work

Posted
go to the "gui.lua"

and in the line 199 add this :

guiLabelSetColor ( elem, math.random(0, 255), math.random(0, 255), math.random(0, 255) ) 

I'm not sure if it will work

not work :(

Posted
go to the "gui.lua"

and in the line 199 add this :

guiLabelSetColor ( elem, math.random(0, 255), math.random(0, 255), math.random(0, 255) ) 

I'm not sure if it will work

not work :(

try this :

guiLabelSetColor ( elem, wnd.align, math.random(0, 255), math.random(0, 255), math.random(0, 255) ) 

Posted
go to the "gui.lua"

and in the line 199 add this :

guiLabelSetColor ( elem, math.random(0, 255), math.random(0, 255), math.random(0, 255) ) 

I'm not sure if it will work

not work

try this :

guiLabelSetColor ( elem, wnd.align, math.random(0, 255), math.random(0, 255), math.random(0, 255) ) 

still not work

Posted
any help?????

Instead of waiting someone for give you a ready code, keep trying to make the code working by yourself.

Posted
any help?????

Instead of waiting someone for give you a ready code, keep trying to make the code working by yourself.

i try to make

now its work :D

thanks you

  • 4 years later...

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

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