Jump to content

[ Help ] guiGridlist Rows.


Sisqo0

Recommended Posts

local GuiWarpElementToMenuElements = {}

local function createWarpElementToMenu(SelectedElement)
	if WarpElementTomenuopen then closeWarpElementToMenu() return end
	WarpElementTomenuopen = true
	guiSetInputMode("no_binds_when_editing")
    if (getElementType(SelectedElement) == "vehicle") then
	    GuiWarpElementToMenuElements[#GuiWarpElementToMenuElements+1] = guiCreateWindow(0,0,350,400,"Warp "..tostring(getVehicleName(SelectedElement)).." To",false)
	else
	    GuiWarpElementToMenuElements[#GuiWarpElementToMenuElements+1] = guiCreateWindow(0,0,350,400,"Warp "..tostring(getPlayerName(SelectedElement)).." To",false)
	end
	WarpElementToWindow = GuiWarpElementToMenuElements[#GuiWarpElementToMenuElements]
	guiWindowSetSizable(WarpElementToWindow,false)
	GuiWarpElementToMenuElements[#GuiWarpElementToMenuElements+1] = guiCreateButton(0.06,0.93,0.4,0.05,"Select",true,WarpElementToWindow)
	WarpElementToSelectButton = GuiWarpElementToMenuElements[#GuiWarpElementToMenuElements]
	guiSetFont(WarpElementToSelectButton, "default-bold-small")
	GuiWarpElementToMenuElements[#GuiWarpElementToMenuElements+1] = guiCreateButton(0.54,0.93,0.4,0.05,"Cancel",true,WarpElementToWindow)
	WarpElementToCancelButton = GuiWarpElementToMenuElements[#GuiWarpElementToMenuElements]
	guiSetFont(WarpElementToCancelButton, "default-bold-small")
	GuiWarpElementToMenuElements[#GuiWarpElementToMenuElements+1]	= guiCreateGridList (0.02,0.06,0.95,0.85,true,WarpElementToWindow )
	WarpElementToGridList = GuiWarpElementToMenuElements[#GuiWarpElementToMenuElements]
	GuiWarpElementToMenuElements[#GuiWarpElementToMenuElements+1]	= guiGridListAddColumn(WarpElementToGridList,"Player",0.475)
	WarpElementToPlayerGridListColumn = GuiWarpElementToMenuElements[#GuiWarpElementToMenuElements]
	GuiWarpElementToMenuElements[#GuiWarpElementToMenuElements+1]	= guiGridListAddColumn(WarpElementToGridList,"Vehicle",0.475)
	WarpElementToVehicleGridListColumn = GuiWarpElementToMenuElements[#GuiWarpElementToMenuElements]
	guiGridListSetSelectionMode(WarpElementToGridList,2)
	for _,vehicle in ipairs (getElementsByType("vehicle")) do
	   local WarpElementToVehicleGridListRow = guiGridListAddRow(WarpElementToGridList)
	   guiGridListSetItemText(WarpElementToGridList,WarpElementToVehicleGridListRow,WarpElementToVehicleGridListColumn,tostring(getVehicleName(vehicle)),false,false)
	   guiGridListSetItemData(WarpElementToGridList,WarpElementToVehicleGridListRow,WarpElementToVehicleGridListColumn,vehicle)
	end
	for _,player in ipairs (getElementsByType("player")) do
	   local WarpElementToPlayerGridListRow = guiGridListAddRow(WarpElementToGridList)
	   guiGridListSetItemText(WarpElementToGridList,WarpElementToPlayerGridListRow,WarpElementToPlayerGridListColumn,tostring(getPlayerName(player)),false,false)
	   guiGridListSetItemData(WarpElementToGridList,WarpElementToPlayerGridListRow,WarpElementToPlayerGridListColumn,player)
	end
end

That's my code in client side

it works perfectly but i have 1 problem

i can't remove the empty rows in player column. please help

Warp-Element-To.png

Link to comment
  • Moderators

@Sisqo0

That is not how a gridlist works.

Each row has multiple columns. Which means that it also has multiple properties.

Each row has property: "Player" & "Vehicle"

 

If you want to separate them, you need 2 gridlists:

Gridlist 1. Row with property "Player"

Gridlist 2. Row with property "Vehicle"

 

 

 

Edited by IIYAMA
Link to comment

@IIYAMA Thanks for your reply, 

I made 2 gridlist before but i got a problem too with selection mode of each gridlist. 

I could select row of player gridlist and row of vehicle at the same time. 

Do you know how to avoid that? 

Edited by Sisqo0
Link to comment
31 minutes ago, Sisqo0 said:

@IIYAMA Thanks for your reply, 

I made 2 gridlist before but i got a problem too with selection mode of each gridlist. 

I could select row of player gridlist and row of vehicle at the same time. 

Do you know how to avoid that? 

Check that - https://wiki.multitheftauto.com/wiki/GuiGridListSetSelectionMode and if this wouldn't work, i think you can simply unselect each other, when clicking on gridlist, with using - https://wiki.multitheftauto.com/wiki/OnClientGUIClick and https://wiki.multitheftauto.com/wiki/GuiGridListSetSelectedItem

 

  • Like 1
Link to comment

@majqq sorry if iam annoying you

i could disable selected items if i selected 2 rows of different gridlists but is there any way to make it if i click on any gridlist rows, the last clicked on the other gridlist would be removed and what i clicked on stay selected only

Link to comment
15 minutes ago, Sisqo0 said:

@majqq sorry if iam annoying you

i could disable selected items if i selected 2 rows of different gridlists but is there any way to make it if i click on any gridlist rows, the last clicked on the other gridlist would be removed and what i clicked on stay selected only

Sorry, but i don't have idea, how it could be done.

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