Matevsz Posted January 5, 2017 Share Posted January 5, 2017 How to do that when you drive a car in the marker appeared in the name of the car gridlist column? InfoCar = createMarker(-2052.3999023438, 170.5, 27.799999237061, "cylinder", 4, 255, 0, 0, 0) carsPanel = guiCreateWindow(10, (screenH - 372) / 2, 836, 372, "Car", false) gridList = guiCreateGridList(10, 29, 669, 287, false, carsPanel) column1 = guiGridListAddColumn(gridList, "Model", 0.3) row = guiGridListAddRow(gridList) nameCar = guiGridListSetItemText(gridList, 0, 1, "-", false, false) Link to comment
^iiEcoo'x_) Posted January 5, 2017 Share Posted January 5, 2017 -- # Client e local Vehicles = { {'Name',id}, {'Name',id} } for _,v in ipairs ( Vehicles ) do local row = guiGridListAddRow ( grid ) guiGridListSetItemText ( grid , row , 1 , v[1] , false , false ) guiGridListSetItemData ( grid , row , 1 , v[2] ) end Link to comment
myonlake Posted January 5, 2017 Share Posted January 5, 2017 (edited) You can use onClientMarkerHit to detect that. -- Get the screen size (width and height) screenW, screenH = guiGetScreenSize( ) InfoCar = createMarker(-2052.3999023438, 170.5, 27.799999237061, "cylinder", 4, 255, 0, 0, 0) -- This is triggered when the InfoCar marker is hit addEventHandler( 'onClientMarkerHit', InfoCar, function( hitPlayer, matchingDimension ) -- If it was hit in the wrong dimension, or panel is already open, or the hitPlayer is not the localPlayer, we stop here if ( not matchingDimension ) or ( isElement( carsPanel ) ) or ( hitPlayer ~= localPlayer ) then return end carsPanel = guiCreateWindow(10, (screenH - 372) / 2, 836, 372, "Car", false) gridList = guiCreateGridList(10, 29, 669, 287, false, carsPanel) column1 = guiGridListAddColumn(gridList, "Model", 0.3) -- Create a new row into the grid list row = guiGridListAddRow(gridList) -- Get the current vehicle local vehicle = getPedOccupiedVehicle( localPlayer ) -- Get the name of the vehicle, and use "-" by default local vehicleName = vehicle and getVehicleName( vehicle ) or "-" -- Set the text for the created row guiGridListSetItemText(gridList, row, 1, vehicleName, false, false) end ) -- This is triggered when the InfoCar marker is left addEventHandler( 'onClientMarkerLeave', InfoCar, function( leftPlayer, matchingDimension ) -- If the leftPlayer matches our localPlayer, and dimension matches, and we have a panel open, we destroy the panel if ( leftPlayer == localPlayer ) and ( matchingDimension ) and ( isElement( carsPanel ) ) then destroyElement( carsPanel ) end end ) Tested and works fine. Edited January 5, 2017 by myonlake 1 Link to comment
Snow-Man Posted January 5, 2017 Share Posted January 5, 2017 guiGridListClear you forget it Link to comment
myonlake Posted January 5, 2017 Share Posted January 5, 2017 3 minutes ago, Snow-Man said: guiGridListClear you forget it You don't need it if you always re-create the window. Link to comment
Matevsz Posted January 5, 2017 Author Share Posted January 5, 2017 1 hour ago, myonlake said: You can use onClientMarkerHit to detect that. -- Get the screen size (width and height) screenW, screenH = guiGetScreenSize( ) InfoCar = createMarker(-2052.3999023438, 170.5, 27.799999237061, "cylinder", 4, 255, 0, 0, 0) -- This is triggered when the InfoCar marker is hit addEventHandler( 'onClientMarkerHit', InfoCar, function( hitPlayer, matchingDimension ) -- If it was hit in the wrong dimension, or panel is already open, or the hitPlayer is not the localPlayer, we stop here if ( not matchingDimension ) or ( isElement( carsPanel ) ) or ( hitPlayer ~= localPlayer ) then return end carsPanel = guiCreateWindow(10, (screenH - 372) / 2, 836, 372, "Car", false) gridList = guiCreateGridList(10, 29, 669, 287, false, carsPanel) column1 = guiGridListAddColumn(gridList, "Model", 0.3) -- Create a new row into the grid list row = guiGridListAddRow(gridList) -- Get the current vehicle local vehicle = getPedOccupiedVehicle( localPlayer ) -- Get the name of the vehicle, and use "-" by default local vehicleName = vehicle and getVehicleName( vehicle ) or "-" -- Set the text for the created row guiGridListSetItemText(gridList, row, 1, vehicleName, false, false) end ) -- This is triggered when the InfoCar marker is left addEventHandler( 'onClientMarkerLeave', InfoCar, function( leftPlayer, matchingDimension ) -- If the leftPlayer matches our localPlayer, and dimension matches, and we have a panel open, we destroy the panel if ( leftPlayer == localPlayer ) and ( matchingDimension ) and ( isElement( carsPanel ) ) then destroyElement( carsPanel ) end end ) Tested and works fine. Player must be in the car? Link to comment
myonlake Posted January 5, 2017 Share Posted January 5, 2017 (edited) 45 minutes ago, Matevsz said: Player must be in the car? So... script it yourself? It isn't hard to add one line of code or move one line of code. isPedInVehicle getPedOccupiedVehicle Edited January 5, 2017 by myonlake Link to comment
Matevsz Posted January 7, 2017 Author Share Posted January 7, 2017 And somebody will help to change so that it picks the car up from the marker and not my? By getElementsWithinMarker 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