Hello Forum!
I need yor help
I am just starting to learn programming in Lua, there are not many guides, so I turn to you.
I wrote my own passport emulation, but I don't understand how I can put the entered data into the database. Below I will attach my code.
Also, I would be happy if you could help me and tell me how I can add the display of this "passport" when entering a marker using addEventHendler.
Thank you in advance!
My code
local dgs = exports.dgs
local sw,sh = guiGetScreenSize() -- разрешение экрана игрока
local px,py = sw/1920,sh/1080 -- адаптация экрана
local window = dgs:dgsCreateWindow(((sw-800)/2)*px,((sh-600)/2)*py,800*px,600*py,"Паспорт",false)
local buttonExecute = dgs:dgsCreateButton(325*px,530*py,150*px,40*py,"Подтвердить",false,window,nil,nil,nil,nil,nil,nil,tocolor(255,0,0),tocolor(100,0,0),tocolor(255,0,0))
local labelFirstName = dgs:dgsCreateLabel(200*px,200*py,400*px,30*py," Имя: ",false,window)
local editFirstName = dgs:dgsCreateEdit(200*px,220*py,400*px,30*py,"",false,window,tocolor(255,255,255),nil,nil,nil)
dgs:dgsSetProperty(labelFirstName,"alignment",{"center"}, {"center"})
dgs:dgsSetProperty(editFirstName,"alignment",{"center"}, {"center"})
local labelLastName = dgs:dgsCreateLabel(200*px,270*py,400*px,30*py," Фамилия: ",false,window)
local editLastName = dgs:dgsCreateEdit(200*px,290*py,400*px,30*py,"",false,window,tocolor(255,255,255),nil,nil,nil)
dgs:dgsSetProperty(labelLastName,"alignment",{"center"}, {"center"})
dgs:dgsSetProperty(editLastName,"alignment",{"center"}, {"center"})
local labelAge = dgs:dgsCreateLabel(200*px,340*py,400*px,30*py," Возраст: ",false,window,tocolor(255,255,255),nil,nil,nil)
local editAge = dgs:dgsCreateEdit(200*px,360*py,400*px,30*py,"",false,window)
dgs:dgsSetProperty(labelAge,"alignment",{"center"}, {"center"})
dgs:dgsSetProperty(editAge,"alignment",{"center"}, {"center"})
local labelCountry = dgs:dgsCreateLabel(200*px,410*py,400*px,30*py," Страна: ",false,window,tocolor(255,255,255),nil,nil,nil,tocolor(100,100,100,100))
local editCountry = dgs:dgsCreateEdit(200*px,430*py,400*px,30*py,"",false,window)
dgs:dgsSetProperty(labelCountry,"alignment",{"center"}, {"center"})
dgs:dgsSetProperty(editCountry,"alignment",{"center"}, {"center"})
dgs:dgsWindowSetMovable(window,false)
dgs:dgsWindowSetSizable(window,false)
dgs:dgsWindowSetCloseButtonEnabled(window,false)
dgs:dgsSetVisible(window,true)
dgs:dgsSetVisible(window,true)
showCursor(true)
function openPanel()
dgs:dgsSetVisible(window,true)
showCursor(true)
end
function colsePanel()
dgs:dgsSetVisible(window,false)
showCursor(false)
end
local currentChose = "register"
addEventHandler("onDgsMouseClick",root,function(btn,state)
if btn == "left" and state == "down" then
if source == buttonExecute then
local firstName = dgs:dgsGetText(editFirstName)
local lastName = dgs:dgsGetText(editLastName)
local age = dgs:dgsGetText(editAge)
local country = dgs:dgsGetText(editCountry)
if not string.find(firstName,"%S") then outputChatBox("Name") return end
if not string.find(lastName,"%S") then outputChatBox("LastName") return end
if not string.find(age,"%d") then outputChatBox("Age") return end
if not string.find(country,"%S") then outputChatBox("Country") return end
triggerServerEvent("playerPassportEnter",localPlayer,firstName,lastName,age,country)
end
end
end)
If you do help me, please write this with explanations, thank you in advance! I LOVE YOU FORUM