Jump to content

[Question] memo


Stranger

Recommended Posts

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

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 by Guest
Link to comment

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
  
    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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...