Fist Posted September 6, 2015 Share Posted September 6, 2015 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
JR10 Posted September 6, 2015 Share Posted September 6, 2015 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. Link to comment
Fist Posted September 6, 2015 Author Share Posted September 6, 2015 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
Addlibs Posted September 6, 2015 Share Posted September 6, 2015 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
Fist Posted September 6, 2015 Author Share Posted September 6, 2015 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
Addlibs Posted September 6, 2015 Share Posted September 6, 2015 guiGridListGetSelectedItem --also, check the example there Link to comment
Fist Posted September 6, 2015 Author Share Posted September 6, 2015 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
Addlibs Posted September 6, 2015 Share Posted September 6, 2015 How is the position stored? A string of comma separated numbers, or a table of numbers? Link to comment
Fist Posted September 6, 2015 Author Share Posted September 6, 2015 How is the position stored? A string of comma separated numbers, or a table of numbers? Like this, i think its wrong. guiGridListSetItemData(GUIEditor.gridlist[1], row, column, "" .. vX .. ", " .. vY .. ", " .. vZ .. "", false, false) Link to comment
Addlibs Posted September 6, 2015 Share Posted September 6, 2015 Yeah, it just complicates things - store it as {vX, vY, vZ} and retrieve with vX, vY, vZ = unpack(gridlistItemData) Link to comment
Fist Posted September 6, 2015 Author Share Posted September 6, 2015 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
Addlibs Posted September 6, 2015 Share Posted September 6, 2015 Is thePlayer defined within that function? Link to comment
Fist Posted September 6, 2015 Author Share Posted September 6, 2015 Is thePlayer defined within that function? with what function? Link to comment
Addlibs Posted September 6, 2015 Share Posted September 6, 2015 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? Link to comment
Fist Posted September 6, 2015 Author Share Posted September 6, 2015 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
Addlibs Posted September 6, 2015 Share Posted September 6, 2015 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. Link to comment
Fist Posted September 6, 2015 Author Share Posted September 6, 2015 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
Fist Posted September 7, 2015 Author Share Posted September 7, 2015 hmm, still i need help with that setElementPosition, it doesnt work for me. EDIT: SOLVED! i just needed to make a local variable with GetLocalPlayer(), thanks MrTasty for helping me out with coordinates. 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