Странно , отдельно работает , а вот когда пытаюсь ввести в скрипт не получается.Вот скрипт:
Клиент
function guiNoteMenu()
if(guiGetVisible (winNote) == true) then
guiSetVisible ( winNote, false )
showCursor(false)
notePage = guiGridListGetSelectedItem(noteList)
saveGridText()
guiSetInputEnabled(false)
else
local x, y = guiGetScreenSize()
winNote = guiCreateWindow (x / 2 - 450, y / 2 - 350, 620, 520, "Тетрадь", false)
guiWindowSetSizable(winNote,false)
noteMemo = guiCreateMemo ( 0.03, 0.05, 0.75, 0.85, "", true, winNote )
setGridText()
noteList = guiCreateGridList ( 0.79, 0.05, 0.18, 0.85, true, winNote )
noteColumn = guiGridListAddColumn ( noteList, "Страницы", 0.90 )
guiGridListSetSortingEnabled ( noteList, false )
pageMemo()
addEventHandler ( "onClientGUIClick", noteList, setGridText)
button = {}
button.Save = guiCreateButton ( 0.80, 0.92, 0.15, 0.06, "Сохранить", true, winNote)
addEventHandler ( "onClientGUIClick", button.Save, saveGridText)
addEventHandler ( "onClientGUIClick", button.Save, saveFile)
button.Delete = guiCreateButton (0.03, 0.92 , 0.15, 0.06 , "Вырвать", true,winNote)
addEventHandler ( "onClientGUIClick", button.Delete, message)
guiSetVisible ( winNote, true )
guiGridListSetSelectedItem(noteList,notePage,noteColumn)
showCursor(true)
guiSetInputEnabled(true)
end
end
function message()
if( guiGetVisible (winNote) == true) then
if( guiGetVisible (winMessage) == false) then
local x,y = guiGetPosition(winNote,false)
winMessage = guiCreateWindow(x,y+200,600,100,"Вы уверены ?",false)
local buttons = {}
buttons.Yes = guiCreateButton(0.10,0.50,0.30,0.30,"Да",true,winMessage)
addEventHandler ( "onClientGUIClick", buttons.Yes, giveServerFile)
buttons.No = guiCreateButton(0.60,0.50,0.30,0.30,"Нет",true,winMessage)
addEventHandler ("onClientGUIClick", buttons.No, closeMessage)
else
guiSetVisible ( winMessage, false )
end
end
function closeMessage()
guiSetVisible(winMessage,false)
end
end
notePageList = {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18}
function pageMemo()
if ( noteColumn ) then
for i=1,18 do
row = guiGridListAddRow ( noteList )
guiGridListSetItemText ( noteList, row, noteColumn, "Страница "..i, false, false )
end
end
end
function setGridText()
for i=0,18 do
if(guiGridListGetSelectedItem(noteList) == i) then
guiSetText(noteMemo,notePageList[i+1])
end
end
end
function saveGridText()
for i=0,18 do
if(guiGridListGetSelectedItem(noteList) == i) then
notePageList[i+1] = guiGetText(noteMemo)
end
end
end
function saveFile()
for i=0,18 do
local newFile = fileCreate(getPlayerName(getLocalPlayer())..i..".txt")
if (newFile) then
fileWrite(newFile, notePageList[i+1])
fileClose(newFile)
end
end
end
addEventHandler( "onClientResourceStop", getRootElement(), saveFile )
function loadFile()
for i=0,18 do
local buffer = {}
local newFile = fileOpen(getPlayerName(getLocalPlayer())..i..".txt",true)
if (newFile) then
buffer[i] = fileRead(newFile,1000)
notePageList[i+1] = buffer[i]
fileClose(newFile)
end
end
end
addEventHandler( "onClientResourceStart", getRootElement(),loadFile)
function giveServerFile()
local px, py, pz = getElementPosition ( getLocalPlayer ( ) )
triggerServerEvent ( "saveNameFile", localPlayer,guiGetText(noteMemo),px, py, pz)
guiSetText(noteMemo,"")
saveGridText()
guiSetVisible ( winMessage, false )
end
function guiNoteRead()
if(guiGetVisible (winReader) == true) then
guiSetVisible ( winReader, false )
showCursor(false)
else
local x, y = guiGetScreenSize()
winReader = guiCreateWindow (x / 2 - 350, y / 2 - 250, 620, 520, "Чтение", false)
guiWindowSetSizable(winReader,false)
guiSetVisible ( winReader, true )
readMemo = guiCreateMemo ( 0.03, 0.03, 0.94, 0.95, "", true, winReader )
local buttonclose = guiCreateButton(0.80,0.90,0.20,0.10,"Закрыть",true,readMemo)
addEventHandler ("onClientGUIClick", buttonclose,closeReader)
showCursor(true)
end
end
function closeReader()
guiSetVisible ( winReader, false )
showCursor(false)
end
function getServerFile(buffer)
guiNoteRead()
guiSetText(readMemo,buffer)
end
addEvent( "onGetServerFile", true )
addEventHandler( "onGetServerFile", getRootElement(), getServerFile )
bindKey("f3","down",guiNoteMenu)
Сервер:
id = 0
pickid = {}
objid = {}
function noteSave(memFile,x,y,z)
local check = fileExists(id..".txt")
if check then
--outputChatBox("Такой файл существует!",player)
id = id + 1
local newFile = fileCreate(id..".txt")
if (newFile) then
fileWrite(newFile, memFile )
fileClose(newFile)
end
else
--outputChatBox("Такого файла не существует!",player)
id = 0
local newFile = fileCreate(id..".txt")
if (newFile) then
fileWrite(newFile, memFile )
fileClose(newFile)
end
end
end
addEvent( "saveNameFile", true )
addEventHandler( "saveNameFile", root, noteSave )
function pageGiveClient(pageid)
local newFile = fileOpen(pageid..".txt")
if(newFile) then
local buffer = fileRead(newFile, 100)
triggerClientEvent ( "onGetServerFile", getRootElement(), buffer )
fileClose(newFile)
end
end
--addCommandHandler ( "pagive", pageGiveClient )
function deleteServerPages()
for i=0,id do
local newFile = fileDelete(i..".txt")
--outputChatBox("Файлы с id = "..i.." успешно удалены")
end
end
addEventHandler ( "onResourceStop", root, deleteServerPages)
Надо сделать так чтоб при соприкосновений colShpere появился pageGiveClient.