Jump to content

Making memo editable for certain people and saving it


Recommended Posts

  
  
              window= guiCreateWindow(264, 189, 355, 294, "", false) 
        guiWindowSetSizable(window, false) 
  
        memo = guiCreateMemo(14, 25, 331, 259, "", false, window)     
guiSetVisible(window,false) 
  
  

Hello so i wanna make it so only people in ACL admin will be able to edit it.

The one who arent admin shouldnt be able to edit it.

So if player 1 does /memo and i write "this is a test" and then presses "save" button it would save

if player 2 doess /memo he will see the SAME message that got last saved by player 1 for example

Link to comment

Try something like that,

If you want to saves the memo even the resource restarted,you need to use either SQL, MySQL or XML.

--client side:

window= guiCreateWindow(264, 189, 355, 294, "", false) 
guiWindowSetSizable(window, false) 
  
memo = guiCreateMemo(14, 25, 331, 259, "", false, window)     
guiSetVisible(window,false) 
  
client = getLocalPlayer() 
function editMemo() 
guiSetText ( memo, "" ) 
 triggerServerEvent ("memoEditable",client) 
end 

--server side:

addEvent( "memoEditable", true ) 
addEventHandler("memoEditable", root,  
function () 
local account = getPlayerAccount(player) 
if not account or isGuestAccount(account) then return end 
local accountName = getAccountName(account) 
for k,v in ipairs ( { "Console","Owner" } ) do  --You can change them by your ACL Admin names 
        if isObjectInACLGroup ( "user." .. accountName, aclGetGroup (v) )   then 
  end 
end 
  
end) 

Link to comment
Try something like that,

If you want to saves the memo even the resource restarted,you need to use either SQL, MySQL or XML.

--client side:

window= guiCreateWindow(264, 189, 355, 294, "", false) 
guiWindowSetSizable(window, false) 
  
memo = guiCreateMemo(14, 25, 331, 259, "", false, window)     
guiSetVisible(window,false) 
  
client = getLocalPlayer() 
function editMemo() 
guiSetText ( memo, "" ) 
 triggerServerEvent ("memoEditable",client) 
end 

--server side:

addEvent( "memoEditable", true ) 
addEventHandler("memoEditable", root,  
function () 
local account = getPlayerAccount(player) 
if not account or isGuestAccount(account) then return end 
local accountName = getAccountName(account) 
for k,v in ipairs ( { "Console","Owner" } ) do  --You can change them by your ACL Admin names 
        if isObjectInACLGroup ( "user." .. accountName, aclGetGroup (v) )   then 
  end 
end 
  
end) 

Doubt it'll work. Didn't test it, but you events don't return anything and the way you did it, it does not matter if he's acl admin or not. You need another event going from server to client again.

Link to comment

This could help you but I didn't test it, you should change the code to your code to be synced

  
  
  
-- client side  
-- you should get the ID from the data , try to save data first with  
-- setElementData(element, "id", value) because I don't know your code  
function saveInformation() 
    local text = guiGetText(memo) 
    local id = getElementData(localPlayer, "id") 
    triggerServerEvent("memoInfo", resourceRoot, text, id) 
end 
addEventHandler("onClientGUIClick",button,saveInformation) 
  
  
  
--server side , you should have table where you can store the text in it and with this function 
-- we can get it 
  
yourTable = { 
    -- id , text  
    {1, "This is your Text"}, 
} 
  
  
function memoInfo(text, id) 
    for k, v in pairs(yourTable) do 
        if v[1] == id then 
            v[2] = text 
            return 
        end 
    end 
end 
addEvent("memoInfo", true) 
addEventHandler("memoInfo", root, memoInfo)  

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