Stranger Posted June 27, 2014 Share Posted June 27, 2014 hey guys. i just want to know if there any way to make the memo save more than 128 character ? cause i have make a save text system, which will save the texts in the memo but i have this problem that if i wrote more than 128 character and press save and close it and open it most of the word that i have wrote it , gone !!! so i wanna know if there any way to make it save more than 128 character. Link to comment
Anubhav Posted June 27, 2014 Share Posted June 27, 2014 Use SQL for saving the text. You can add me at skype anubhav.agarwal87 for SQL help. Link to comment
Stranger Posted June 27, 2014 Author Share Posted June 27, 2014 (edited) Thank you Anubhav. so i have a problem here Client side: local screenW, screenH = guiGetScreenSize() win = guiCreateWindow((screenW - 363) / 2, (screenH - 336) / 2, 363, 336, "Save Text", false) guiWindowSetSizable(win, false) guiSetAlpha(win, 1.00) guiSetVisible (win, false) txt = guiCreateMemo(9, 26, 344, 261, "", false, win) sv = guiCreateButton(9, 294, 173, 32, "Save", false, win) guiSetProperty(sv, "NormalTextColour", "FFAAAAAA") cl = guiCreateButton(182, 294, 172, 32, "Close", false, win) guiSetProperty(cl, "NormalTextColour", "FFAAAAAA") bindKey ("o", "down", function () if getPlayerSerial (localPlayer) == "------------" then guiSetVisible (win, not guiGetVisible (win)) showCursor (guiGetVisible (win)) guiSetInputEnabled (guiGetVisible (win)) triggerServerEvent ("checkIt", localPlayer) end end) function sendDetails() local text = guiGetText(txt) triggerServerEvent("onSaveTheText",localPlayer,text) end addEventHandler ("onClientResourceStart", resourceRoot, function () triggerServerEvent ("makeIt", localPlayer) end) addEvent("savedData",true) function savedDatae(queryer, poll, answer) guiSetText(txt,answer) end addEventHandler("savedData",root,savedDatae) addEventHandler ("onClientGUIClick", root, function () if (source == sv) then sendDetails () end if (source == cl) then guiSetVisible (win, false) showCursor (guiGetVisible (win)) guiSetInputEnabled (guiGetVisible (win)) end end) addEvent ("onStartAddIt", true) addEventHandler ("onStartAddIt", root, function (answer) guiSetText(txt,tostring(answer)) end ) Server side: local data = {} con = dbConnect("sqlite",":/saver.db") local tableSaver = {} addEvent ("makeIt", true) addEventHandler("makeIt",root, function () dbExec(con,"CREATE TABLE IF NOT EXISTS data(text)") local queryer = dbQuery(con,"SELECT * FROM data") local poll = dbPoll(queryer,-1) if poll and queryer then local answer = tostring(poll[1]) if getPlayerSerial (source) == "-------------" then triggerClientEvent(source, "savedData", source, queryer, poll, answer) end end end ) addEvent("onSaveTheText",true) addEventHandler("onSaveTheText", root, function(text) tableSaver[1] = text dbExec(con,"UPDATE data SET text=?",text) end ) addEvent ("checkIt", true) addEventHandler ("checkIt", root, function () local answer = tableSaver[1] dbExec(con,"UPDATE data SET text=?",tostring(answer)) triggerClientEvent (source, "onStartAddIt", source,answer) end ) it's saves, but if i restart the resource the message in the memo change to "nil" i don't know where is the problem, so help. Edited June 27, 2014 by Guest Link to comment
Anubhav Posted June 27, 2014 Share Posted June 27, 2014 Oh I did that. Realy I am confused with it now. I can't help you anymore. Sorry, Anubhav Link to comment
Stranger Posted June 27, 2014 Author Share Posted June 27, 2014 no problem. ------------ any help please. Link to comment
xXMADEXx Posted June 27, 2014 Share Posted June 27, 2014 An error I noticed the moment I saw the code was this: dbExec(con,"CREATE TABLE IF NOT EXISTS data(text)") It should be something like this: dbExec ( con, "CREATE TABLE IF NOT EXISTS data ( value TEXT )" ); You cannot use "text" as a column name, because it's a reserved word for SQL. Server: local data = {} con = dbConnect("sqlite",":/saver.db") local tableSaver = {} addEvent ("makeIt", true) addEventHandler("makeIt",root, function () dbExec ( con, "CREATE TABLE IF NOT EXISTS data ( value TEXT )" ); local queryer = dbQuery(con,"SELECT * FROM data") local poll = dbPoll(queryer,-1) if poll and queryer then local answer = tostring(poll[1]) if getPlayerSerial (source) == "-------------" then triggerClientEvent(source, "savedData", source, queryer, poll, answer) end end end ) addEvent("onSaveTheText",true) addEventHandler("onSaveTheText", root, function(text) tableSaver[1] = text dbExec(con,"UPDATE data SET value=?",text) end ) addEvent ("checkIt", true) addEventHandler ("checkIt", root, function () local answer = tableSaver[1] dbExec(con,"UPDATE data SET value=?",tostring(answer)) triggerClientEvent (source, "onStartAddIt", source,answer) end ) If it still doesn't work let me know, and upload any error(s) it gives in debugscript. Link to comment
Stranger Posted June 27, 2014 Author Share Posted June 27, 2014 i got this error: 28: dbExec failed; (1) no such column: value Link to comment
Anubhav Posted June 27, 2014 Share Posted June 27, 2014 local data = {} con = dbConnect("sqlite",":/saver.db") local tableSaver = {} addEvent ("makeIt", true) addEventHandler("makeIt",root, function () dbExec ( con, "CREATE TABLE IF NOT EXISTS data ( value TEXT )" ); local queryer = dbQuery(con,"SELECT * FROM data") local poll = dbPoll(queryer,-1) if poll and queryer then local answer = tostring(poll[1]) if getPlayerSerial (source) == "-------------" then triggerClientEvent(source, "savedData", source, queryer, poll, answer) end end end ) addEvent("onSaveTheText",true) addEventHandler("onSaveTheText", root, function(text) tableSaver[1] = text dbExec(con,"UPDATE data SET value=?",text) end ) addEvent ("checkIt", true) addEventHandler ("checkIt", root, function () local answer = tableSaver[1] dbExec(con,"UPDATE data SET text=?",tostring(answer)) triggerClientEvent (source, "onStartAddIt", source,answer) end ) Link to comment
Stranger Posted June 27, 2014 Author Share Posted June 27, 2014 yea now it's work, but still not save after the restart. 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