TheGamingMann Posted March 24, 2014 Share Posted March 24, 2014 With this script I plan to have it unpack the data (startx, starty, etc.) from the grildist data. But I keep getting the error of Bad Argument: expected Table got nil. I am not sure why this is happening because I do have it as a table in the gridlist as a table. Please help in anyway you can. Thanks in advance. function loadHandler(button, state) if button == "left" and state == "up" then local row, col = guiGridListGetSelectedItem(glistLoadList) local data = guiGridListGetItemData(glistLoadList, row, col) if row and col and row ~= -1 and col ~=-1 then local startx, starty, startz, endx, endy, endz, cash = unpack(data) triggerEvent("startLoad", localPlayer, startx, starty, startz, endx, endy, endz, cash) end end end function beginLoad(startx, starty, startz, endx, endy, endz, cash) createMarker(startx, starty, startz, "checkpoint", 5) createBlip(-102, -70, 5, 0, 2, 0, 0, 255) end addEvent("startLoad", false) addEventHandler("startLoad", localPlayer, beginLoad) Link to comment
Castillo Posted March 24, 2014 Share Posted March 24, 2014 Show me the part where you set this data. Link to comment
TheGamingMann Posted March 24, 2014 Author Share Posted March 24, 2014 Its the same code you helped me with last time. Sorry I left that out. function fillLoadList() local file = xmlLoadFile("loads.xml") if (file) then local childs = xmlNodeGetChildren(file) local randomChilds = {} for index = 1, 3 do table.insert(randomChilds, childs[math.random(#childs)]) end for _, loads in ipairs (randomChilds) do local row = guiGridListAddRow(glistLoadList) local attrs = xmlNodeGetAttributes(loads) local startx = attrs.startx local starty = attrs.starty local startz = attrs.startz local endx = attrs.endx local endy = attrs.endy local endz = attrs.endz local cash = attrs.cash guiGridListSetItemText(glistLoadList, row, 1, attrs.cargo, false, false) guiGridListSetItemText(glistLoadList, row, 2, attrs.pickup, false, false) guiGridListSetItemData(glistLoadList, row, 2, {attrs.startx, attrs.starty, attrs.startz}) guiGridListSetItemText(glistLoadList, row, 3, attrs.dropoff, false, false) guiGridListSetItemData(glistLoadList, row, 3, {attrs.endx, attrs.endy, attrs.endz}) guiGridListSetItemText(glistLoadList, row, 4, attrs.pay, false, false) guiGridListSetItemData(glistLoadList, row, 4, attrs.cash) end xmlUnloadFile(file) end end Link to comment
Castillo Posted March 25, 2014 Share Posted March 25, 2014 function loadHandler(button, state) if button == "left" and state == "up" then local row, col = guiGridListGetSelectedItem(glistLoadList) if ( row and col and row ~= -1 and col ~=-1 ) then local data = guiGridListGetItemData(glistLoadList, row, 2) local startx, starty, startz, endx, endy, endz, cash = unpack(data) triggerEvent("startLoad", localPlayer, startx, starty, startz, endx, endy, endz, cash) end end end function beginLoad(startx, starty, startz, endx, endy, endz, cash) createMarker(startx, starty, startz, "checkpoint", 5) createBlip(-102, -70, 5, 0, 2, 0, 0, 255) end addEvent("startLoad", false) addEventHandler("startLoad", localPlayer, beginLoad) Try it. Link to comment
TheGamingMann Posted March 25, 2014 Author Share Posted March 25, 2014 B-E-A-UTILFUL! Sorry for the caps. Thanks for the help solidsnake again. You are really good at this. Thanks man. Link to comment
Castillo Posted March 25, 2014 Share Posted March 25, 2014 Just so you know, I changed it to obtain the value from the column 2, I guess the value "col" was 1. You're welcome. Link to comment
TheGamingMann Posted March 25, 2014 Author Share Posted March 25, 2014 Yeah I noticed that. I was thinking about it but I didn't want to totally screw my whole mode up. Thanks again. Oh and one question. How can I have a guiElement stay on the screen for 30 seconds? I got the timer but currently it is just delay. I want it to come up and stay for 30 seconds then be gone. Thanks. Link to comment
Karuzo Posted March 25, 2014 Share Posted March 25, 2014 set a timer for 30 seconds and then just set the visibility of that element to false. Link to comment
Anubhav Posted March 25, 2014 Share Posted March 25, 2014 function changeVis() local state = guiGetVisible(yourGUIName) guiSetVisible(yourGUIName,not state) end setTimer(changeVis,30000,0) Link to comment
TheGamingMann Posted March 25, 2014 Author Share Posted March 25, 2014 Will try your code Anu whe n Iget home. Thanks for the help. Link to comment
Moderators Citizen Posted March 25, 2014 Moderators Share Posted March 25, 2014 function changeVis() local state = guiGetVisible(yourGUIName) guiSetVisible(yourGUIName,not state) end setTimer(changeVis,30000,0) Hahaha, it will just make his gui blicking every 30 secs. He wanted it to be hidden: function hideMyGui() guiSetVisible(myGuiElement, false) end And put this line where the gui is shown: setTimer(hideMyGui, 30*1000, 1) The "All-In-One" versiobn to be placed where the gui is shown: setTimer(function () guiSetVisible(myGuiElement, false) end, 30*1000, 1) It's using what we called an anonymous function. They are usefull when you know you will never call that function somewhere else in your script. Link to comment
TheGamingMann Posted March 25, 2014 Author Share Posted March 25, 2014 Thanks man it works well 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