Jump to content

[Help] GUI Grid List


Fist

Recommended Posts

Hello everyone!

How i can make so item in gridlist is with a name "example: Tower" and it has a data which position where that tower is, and then when i trigger button to use that position, it teleports player to that tower. I was this thinking this so long and i almost did it but am stuck at placing position data in that grid item.

But please if u can explain it instead of giving whole code. It would be appreciated. :)

Link to comment
You can store the coordinates in a table where the name of the location is the key. The key can also be an id, perhaps stored with guiGridListSetItemData.

There are plenty of ways to do what you want.

Yes, i already used it to check or i placed coordinates correct, and it is correct. But there is another thing what i dont know, how i can attach those cordinates to a button which will teleport to those coordinates?

Link to comment

You don't attach it to a button - you create a button and attach a function to it, one that will check with item from the gridlist is selected, chiefly, the name of the item, and it's data (along with the position stored within), and just setElementPosition to that position.

Link to comment
You don't attach it to a button - you create a button and attach a function to it, one that will check with item from the gridlist is selected, chiefly, the name of the item, and it's data (along with the position stored within), and just setElementPosition to that position.

and how i can do it so it checks which item is selected?

Link to comment
guiGridListGetSelectedItem --also, check the example there 

lol, im so blind.

also i did use it but when i press it nothing happens, probably i did something wrong. here is code

function findItem(thePlayer) 
     local TowerCoords = guiGridListGetItemData(GUIEditor.gridlist[1], guiGridListGetSelectedItem(GUIEditor.gridlist[1])) 
     setElementPosition(thePlayer, TowerCoords) 
end 

edit: i store cordinates in 1 local called TowerCoords which looks like this when u export it to chat or where ever u want "1777.56640625, -1889.857421875, 13.087238311768".

Link to comment
How is the position stored? A string of comma separated numbers, or a table of numbers?

Like this, i think its wrong. :S

  
guiGridListSetItemData(GUIEditor.gridlist[1], row, column, "" .. vX .. ", " .. vY .. ", " .. vZ .. "", false, false) 
  

Link to comment
Yeah, it just complicates things - store it as
{vX, vY, vZ} 

and retrieve with

vX, vY, vZ = unpack(gridlistItemData) 

Still doesnt work.

EDIT:

I actually understund how it works, so code atm is like this, i checked it outputed on chatbox the coords and was all perfectly fine, but when i set it them to setElementPosition function it just doesnt do anything. why?

  
function findVehicle(thePlayer) 
    local vX, vY, vZ = unpack(guiGridListGetItemData(GUIEditor.gridlist[1], guiGridListGetSelectedItem(GUIEditor.gridlist[1]))) 
    setElementPosition(thePlayer, vX, vY, vZ) 
end 
  

Link to comment
  
function findVehicle(thePlayer) 
    local vX, vY, vZ = unpack(guiGridListGetItemData(GUIEditor.gridlist[1], guiGridListGetSelectedItem(GUIEditor.gridlist[1]))) 
    setElementPosition(thePlayer, vX, vY, vZ) 
end 

This function, is thePlayer a non-nil variable?

thePlayer is only in that function, no where else.

Link to comment
When the function is called, is anything passed as the 1st parameter? If not, it explains why you don't get teleported - setElementPosition expects a ped/player as the first argument, not a nil.

and how i can set it so it doesnt past 1st parameter?

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