Jump to content

StefanAlmighty

Members
  • Posts

    143
  • Joined

  • Last visited

Everything posted by StefanAlmighty

  1. Sent, thank you, take your time.
  2. Okay so now for the hard part. I'm not sure how to use table.insert. When the player types in the name and description, it should add a row to the data table which is in server.lua. It's at the bottom of this code. addEventHandler ("onClientGUIClick", root, function () if (source == cancel) then if guiGetVisible(window) ~= nil then guiSetVisible (window, false) showCursor(false) end elseif (source == transport) then local row = guiGridListGetSelectedItem(grid) if row and row == -1 then outputChatBox ("You must selecte the destination",getLocalPlayer(),255,0,0) return false end guiSetVisible(window,false) showCursor(false) triggerServerEvent("warp",getLocalPlayer(),guiGridListGetSelectedItem(grid)+1) elseif (source == create) then if guiGetVisible(window) ~= nil then guiSetVisible (window, false) showCursor(false) guiSetVisible (newLocation, true) showCursor (true) end elseif (source == newLocationCancel) then if guiGetVisible(newLocation) ~= nil then guiSetVisible (newLocation, false) guiSetVisible (window, true) end elseif (source == newLocationCreate) then local name = guiGetText(nameInput) local desc = guiGetText(descInput) if (name == "") then guiSetText (errorMessage, "You have not entered a name for the teleport.") return end if (desc == "") then guiSetText (errorMessage, "You have not entered a description for the teleport.") return end -- How do I create the function which adds a row to my data table (which is located in the server.lua) end end) Here is the data table: local data = { [1] = {"1", "Los Santos", "Pershing Square", 1479.9873046875, -1710.9453125, 13.36874961853, 0, 0, 0}, [2] = {"2", "San Fierro", "Doherty", -1988.5693359375, 507.0029296875, 35.171875, 0, 0, 90}, [3] = {"3", "Las Venturas", "Las Venturas Airport", 1691.6801757813, 1449.1293945313, 10.765375, 0, 0, 268}, } Also, I want it so for the IDs, it grabs the next available ID. So for example, if there was 1, 2 and 4 it would create a teleport as 3.
  3. local nameInput = guiCreateEdit(10, 28, 120, 25, "", false, newLocation) local descInput = guiCreateEdit(134, 28, 256, 25, "", false, newLocation) Yes.
  4. Doesn't seem to work. I've checked the X and Y of my label and there's no issue with them.
  5. Okay so now I'm trying to create GUI text if a player doesn't fill out the name box or the description box. However, the text for some reason does not show up. addEventHandler ("onClientGUIClick", root, function () if (source == cancel) then if guiGetVisible(window) ~= nil then guiSetVisible (window, false) showCursor(false) end elseif (source == transport) then local row = guiGridListGetSelectedItem(grid) if row and row == -1 then outputChatBox ("You must selecte the destination",getLocalPlayer(),255,0,0) return false end guiSetVisible(window,false) showCursor(false) triggerServerEvent("warp",getLocalPlayer(),guiGridListGetSelectedItem(grid)+1) elseif (source == create) then if guiGetVisible(window) ~= nil then guiSetVisible (window, false) showCursor(false) guiSetVisible (newLocation, true) showCursor (true) end elseif (source == newLocationCancel) then if guiGetVisible(newLocation) ~= nil then guiSetVisible (newLocation, false) guiSetVisible (window, true) end elseif (source == newLocationCreate) then if (nameInput == "") then guiSetText (errorMessage, "You have not entered a name for the teleport.") elseif (descInput == "") then guiSetText (errorMessage, "You have not entered a description for the teleport.") else -- ill continue this after end end end) That's the function for when the button is clicked. Here is the code which creates the label which can be found at the top of my script. local errorMessage = guiCreateLabel(10, 78, 380, 22, "", false, newLocation)
  6. When I keep adding more click responses to that function, it messes up, what am I doing wrong? addEventHandler ("onClientGUIClick", root, function () if (source == cancel) then if guiGetVisible(window) ~= nil then guiSetVisible (window, false) showCursor(false) end elseif (source == transport) then local row = guiGridListGetSelectedItem(grid) if row and row == -1 then outputChatBox ("You must selecte the destination",getLocalPlayer(),255,0,0) return false end guiSetVisible(window,false) showCursor(false) triggerServerEvent("warp",getLocalPlayer(),guiGridListGetSelectedItem(grid)+1) elseif (source == create) then if guiGetVisible(window) ~= nil then guiSetVisible (window, false) showCursor(false) guiSetVisible (newLocation, true) showCursor (true) end elseif (source == newLocationCancel) if guiGetVisible(newLocation) ~= nil then guiSetVisible (newLocation, false) guiSetVisible (window, true) end elseif (source == newLocationCreate) if guiGetVisible(newLocation) ~= nil then guiSetVisible (newLocation, false) showCursor (false) end end end) I added more to it, but now the script doesn't work again
  7. Thanks KariiM (again), you've been sooooo much help. Appreciated.
  8. I'm going to bump this because I don't think my question was clear enough. My code is crashing because I added an additional elseif for when the button "Create" is clicked. Here is the code in question: addEventHandler ("onClientGUIClick", root, function () if (source == cancel) then if guiGetVisible(window) ~= nil then guiSetVisible (window, false) showCursor(false) end elseif (source == transport) then local row = guiGridListGetSelectedItem(grid) if row and row == -1 then outputChatBox ("You must selecte the destination",getLocalPlayer(),255,0,0) return false end guiSetVisible(window,false) showCursor(false) triggerServerEvent("warp",getLocalPlayer(),guiGridListGetSelectedItem(grid)+1) elseif (source == create) if guiGetVisible(window) ~= nil then guiSetVisible (window, false) -- closes current gui showCursor(false) end end end) I'll narrow down the specific part which is causing the script to not work. Here it is: elseif (source == create) if guiGetVisible(window) ~= nil then guiSetVisible (window, false) -- closes current gui showCursor(false) end end
  9. I'm working on the GUI for create and delete buttons, so I'll get back to you if I get issues. But for now I'm getting this issue, the script doesn't work because I've added the "elseif (source == create)" onwards. I don't see what I did wrong there? addEventHandler ("onClientGUIClick", root, function () if (source == cancel) then if guiGetVisible(window) ~= nil then guiSetVisible (window, false) showCursor(false) end elseif (source == transport) then local row = guiGridListGetSelectedItem(grid) if row and row == -1 then outputChatBox ("You must selecte the destination",getLocalPlayer(),255,0,0) return false end guiSetVisible(window,false) showCursor(false) triggerServerEvent("warp",getLocalPlayer(),guiGridListGetSelectedItem(grid)+1) elseif (source == create) if guiGetVisible(window) ~= nil then guiSetVisible (window, false) -- closes current gui showCursor(false) end end end)
  10. I'm adding more GUI code to the client file, which will be shown when the player clicks the button "Create" which I've added to the main GUI. The code is this, but according to my server, there's a problem with it because the whole script doesn't work. Here is the code: local status = "Your current position will be used for this marker." local gui.newLocation = guiCreateWindow(0, 0, w, h, "Create Teleport © Almighty", false) centerWindow(gui.newLocation) guiSetVisible(gui.newLocation, false) guiWindowSetSizable(gui.newLocation, false) local gui.valueLabel = guiCreateLabel(10, 53, 54, 15, "Value", false, gui.newLocation) local gui.valueInput = guiCreateEdit(10, 28, 150, 25, "", false, gui.newLocation) local gui.descLabel = guiCreateLabel(164, 53, 118, 15, "Location Description", false, gui.newLocation) local gui.descInput = guiCreateEdit(164, 28, 226, 25, "", false, gui.newLocation) local gui.localeMessage = guiCreateLabel(10, 78, 380, 22, status, false, gui.newLocation) local gui.localeStatusColor = guiLabelSetColor(gui.localeMessage, 255, 255, 255) local gui.newCreate = guiCreateButton(240, 110, 150, 30, "Create", false, gui.newLocation) I added that directly beneath the main 'window' GUI on the client file.
  11. Alright so should I use it in this format? table.insert(data, 1, 4) table.insert(data, 2, "Bayside") table.insert(data, 3, "Teleports you to Bayside in Tierra Robada")
  12. How would I do that? Is there a function which will add a row to my data table?
  13. One more thing, I'm not sure if it's possible but I'll ask. Is it possible to make a command (for example /addnewpos) which adds a new teleport location to the data table from in-game? I'm not sure if it's possible, but I'd like to make my teleport system completely dynamic.
  14. I've been studying the code and I think I know where I went wrong. Although, I've tested it and it works like a charm. Thanks for that.
  15. I want it so anybody can use it for now, and the code works fine. I'd just like to know how to find out which row is selected.
  16. function openTeleportMenu(locationData) if locationData and type(locationData) == "table" then data = locationData end terminateLocationManager() showCursor(true) local w, h = 400, 250 gui.manager = guiCreateWindow(0, 0, w, h, "Admin Teleporter © Almighty", false) exports.global:centerWindow(gui.manager) gui.grid = guiCreateGridList(10, 23, 380, 172, false, gui.manager) gui.colID = guiGridListAddColumn(gui.grid, "ID", 0.1) gui.colName = guiGridListAddColumn(gui.grid, "Name", 0.3) gui.colDesc = guiGridListAddColumn(gui.grid, "Description", 0.5) for v, k in pairs(data) do gui.row = guiGridListAddRow(gui.grid) local a, b = gui.grid, gui.row guiGridListSetItemText(a, b, gui.colID, data[v][1], false, true) guiGridListSetItemText(a, b, gui.colName, data[v][2], false, false) guiGridListSetItemText(a, b, gui.colDesc, data[v][3], false, false) end gui.closeWindow = guiCreateButton(299, 205, 91, 35, "Close", false, gui.manager) addEventHandler("onClientGUIClick", gui.closeWindow, function () if source == gui.closeWindow then terminateLocationManager() end end, false) gui.goWindow = guiCreateButton(5, 205, 91, 35, "Go", false, gui.manager) addEventHandler("onClientGUIClick", gui.goWindow, function () if source == gui.goWindow then local selectedplace = guiGridListGetSelectedItem(gui.manager) if selectedplace == 1 -- LS setElementPosition(getRootElement(), data[ls][4], data[ls][5], data[ls[6]) setElementRotation(getRootElement(), 0, 0, data[ls][9]) setElementInterior(getRootElement(), data[ls][7]) setElementDimension(getRootElement(), data[ls][8]) end end end, false) end addCommandHandler("tpmenu", openTeleportMenu, false, false) It's on line 28 - 39.
  17. gui.goWindow = guiCreateButton(5, 205, 91, 35, "Go", false, gui.manager) addEventHandler("onClientGUIClick", gui.goWindow, function () if source == gui.goWindow then local selectedplace = guiGridListGetSelectedItem(gui.manager) if selectedplace == 1 -- LS setElementPosition(getRootElement(), data[ls][4], data[ls][5], data[ls[6]) setElementRotation(getRootElement(), 0, 0, data[ls][9]) setElementInterior(getRootElement(), data[ls][7]) setElementDimension(getRootElement(), data[ls][8]) end end end, false) I've tried but I'm not sure how to find out if the player has selected LS, SF or LV. This doesn't work btw.
  18. Okay all good, it's working perfectly. When the player has a row selected and they click "Go" I want it to teleport them to the location. Here's a picture of my GUI: So if the player has Los Santos selected, I want it to teleport them to the LS coordinates in my table.
  19. I modified it a bit so it contains the coordinates, interior, dimension etc. Here: local data = { -- X Y Z Int Dim Rot ls = {"1", "Los Santos", "Teleports you to Pershing Square, Los Santos.", 1479.9873046875, -1710.9453125, 13.36874961853, 0, 0, 0}, sf = {"2", "San Fierro", "Teleports you to Doherty, San Fierro.", -1988.5693359375, 507.0029296875, 35.171875, 0, 0, 90}, lv = {"3", "Las Venturas", "Teleports you to The Strip, Las Venturas", 1691.6801757813, 1449.1293945313, 10.765375, 0, 0, 268}, } I tried looping through them and adding them to my gridlist but it doesn't work, here's the code: for v, k in pairs(data) do gui.row = guiGridListAddRow(gui.grid) local a, b = gui.grid, gui.row guiGridListSetItemText(a, b, gui.colID, data[k][1], false, true) guiGridListSetItemText(a, b, gui.colValue, data[k][2], false, false) guiGridListSetItemText(a, b, gui.colDesc, data[k][3], false, false) end
  20. My gridlist has three columns, so I made a table: local data = { {"1", "Los Santos", "Pershing Square, the heart of Los Santos."} {"2", "DMV", "Department of Motor Vehicles."} } But now it wont work at all, not even the GUI.
  21. How would I create the table? I want it to store an ID, name and description.
  22. StefanAlmighty

    GUI

    So I'm making a teleport system GUI. I've made the GUI, but now I want to create an array and I want it to loop through my array and fill the gridlist with all the teleporter locations in the array? How would I go about doing this?
  23. Ah I was just wondering, it doesn't matter about SDK I guess. I'm trying to create a GUI, I've created this code but it doesn't work? It only shows the cursor, the actual GUI doesn't show. function buildTeleportGUI() local screenWidth, screenHeight = guiGetScreenSize() local windowWidth, windowHeight = 384, 210 local left = screenWidth/2 - windowWidth/2 -- grabs the center of the screen local top = screenHeight/2 - windowHeight/2 mainTeleportWindow = guiCreateWindow(left, top, windowWidth, windowHeight, "Admin Teleporter © Almighty", true) closeTeleportWindowBtn = guiCreateButton(left, top, windowWidth, windowHeight, "Close", true, mainTeleportWindow) guiSetVisible(mainTeleportWindow, false) end function openTeleportGUI(playerSource) guiSetVisible(mainTeleportWindow, true) showCursor(true) end addCommandHandler("gotoplace", openTeleportGUI, false, false) addEventHandler("onClientResourceStart", getResourceRootElement(), function () buildTeleportGUI() end )
×
×
  • Create New...