Jump to content

[HELP] SearchBox


GrubaS

Recommended Posts

What's wrong? i can search maps :x

debugscript 3:

f5db9aac48a20.png

Lua Code:

addEventHandler("onClientGUIChanged", searchBox, 
    function(element) 
        for id, gamemode in pairs ( aGamemodeMapTable ) do 
            if ( gamemode.name == "Race" ) then 
                for id, map in ipairs ( gamemode.maps ) do 
                    if string.find ( string.lower ( map.name ), string.lower ( guiGetText(mapsearch):lower ( ) ), 0, true ) ~= nil then 
        end 
    end 
end 
end 
end 
) 

Link to comment

Client Side,

local players = getElementsByType("player") 
local gme = getLocalPlayer ()
local x,y = guiGetScreenSize ()
local addedTeams = {}
local addedMaps = {}
local addedMapsEdit = {}
local countTable = {}
local countTableEdit = {}
local alivept = {}
local showTeams = false
local defaultRounds = "5"
 
function openCloseWindow (maps)
mapsTable = maps
if not guiGetVisible(addsWindow) then
guiSetVisible(addsWindow,true)
showCursor(true)
local r, g, b
    if getPlayerTeam(gme) then
    r, g, b = getTeamColor(getPlayerTeam(gme))
    else
    r, g, b = 255, 255, 255
    end
--callServerFunction("outputChatBox","* "..getPlayerName(gme).."#ffffff opened CWShit window", root, r, g, b,true)
fillingColumns()
else
guiSetVisible(addsWindow,false)
showCursor(false)
--fillingColumns()
end
end
 
 
function fillingColumns()
guiGridListClear(teamsList)
local teams = getElementsByType("team")
    for i, v in ipairs (teams) do
    row =  guiGridListAddRow ( teamsList )
    guiGridListSetItemText (teamsList, row, 1,  getTeamName(v), false, false)
    end
    --------
    guiGridListClear(teamsList2)
    for i, v in ipairs (addedTeams) do
    row =  guiGridListAddRow (teamsList2)
    guiGridListSetItemText (teamsList2, row, 1, getTeamName(v), false, false)
    guiGridListSetItemText (teamsList2, row, 2, countTable[getTeamName(v)], false, false)
    end
    --------
    guiGridListClear(mapsList)
    if mapsTable then
    for i, v in ipairs (mapsTable) do
    row =  guiGridListAddRow ( mapsList )
    guiGridListSetItemText (mapsList, row, 1,  mapsTable[i], false, false)
    end
    end
    --------
    guiGridListClear(mapsList2)
    --outputChatBox(#addedMaps.."   "..#addedMapsEdit)
    for i, v in ipairs (addedMaps) do
    row =  guiGridListAddRow (mapsList2)
    guiGridListSetItemText (mapsList2, row, 1, v, false, false)
    end
    --------
end
 
addsWindow = guiCreateWindow(520,20,450,400,"CWShit",false)
tabPanel = guiCreateTabPanel ( 0, 0.065, 1, 1, true, addsWindow )
tabTeams = guiCreateTab( "Teams", tabPanel )
tabMaps = guiCreateTab( "Maps", tabPanel )
guiSetVisible(addsWindow, false)
------------
teamsList = guiCreateGridList(0.04, 0.04, 0.44, 0.92,true,tabTeams)
guiGridListSetSelectionMode(teamsList, 2)
teamsColumn =  guiGridListAddColumn(teamsList,"Teams",1)
guiGridListSetColumnWidth ( teamsList, teamsColumn, 0.9, true )
saveButton1 = guiCreateButton(0.52,0.88,0.31,0.08,"Save",true,tabTeams)
closeButton1 = guiCreateButton(0.86,0.88,0.1,0.08,"X",true,tabTeams)
------------
teamsList2 = guiCreateGridList(0.52, 0.04, 0.44, 0.66,true,tabTeams)
guiGridListSetSelectionMode(teamsList2, 1)
addedTColumn = guiGridListAddColumn(teamsList2,"Added teams",1)
countColumn = guiGridListAddColumn(teamsList2,"Count", 2)
guiGridListSetColumnWidth ( teamsList2, addedTColumn, 0.61, true )
guiGridListSetColumnWidth ( teamsList2, countColumn, 0.2, true )
minusCountButton = guiCreateButton(0.52,0.74,0.08,0.085,"-",true,tabTeams)
countEdit = guiCreateEdit(0.63, 0.74, 0.095, 0.08,"", true, tabTeams)
guiEditSetMaxLength (countEdit, 2 )
plusCountButton = guiCreateButton(0.75,0.74,0.08,0.085,"+",true,tabTeams)
 
------------------------------------------------------------------
searchBox = guiCreateEdit(0.04, 0.04, 0.44, 0.06, "Search", true, tabMaps)
mapsList = guiCreateGridList(0.04, 0.13, 0.44, 0.83,true,tabMaps)
guiGridListSetSelectionMode(mapsList, 2)
guiGridListAddColumn(mapsList,"Maps",1)
guiCreateLabel  ( 0.76, 0.79, 0.3, 0.05, "rounds:", true, tabMaps)
roundsEdit = guiCreateEdit(0.86, 0.78, 0.095, 0.07, roundsOnMap or defaultRounds, true, tabMaps)
guiEditSetMaxLength (roundsEdit, 2 )
saveButton2 = guiCreateButton(0.52,0.88,0.31,0.08,"Save",true,tabMaps)
closeButton2 = guiCreateButton(0.86,0.88,0.1,0.08,"X",true,tabMaps)
downButton = guiCreateButton(0.52,0.78,0.1,0.08,"Down",true,tabMaps)
upButton = guiCreateButton(0.634,0.78,0.1,0.08,"Up",true,tabMaps)
------------
mapsList2 = guiCreateGridList(0.52, 0.04, 0.44, 0.7,true,tabMaps)
guiGridListSetSelectionMode(mapsList2,2)
guiGridListAddColumn(mapsList2,"Added maps",1)
 
 
addEventHandler("onClientGUIChanged", searchBox,
    function(element)
        for id, gamemode in pairs ( aGamemodeMapTable ) do
            if ( gamemode.name == "Race" ) then
                for id, map in ipairs ( gamemode.maps ) do
                    if string.find ( string.lower ( map.name ), string.lower ( guiGetText(mapsearch):lower ( ) ), 0, true ) ~= nil then
        end
    end
end
end
end
)
 
addEventHandler( "onClientGUIDoubleClick", teamsList, function()
local selectedRow, selectedCol = guiGridListGetSelectedItem( teamsList )
local selectedTeam = guiGridListGetItemText( teamsList, selectedRow, selectedCol )
if selectedTeam then
table.insert (addedTeams, getTeamFromName (selectedTeam))
row =  guiGridListAddRow (teamsList2)
guiGridListSetItemText (teamsList2, row, 1, selectedTeam, false, false)
end
end, false )
 
addEventHandler( "onClientGUIDoubleClick", teamsList2, function()
local selectedRow, selectedCol = guiGridListGetSelectedItem( teamsList2 )
local selectedTeam = guiGridListGetItemText( teamsList2, selectedRow, selectedCol )
table.remove (addedTeams, selectedRow+1)
guiGridListRemoveRow (teamsList2, selectedRow)
end, false )
 
addEventHandler( "onClientGUIClick", root, function()
if source == closeButton1  or source == closeButton2 then
openCloseWindow ()
elseif source == saveButton1 then
    if addedTeams[2] then
        for i, team in ipairs (addedTeams) do
            if not countTableEdit[getTeamName(team)] then
            countTableEdit[getTeamName(team)] = 0
            end
        end
    countTable = countTableEdit
    callServerFunction("serverAddTeamsCount", gme, addedTeams, countTable)
    else
    outputChatBox ("*#E01B2F Error:#ffffff You need add minimum 2 teams", 255, 255, 255, true )
    end
 
elseif source == saveButton2 then
    if addedMapsEdit[1] then
    local rounds = nil
        if  guiGetText (roundsEdit) > "0"  then
        rounds = tonumber(guiGetText (roundsEdit))
        end
   -- addedMaps = addedMapsEdit
    callServerFunction("serverAddMapsRounds", gme, addedMapsEdit, rounds or defaultRounds)
    else outputChatBox ("*#E01B2F Error:#ffffff .", 255, 255, 255, true )
    end
 
elseif source == teamsList2 then
selectedRow, selectedCol = guiGridListGetSelectedItem( teamsList2)
selectedTeam = guiGridListGetItemText( teamsList2, selectedRow, selectedCol )
    if countTableEdit[selectedTeam] then
    guiSetText  (countEdit, countTableEdit[selectedTeam] )
    end
 
elseif source == plusCountButton and countTableEdit[selectedTeam] then
countTableEdit[selectedTeam] = countTableEdit[selectedTeam] + 1
guiSetText  (countEdit, countTableEdit[selectedTeam])
guiGridListSetItemText (teamsList2, selectedRow, 2, guiGetText (countEdit) , false, false)
 
elseif source == minusCountButton then
countTableEdit[selectedTeam] = countTableEdit[selectedTeam] - 1
guiSetText  (countEdit, countTableEdit[selectedTeam])
guiGridListSetItemText (teamsList2, selectedRow, 2, guiGetText (countEdit) , false, false)
 
elseif source == upButton then
local selectedRow, selectedCol = guiGridListGetSelectedItem( mapsList2 )
local selectedMap = guiGridListGetItemText( mapsList2, selectedRow, selectedCol )
    if selectedMap and selectedRow >= 1  then
   addedMapsEdit[selectedRow+1], addedMapsEdit[selectedRow] = addedMapsEdit[selectedRow], addedMapsEdit[selectedRow+1]
    row = guiGridListInsertRowAfter(mapsList2, selectedRow-2)
    guiGridListSetItemText (mapsList2, row, selectedCol,selectedMap, false, false)
    guiGridListRemoveRow (mapsList2, selectedRow+1)
    end
 
elseif source == downButton then
local selectedRow, selectedCol = guiGridListGetSelectedItem( mapsList2 )
local selectedMap = guiGridListGetItemText( mapsList2, selectedRow, selectedCol )
    if selectedMap and selectedRow >= 0 and selectedRow < #addedMapsEdit-1 then
    addedMapsEdit[selectedRow+1], addedMapsEdit[selectedRow+2] = addedMapsEdit[selectedRow+2], addedMapsEdit[selectedRow+1]
    row = guiGridListInsertRowAfter(mapsList2, selectedRow+1)
    guiGridListSetItemText (mapsList2, row, selectedCol,selectedMap, false, false)
    guiGridListRemoveRow (mapsList2, selectedRow)
    end
end
 
end)
 
addEventHandler( "onClientGUIDoubleClick", mapsList, function()
local selectedRow, selectedCol = guiGridListGetSelectedItem( mapsList )
local selectedMap = guiGridListGetItemText( mapsList, selectedRow, selectedCol )
if selectedMap then
table.insert (addedMapsEdit, selectedMap)
row =  guiGridListAddRow (mapsList2)
guiGridListSetItemText (mapsList2, row, 1, selectedMap, false, false)
end
end, false )
 
addEventHandler( "onClientGUIDoubleClick", mapsList2, function()
local selectedRow, selectedCol = guiGridListGetSelectedItem( mapsList2 )
local selectedMap = guiGridListGetItemText( mapsList2, selectedRow, selectedCol )
table.remove (addedMapsEdit, selectedRow+1)
guiGridListRemoveRow (mapsList2, selectedRow)
end, false )
 
function refreshMapsRounds (maps, rounds)
addedMaps = maps
addedMapsEdit = maps
roundsOnMap = rounds
guiSetText  (roundsEdit, roundsOnMap)
fillingColumns()
end
 
function refreshTablichka(teamsTable, count, state)
addedTeams = teamsTable
countTable = count
--countTableEdit = count
showTeams = state
fillingColumns()
end
 
--function checkAfk()
--end
 
 
 
function startMapClient ()
for i, team in ipairs (addedTeams) do
alivept[getTeamName(team)] = 0
end
end
 
addEventHandler ( "onClientPlayerVehicleEnter", root,
function ()
if
Link to comment

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