Blaawee Posted January 20, 2012 Share Posted January 20, 2012 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 Link to comment
codeluaeveryday Posted January 20, 2012 Share Posted January 20, 2012 viewtopic.php?t=33061 Link to comment
Castillo Posted January 20, 2012 Share Posted January 20, 2012 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. Link to comment
Blaawee Posted January 20, 2012 Author Share Posted January 20, 2012 thx solid that's work , but when i disabled the hex color code i can't warp to any again Link to comment
Castillo Posted January 20, 2012 Share Posted January 20, 2012 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. Link to comment
Blaawee Posted January 20, 2012 Author Share Posted January 20, 2012 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 Link to comment
Castillo Posted January 20, 2012 Share Posted January 20, 2012 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 Link to comment
Blaawee Posted January 21, 2012 Author Share Posted January 21, 2012 same thing i can't warp to any one and the hex color disabled Link to comment
Castillo Posted January 21, 2012 Share Posted January 21, 2012 Works perfectly here, I can warp to myself. Link to comment
Blaawee Posted January 21, 2012 Author Share Posted January 21, 2012 yes you can with your self and with others player's you can't Link to comment
MR.S3D Posted January 21, 2012 Share Posted January 21, 2012 hi guys how to set lable color in the freeroam gamemode this label {'lbl', text='welcom'}, Link to comment
Blaawee Posted January 21, 2012 Author Share Posted January 21, 2012 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 Link to comment
MR.S3D Posted January 21, 2012 Share Posted January 21, 2012 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 Link to comment
Blaawee Posted January 21, 2012 Author Share Posted January 21, 2012 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) ) Link to comment
MR.S3D Posted January 21, 2012 Share Posted January 21, 2012 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 Link to comment
TAPL Posted January 21, 2012 Share Posted January 21, 2012 any help????? Instead of waiting someone for give you a ready code, keep trying to make the code working by yourself. Link to comment
MR.S3D Posted January 21, 2012 Share Posted January 21, 2012 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 thanks you Link to comment
☠ RaZeR ☠ Posted July 26, 2016 Share Posted July 26, 2016 same thing i can't warp to any one and the hex color disabled +1 Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now