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.

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

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.

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
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 

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

Works perfectly here, I can warp to myself.

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

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 :(

Welcom to my server Q.5

Current game type in my server Drift

350x20_FFFFFF_FFFFFF_000000_000000.png

my Email : [email protected]

Programming level: 90%

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

Welcom to my server Q.5

Current game type in my server Drift

350x20_FFFFFF_FFFFFF_000000_000000.png

my Email : [email protected]

Programming level: 90%

Posted
any help?????

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

CiTLh.png
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

Welcom to my server Q.5

Current game type in my server Drift

350x20_FFFFFF_FFFFFF_000000_000000.png

my Email : [email protected]

Programming level: 90%

  • 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...