WiBox Posted July 7, 2018 Share Posted July 7, 2018 (edited) Hello guys, I need a help with something... I need a way when I press Create zone: zoneCreator.button[2] = guiCreateButton(137, 532, 141, 29, "Create Zone", false, zoneCreator.window[1]) those 4: function showZoneOutput() guiSetText(zoneCreator.edit[1], string.format('%.3f', x)) guiSetText(zoneCreator.edit[2], string.format('%.3f', y)) guiSetText(zoneCreator.edit[3], string.format('%.3f', w)) guiSetText(zoneCreator.edit[4], string.format('%.3f', d)) end get added inside that table: zones = { --{id,name,owner,ctrl,price,objects,radio,x,y,sx,sy} --{id = 1, name = "Test zone", owner = "TsT", ctrl = "", price = 50000, objects = 0, radio = "", x = -1188.001, y = -438.446, sx = 19.328, sy = 22.896} } Can someone help me with making that thing? I tried I know I should make a function..: function test( ) -- get info from loadInfo and add them inside the table zones = { addEventHandler ( "onClientGUIClick", zoneCreator.button[2], showZoneOutput, false ) end addEventHandler( "onClientResourceStart", getResourceRootElement( getThisResource( ) ), test ) Now of course I made it wrong with messing part... If someone can help.. Thanks. Edited July 7, 2018 by SSKE Link to comment
Moderators IIYAMA Posted July 8, 2018 Moderators Share Posted July 8, 2018 (edited) @SSKE Other methods next to table.insert to insert in to a table: -------------------------------------- -- Using the table more as an array -- -- manual insert zones[1] = "value" zones[2] = "value" zones[3] = "value" zones[4] = "value" -- Auto insert at the end. Does almost the same as table.insert, it just can't pushing items (from the first index) and it is much faster. zones[#zones + 1] = "value" -- #zones -- table length! -- #zones + 1 = new free slot! --------------------------------------- -- Using the table more as an object -- -- Dot notation zones.header = "value" zones.bodyText = "value" zones.subText = "value" -- The same without dot notation zones["header"] = "value" zones["bodyText"] = "value" zones["subText"] = "value" -- Using other values as index (yes no limits) zones[{}] = "value" -- table zones[2425] = "value" -- number zones["fdgsdf"] = "value" -- string zones[function () end] = "value" -- function --etc. Edited July 8, 2018 by IIYAMA Link to comment
WiBox Posted July 9, 2018 Author Share Posted July 9, 2018 I want to add an client side coding inside a table in server side-,- I know what shoulf I use I just don't know how to add them inside the table! I know what should I use but I don't know how to make them. I tried so many times no errors but doesn't work -.- Link to comment
Moderators IIYAMA Posted July 9, 2018 Moderators Share Posted July 9, 2018 Well, show us what you tried. Because I don't understand your issue. If you want clientside and serverside be able to communicate, that can only be done with: setElementData triggerClientEvent / triggerServerEvent I understand that you have trouble with communicating with the English language, but please stay positive. I am reading your text after all. Link to comment
WiBox Posted July 11, 2018 Author Share Posted July 11, 2018 I'll try to explain better than before. function showZoneOutput() guiSetText(zoneCreator.edit[1], string.format('%.3f', x)) guiSetText(zoneCreator.edit[2], string.format('%.3f', y)) guiSetText(zoneCreator.edit[3], string.format('%.3f', w)) guiSetText(zoneCreator.edit[4], string.format('%.3f', d)) end The function showZoneOutput is in client side file. I want to trigger that function to server side and add it inside a table which is: zones = { --{id,name,owner,ctrl,price,objects,radio,x,y,sx,sy} --{id = 1, name = "Test zone", owner = "TsT", ctrl = "", price = 50000, objects = 0, radio = "", x = -1188.001, y = -438.446, sx = 19.328, sy = 22.896} } (from zones table) from the function showZoneOutput the x = x y = y sx = w sy = d __________________________________________________________________________________________ I want to insert X from the client side into the table zones = {} in the server side. That's all what I want.. Link to comment
Moderators IIYAMA Posted July 11, 2018 Moderators Share Posted July 11, 2018 Yes! that is how you should explain it the next time! Communicating with the server The very basic of it. Client function showZoneOutput() -- ... triggerServerEvent("saveDataInTable", resourceRoot, string.format('%.3f', x), string.format('%.3f', y), string.format('%.3f', w), string.format('%.3f', d)) end Server addEvent("saveDataInTable", true) addEventHandler("saveDataInTable", resourceRoot, function (x, y, w, d) zones[#zones + 1] = {id = 1, name = "Test zone", owner = "TsT", ctrl = "", price = 50000, objects = 0, radio = "", x = x, y = y, sx = w, sy = d} iprint(zones) end) Untested. https://wiki.multitheftauto.com/wiki/TriggerServerEvent Link to comment
WiBox Posted July 12, 2018 Author Share Posted July 12, 2018 I'll try it as soon as possible. Thanks! 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