Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local defX, defY, defZ = 1479.8171386719, -1741.1892089844, 13.546875 - -0, 0, 4.4301533699036
- local sx,sy = guiGetScreenSize()
- local salt = "vgrpkeyscotland"
- local wx,wy = sx/2-490/2,sy/2-368/2
- local guiElements = {}
- local activeGui = "login"
- local loadedUser = ""
- local loadedPassword = ""
- local md55 = false
- local emlekezz = false
- local localPlayer = getLocalPlayer()
- local tempPeds = {}
- local pedData = {}
- local isCameraOnMove = false
- local selectedCharacter = 1
- local imgrot = 0
- local img = 3
- local destroyTimer
- function sendPasswordMail(username)
- if isTimer(destroyTimer) then
- killTimer(destroyTimer)
- end
- img = 1
- addEventHandler("onClientRender", root, renderGTAVLoading)
- triggerServerEvent("sendPasswordRecover", localPlayer, username)
- end
- addEvent("receivePasswordRecover", true)
- addEventHandler("receivePasswordRecover", root, function(data)
- if data == "Done" then
- img = 2
- elseif data == "Fail" then
- img = 4
- elseif data == "Nomail" then
- img = 5
- else
- img = 3
- end
- destroyTimer = setTimer(function()
- removeEventHandler("onClientRender", root, renderGTAVLoading)
- end, 5000, 1)
- end)
- function renderGTAVLoading()
- if img > 0 then
- dxDrawRectangle(sx-200,sy-25,200,25,tocolor(0,0,0,180), true)
- if img == 1 then
- imgrot = imgrot + 5
- dxDrawImage(sx-195,sy-23,20,20,"assets/loading.png", imgrot, 0, 0, nil, true)
- dxDrawText("Keresés folyamatban ...",sx-165,sy-19,20,20,tocolor(255,255,255,255),1,"default","left","top",false,false,true)
- elseif img == 2 then
- dxDrawImage(sx-195,sy-22,20,20,"assets/success.png", 0, 0, 0, nil, true)
- dxDrawText("Email sikeresen elküldve!",sx-165,sy-19,20,20,tocolor(255,255,255,255),1,"default","left","top",false,false,true)
- elseif img == 3 then
- dxDrawImage(sx-195,sy-22,20,20,"assets/error.png", 0, 0, 0, nil, true)
- dxDrawText("Sikertelen email küldés!",sx-165,sy-19,20,20,tocolor(255,255,255,255),1,"default","left","top",false,false,true)
- elseif img == 4 then
- dxDrawImage(sx-195,sy-22,20,20,"assets/error.png", 0, 0, 0, nil, true)
- dxDrawText("Nincs találat!",sx-165,sy-19,20,20,tocolor(255,255,255,255),1,"default","left","top",false,false,true)
- elseif img == 5 then
- dxDrawImage(sx-195,sy-22,20,20,"assets/error.png", 0, 0, 0, nil, true)
- dxDrawText("Nincs társított email cím!",sx-165,sy-19,20,20,tocolor(255,255,255,255),1,"default","left","top",false,false,true)
- end
- end
- end
- addEventHandler("onClientResourceStart", resourceRoot, function()
- if not getElementData(localPlayer, "spawned") then
- triggerEvent("showLoginPanel", localPlayer)
- end
- setBlurLevel(0)
- end)
- addEvent("showLoginPanel", true)
- addEventHandler("showLoginPanel", root, function()
- setCameraInterior(0)
- setCameraMatrix(456.46926879883, -1588.6673583984, 53.359394073486, 389.35961914063, -1517.9282226563, 31.172163009644, 0, exports.ex_core:getPlayerFov())
- setElementPosition(localPlayer, 456.46926879883, -1588.6673583984, 53.359394073486)
- showChat(false)
- showCursor(true)
- fadeCamera(true)
- addEventHandler("onClientRender",root,renderLoginPanel)
- addEventHandler("onClientKey",root,handleKeys)
- createGuiElements(activeGui)
- end)
- function addGuiElement(e)
- local this = #guiElements + 1
- guiElements[this] = e
- end
- local loginConfig = "@loginData.json"
- function jsonGET(file)
- local fileHandle
- local jsonDATA = {}
- if not fileExists(file) then
- fileHandle = fileCreate(file)
- fileWrite(fileHandle, toJSON({["username"] = "", ["password"] = ""}))
- fileClose(fileHandle)
- fileHandle = fileOpen(file)
- else
- fileHandle = fileOpen(file)
- end
- if fileHandle then
- local buffer
- local allBuffer = ""
- while not fileIsEOF(fileHandle) do
- buffer = fileRead(fileHandle, 500)
- allBuffer = allBuffer..buffer
- end
- jsonDATA = fromJSON(allBuffer)
- fileClose(fileHandle)
- end
- return jsonDATA
- end
- function jsonSAVE(file, data)
- if fileExists(file) then
- fileDelete(file)
- end
- local fileHandle = fileCreate(file)
- fileWrite(fileHandle, toJSON(data))
- fileFlush(fileHandle)
- fileClose(fileHandle)
- return true
- end
- function createGuiElements(typ)
- for k,v in ipairs(guiElements) do
- if isElement(v) then
- destroyElement(v)
- end
- end
- if typ == "login" then
- activeGui = "login"
- label1 = guiCreateLabel(wx+70,wy+43,350,50,"",false)
- label2 = guiCreateLabel(wx+70,wy+120,350,50,"",false)
- window = guiCreateWindow(wx,wy,490,368,"Bejelentkezés",false)
- edit1 = guiCreateEdit(70,25,350,50,"",false,window)
- edit2 = guiCreateEdit(70,100,350,50,"",false,window)
- guiEditSetMaxLength(edit1, 30)
- guiEditSetMaxLength(edit2, 50)
- addEventHandler("onClientGUIChanged", edit1, function()
- guiSetText(label1, guiGetText(edit1))
- md55 = false
- end)
- addEventHandler("onClientGUIChanged", edit2, function()
- md55 = false
- local strin = tostring(guiGetText(edit2))
- if strin:len() > 0 then
- local temp = ""
- for i=1, strin:len() do
- temp = temp .. "*"
- end
- guiSetText(label2, temp)
- else
- guiSetText(label2, "")
- end
- end)
- button = guiCreateButton(20,240,450,50,"",false,window)
- button2 = guiCreateButton(20,295,450,30,"",false,window)
- button3 = guiCreateButton(20,175,450,40,"",false,window)
- button4 = guiCreateButton(20,335,450,30,"",false,window)
- addEventHandler("onClientGUIClick", button3, function()
- if source == button3 then
- emlekezz = not emlekezz
- end
- end)
- addEventHandler("onClientGUIClick", button2, function()
- if source == button2 then
- createGuiElements("register")
- end
- end)
- addEventHandler("onClientGUIClick", button4, function()
- if source == button4 then
- createGuiElements("lost_pw")
- end
- end)
- addEventHandler("onClientGUIClick", button, function()
- if source == button then
- validate("login")
- end
- end)
- local data = jsonGET(loginConfig)
- if data then
- if data["username"] and data["username"] ~= "" and data["password"] and data["password"] ~= "" then
- guiSetText(edit1, data["username"])
- guiSetText(edit2, data["password"])
- md55 = true
- emlekezz = true
- end
- end
- guiSetAlpha(window, 0)
- addGuiElement(window)
- addGuiElement(label1)
- addGuiElement(label2)
- elseif typ == "lost_pw" then
- activeGui = "lost_pw"
- label1 = guiCreateLabel(wx+70,wy+175,350,50,"",false)
- text = [[
- A jelszó visszaállítás menete:
- 1. Beírod a felhasználóneved / az email címed.
- 2. Rákattintasz a "Jelszó visszaállítás" gombra.
- 3. A rendszer küld egy megerősítő emailt.
- 4. Rákattintasz a megerősítő linkre.
- 5. A rendszer elküldi az új jelszavad az email címedre.
- ]]
- label2 = guiCreateLabel(wx+20,wy+20,490,300,text,false)
- guiLabelSetHorizontalAlign(label2, "center")
- window = guiCreateWindow(wx,wy,490,368,"Elfelejtett jelszó",false)
- edit1 = guiCreateEdit(70,160,350,50,"",false,window)
- guiEditSetMaxLength(edit1, 60)
- addEventHandler("onClientGUIChanged", edit1, function()
- guiSetText(label1, guiGetText(edit1))
- end)
- button = guiCreateButton(20,240,450,50,"",false,window)
- addEventHandler("onClientGUIClick", button, function()
- if source == button then
- validate("lost_pw")
- end
- end)
- button2 = guiCreateButton(20,300,450,50,"",false,window)
- addEventHandler("onClientGUIClick", button2, function()
- if source == button2 then
- createGuiElements("login")
- end
- end)
- guiSetAlpha(window, 0)
- addGuiElement(window)
- addGuiElement(label1)
- addGuiElement(label2)
- elseif typ == "register" then
- activeGui = "register"
- label1 = guiCreateLabel(wx+70,wy+43,350,50,"",false)
- label2 = guiCreateLabel(wx+70,wy+120,350,50,"",false)
- label3 = guiCreateLabel(wx+70,wy+195,350,50,"",false)
- window = guiCreateWindow(wx,wy,490,368,"Regisztráció",false)
- edit1 = guiCreateEdit(70,25,350,50,"",false,window)
- edit2 = guiCreateEdit(70,100,350,50,"",false,window)
- edit3 = guiCreateEdit(70,175,350,50,"",false,window)
- guiEditSetMaxLength(edit1, 30)
- guiEditSetMaxLength(edit2, 50)
- guiEditSetMaxLength(edit3, 50)
- button = guiCreateButton(20,240,450,50,"",false,window)
- button2 = guiCreateButton(20,300,450,50,"",false,window)
- addEventHandler("onClientGUIClick", button2, function()
- if source == button2 then
- createGuiElements("login")
- end
- end)
- addEventHandler("onClientGUIClick", button, function()
- if source == button then
- validate("register")
- end
- end)
- addEventHandler("onClientGUIChanged", edit1, function()
- guiSetText(label1, guiGetText(edit1))
- end)
- addEventHandler("onClientGUIChanged", edit2, function()
- local strin = tostring(guiGetText(edit2))
- if strin:len() > 0 then
- local temp = ""
- for i=1, strin:len() do
- temp = temp .. "*"
- end
- guiSetText(label2, temp)
- else
- guiSetText(label2, "")
- end
- end)
- addEventHandler("onClientGUIChanged", edit3, function()
- local strin = tostring(guiGetText(edit3))
- if strin:len() > 0 then
- local temp = ""
- for i=1, strin:len() do
- temp = temp .. "*"
- end
- guiSetText(label3, temp)
- else
- guiSetText(label3, "")
- end
- end)
- guiSetAlpha(window, 0)
- addGuiElement(window)
- addGuiElement(label1)
- addGuiElement(label2)
- addGuiElement(label3)
- end
- end
- function handleKeys(k,s)
- if (k == "enter" or k == "num_enter") and s then
- validate(activeGui)
- end
- end
- local startTick = nil
- function validate(typ)
- startTick = getTickCount()
- if isTimer(theTimer) then
- exports.ex_gui:showInfoBox("Várj 10 másodpercet két próbálkozás között!")
- return
- end
- theTimer = setTimer(function() end, 10000, 1)
- if typ == "login" then
- local username = tostring(guiGetText(edit1))
- local password = tostring(guiGetText(edit2))
- if username and password then
- if username:len() > 0 and password:len() > 0 then
- if not md55 then
- triggerServerEvent("serverLoginAttempt", localPlayer, username, md5(salt..password))
- else
- triggerServerEvent("serverLoginAttempt", localPlayer, username, password, password)
- end
- else
- exports.ex_gui:showInfoBox("Felhasználónév és jelszó megadása kötelező!")
- end
- else
- exports.ex_gui:showInfoBox("Felhasználónév és jelszó megadása kötelező!")
- end
- elseif typ == "lost_pw" then
- local username = tostring(guiGetText(edit1))
- if username then
- if username:len() > 4 then
- sendPasswordMail(username)
- else
- exports.ex_gui:showInfoBox("Felhasználónév / email cím minimum 4 karakterből kell álljon!")
- end
- else
- exports.ex_gui:showInfoBox("Felhasználónév / email cím megadása kötelező!")
- end
- elseif typ == "register" then
- local username = tostring(guiGetText(edit1))
- local password = tostring(guiGetText(edit2))
- local password2 = tostring(guiGetText(edit3))
- if username and password and password2 then
- if username:len() > 0 and password:len() > 0 and password2:len() > 0 then
- if password ~= password2 then
- exports.ex_gui:showInfoBox("A két jelszó nem egyezik!")
- elseif username:len() < 4 then
- exports.ex_gui:showInfoBox("A felhasználónév minimum 4 karakterből kell álljon!")
- elseif password:len() < 6 then
- exports.ex_gui:showInfoBox("A jelszó minimum 6 karakterből kell álljon!")
- else
- triggerServerEvent("registerPlayer", localPlayer, username, md5(salt..password), getPlayerSerial(localPlayer))
- end
- else
- exports.ex_gui:showInfoBox("Felhasználónév és jelszó megadása kötelező!")
- end
- else
- exports.ex_gui:showInfoBox("Felhasználónév és jelszó megadása kötelező.")
- end
- end
- end
- local progressImage = 0
- function renderLoginPanel()
- exports.ex_blur:createBlur()
- if progressImage < 1 then
- progressImage = progressImage + 0.01
- end
- local iX,iY,iZ = interpolateBetween(sx/2-38/2, -50, 0, wx+490/2-38/2, wy-70, 0, progressImage, "OutBounce")
- dxDrawImage(iX,iY,38,61,"assets/logo_new.png")
- if activeGui == "login" then
- dxDrawImage(wx,wy,490,368,"assets/login.png")
- if emlekezz then
- dxDrawImage(wx,wy,490,368,"assets/login2.png")
- end
- elseif activeGui == "register" then
- dxDrawImage(wx,wy,490,368,"assets/register.png")
- elseif activeGui == "lost_pw" then
- dxDrawImage(wx,wy,490,368,"assets/lost_pw.png")
- end
- end
- addEvent("successRegister", true)
- addEventHandler("successRegister", getRootElement(), function()
- createGuiElements("login")
- exports.ex_gui:showInfoBox("Sikeresen regisztráltál! Most már bejelentkezhetsz.")
- end)
- function clearChatBox()
- for i=1, getChatboxLayout()["chat_lines"] do
- outputChatBox(" ")
- end
- end
- addCommandHandler("clearchat", clearChatBox)
- addCommandHandler("clear", clearChatBox)
- addCommandHandler("cc", clearChatBox)
- local chatBlockTime = 0
- addEvent("receiveServerCharacterData", true)
- addEventHandler("receiveServerCharacterData", root, function(data)
- local username = ""
- local password = ""
- if emlekezz then
- username = getElementData(localPlayer, "temp:Username") or ""
- password = getElementData(localPlayer, "temp:Password") or ""
- setElementData(localPlayer, "temp:Username", nil)
- setElementData(localPlayer, "temp:Password", nil)
- end
- jsonSAVE(loginConfig, {["username"] = username, ["password"] = password})
- exports.ex_job_core:applyJob(data.job)
- chatBlockTime = data.chatblocktime
- setElementData(localPlayer, "char:Chattime", chatBlockTime)
- if data.chatblocked == 1 then
- if chatBlockTime ~= 0 then
- startChatBlockTimer(chatBlockTime)
- end
- end
- setElementData(localPlayer, "spawned", true)
- exports.ex_core:toggleComponents(false)
- triggerEvent("spawnVehiclesFunction", localPlayer)
- setElementFrozen(localPlayer, false)
- setCameraTarget(localPlayer)
- toggleAllControls(true, true, true)
- exports.ex_gui:showInfoBox("Sikeresen bejelentkeztél, jó szórakozást kivánunk a HL-en!")
- if data.adolevonas == 0 then
- triggerEvent("initTax", localPlayer)
- end
- exports.ex_inventory:loadPlayerItems(data.id)
- exports.ex_drogplants:countDownPlantTime(data.plantTime)
- end)
- local syncWithServer = false
- local syncTimer
- function startChatBlockTimer(time)
- if isTimer(syncTimer) then killTimer(syncTimer) end
- syncTimer = setTimer(function()
- syncWithServer = not syncWithServer
- end, 10000, 0)
- timer1 = setTimer(function()
- chatBlockTime = chatBlockTime - 1
- if chatBlockTime == 0 then
- if isTimer(timer1) then killTimer(timer1) end
- if isTimer(syncTimer) then killTimer(syncTimer) end
- if syncWithServer then
- syncWithServer = false
- setElementData(localPlayer, "char:Chatblocked", 0, true)
- else
- setElementData(localPlayer, "char:Chatblocked", 0, false)
- end
- outputChatBox("[HL] #FFFFFFLejárt a chat tiltásod!", 255, 0, 0, true)
- end
- setElementData(localPlayer, "char:Chattime", chatBlockTime)
- end, 1000, chatBlockTime)
- end
- addEventHandler("onClientResourceStart", resourceRoot, function()
- if getElementData(localPlayer, "spawned") then
- local chatBlocked = tonumber(getElementData(localPlayer, "char:Chatblocked"))
- chatBlockTime = tonumber(getElementData(localPlayer, "char:Chattime")) or 0
- if chatBlocked == 1 then
- if chatBlockTime == 0 then
- else
- startChatBlockTimer(chatBlockTime)
- end
- end
- end
- end)
- local countdown = 0
- addEvent("initChatBanCountDown", true)
- addEventHandler("initChatBanCountDown", root, function(t)
- countdown = t
- if t ~= 0 then
- if isTimer(timer1) then
- killTimer(timer1)
- end
- setElementData(localPlayer, "char:Chattime", t)
- timer1 = setTimer(function()
- countdown = countdown - 1
- if countdown == 0 then
- killTimer(timer1)
- setElementData(localPlayer, "char:Chatblocked", 0)
- outputChatBox("[HL] #FFFFFFLejárt a chat tiltásod!", 255, 0, 0, true)
- end
- setElementData(localPlayer, "char:Chattime", countdown)
- end, 1000, countdown)
- end
- end)
- function removeLoginBox()
- for k,v in ipairs(guiElements) do
- if isElement(v) then
- destroyElement(v)
- end
- end
- setCameraTarget(localPlayer)
- guiElements = {}
- showCursor(false)
- showChat(true)
- removeEventHandler("onClientRender",root,renderLoginPanel)
- removeEventHandler("onClientKey",root,handleKeys)
- end
- --- KARAKTER VÁLASZTÓ BY XENIUS 2015
- local sm = {}
- sm.moov = 0
- sm.object1,sm.object2 = nil,nil
- local function removeCamHandler()
- if(sm.moov == 1)then
- sm.moov = 0
- end
- end
- local function camRender()
- if (sm.moov == 1) then
- local x1,y1,z1 = getElementPosition(sm.object1)
- local x2,y2,z2 = getElementPosition(sm.object2)
- setCameraMatrix(x1,y1,z1,x2,y2,z2,0,exports.ex_core:getPlayerFov())
- end
- end
- addEventHandler("onClientPreRender",root,camRender)
- local function smoothMoveCamera(x1,y1,z1,x1t,y1t,z1t,x2,y2,z2,x2t,y2t,z2t,time)
- if(sm.moov == 1)then return false end
- sm.object1 = createObject(1337,x1,y1,z1)
- sm.object2 = createObject(1337,x1t,y1t,z1t)
- setElementDimension(sm.object1, getElementDimension(localPlayer))
- setElementDimension(sm.object2, getElementDimension(localPlayer))
- setElementAlpha(sm.object1,0)
- setElementAlpha(sm.object2,0)
- setObjectScale(sm.object1,0.01)
- setObjectScale(sm.object2,0.01)
- moveObject(sm.object1,time,x2,y2,z2,0,0,0,"InOutQuad")
- setElementAlpha(localPlayer, 0)
- moveObject(sm.object2,time,x2t,y2t,z2t,0,0,0,"InOutQuad")
- sm.moov = 1
- setTimer(removeCamHandler,time,1)
- setTimer(destroyElement,time,1,sm.object1)
- setTimer(destroyElement,time,1,sm.object2)
- return true
- end
- local pedPositions = {
- [1] = {
- pos = {402.17541503906, -1532.3784179688, 32.2734375},
- rot = {0, 0, 217.42056274414},
- cam = {405.01971435547, -1535.5256347656, 33.379688262939, 342.66143798828, -1460.1274414063, 12.726487159729},
- },
- }
- function checkCursor()
- if isCursorShowing() then
- return true
- else
- return false
- end
- end
- function getCursorPos()
- if checkCursor() then
- cx,cy = getCursorPosition()
- cx,cy = cx*sx,cy*sy
- else
- cx,cy = -500,-500
- end
- return cx,cy
- end
- function isInBox(x, y, xmin, xmax, ymin, ymax)
- if checkCursor() then
- return x >= xmin and x <= xmax and y >= ymin and y <= ymax
- else
- return false
- end
- end
- local tempPed = nil
- local selectedChar = 0
- local characters = {}
- local FONT = exports.ex_core:getFont("roboto.ttf")
- local FONT2 = exports.ex_core:getFont("montserrat.ttf")
- local width, height = 400, 350
- local pX = 0
- local pY = sy/2-height/2
- local loadCharacterCreation = false
- local characterCreationErrorMessage = ""
- local errorFields = {}
- local characterCount = 0
- addEvent("receiveCharacters", true)
- addEventHandler("receiveCharacters", root, function(tbl, test, created)
- if isElement(tempPed) then
- destroyElement(tempPed)
- end
- if created then
- removeEventHandler("onClientRender", root, renderCharacterCreationUI)
- destroyCharacterCreatioGUI()
- addEventHandler("onClientRender", root, renderCharacterSelectInterface)
- else
- removeLoginBox()
- showCursor(true)
- exports.ex_core:toggleComponents(true)
- end
- characters = tbl
- characterCount = 0
- local position = pedPositions[1]
- for k,v in pairs(characters) do
- if characterCount == 0 then
- tempPed = createPed(v[3], unpack(position.pos))
- setElementRotation(tempPed, unpack(position.rot))
- setElementDimension(tempPed, getElementDimension(localPlayer))
- end
- characterCount=characterCount+1
- local x,y,z,dim
- if v[4] then
- x,y,z,dim = v[4][1],v[4][2],v[4][3],v[4][4]
- else
- x,y,z,dim = defX, defY, defZ, 0
- end
- local zone = getZoneName(x,y,z)
- v[4] = zone
- if dim > 0 then
- local id, entrance = exports.ex_building:findInterior(dim)
- if id > 0 and entrance then
- v[4] = getElementData(entrance, "name")
- end
- end
- if v[5] == 0 or not v[5] then
- v[5] = "a mai napon"
- else
- v[5] = v[5].." nappal ezelőtt"
- end
- end
- if not created then
- if test then
- moveCameraToCharacter(1, 2000, true)
- addEventHandler("onClientClick", root, spawnCharacter)
- end
- end
- end)
- addEvent("testSuccessful", true)
- addEventHandler("testSuccessful", root, function()
- moveCameraToCharacter(1, 2000, true)
- addEventHandler("onClientClick", root, spawnCharacter)
- end)
- function moveCameraToCharacter(id, time, first)
- if isCameraOnMove then return end
- if pedPositions[id] then
- local x1,y1,z1,x1t,y1t,z1t = getCameraMatrix()
- local x2,y2,z2,x2t,y2t,z2t = unpack(pedPositions[id].cam)
- isCameraOnMove = true
- smoothMoveCamera(x1,y1,z1,x1t,y1t,z1t,x2,y2,z2,x2t,y2t,z2t,time)
- setTimer(function(first)
- isCameraOnMove = false
- if first then
- addEventHandler("onClientRender", root, renderCharacterSelectInterface)
- end
- end, time, 1, first)
- end
- end
- local nameEdit, descriptionText, genderCombos, nationalityCombos
- function createCharacterCreatioGUI()
- nameEdit = guiCreateEdit(pX+140,pY+40-5,width-150,30,"",false)
- guiSetAlpha(nameEdit, 0.8)
- descriptionText = guiCreateMemo(pX+140,pY+160-5,width-150,80,"",false)
- guiSetAlpha(descriptionText, 0.8)
- genderCombos = guiCreateComboBox(pX+140,pY+80-2,width-150,80,"",false)
- guiSetAlpha(genderCombos, 0.8)
- guiComboBoxAddItem(genderCombos, "Férfi")
- guiComboBoxAddItem(genderCombos, "Nő")
- nationalityCombos = guiCreateComboBox(pX+140,pY+120-2,width-150,80,"",false)
- guiSetAlpha(nationalityCombos, 0.8)
- guiComboBoxAddItem(nationalityCombos, "Fekete")
- guiComboBoxAddItem(nationalityCombos, "Fehér")
- guiComboBoxAddItem(nationalityCombos, "Ázsiai")
- addEventHandler("onClientGUIComboBoxAccepted", root, guiComboChange)
- end
- function destroyCharacterCreatioGUI()
- removeEventHandler("onClientGUIComboBoxAccepted", root, guiComboChange)
- if isElement(nameEdit) then
- destroyElement(nameEdit)
- end
- if isElement(descriptionText) then
- destroyElement(descriptionText)
- end
- if isElement(genderCombos) then
- destroyElement(genderCombos)
- end
- if isElement(nationalityCombos) then
- destroyElement(nationalityCombos)
- end
- end
- addEvent("receiveCharacterCreationError", true)
- addEventHandler("receiveCharacterCreationError", root, function(err)
- loadCharacterCreation = false
- characterCreationErrorMessage = err
- end)
- function guiComboChange()
- local gender = guiComboBoxGetItemText(genderCombos, guiComboBoxGetSelected(genderCombos))
- local nationality = guiComboBoxGetItemText(nationalityCombos, guiComboBoxGetSelected(nationalityCombos))
- local skin = 0
- if gender == "Férfi" then
- if nationality == "Fekete" then
- skin = 29
- elseif nationality == "Fehér" then
- skin = 31
- elseif nationality == "Ázsiai" then
- skin = 58
- end
- elseif gender == "Nő" then
- if nationality == "Fekete" then
- skin = 10
- elseif nationality == "Fehér" then
- skin = 12
- elseif nationality == "Ázsiai" then
- skin = 7
- end
- end
- if skin > 0 then
- setElementModel(tempPed, skin)
- end
- end
- function spawnCharacter(button, state)
- if isCameraOnMove then return end
- if button == "left" and state == "down" then
- if selectedChar == "new" then
- loadCharacterCreation = false
- characterCreationErrorMessage = ""
- removeEventHandler("onClientRender", root, renderCharacterSelectInterface)
- createCharacterCreatioGUI()
- addEventHandler("onClientRender", root, renderCharacterCreationUI)
- elseif selectedChar == "newchardeny" then
- removeEventHandler("onClientRender", root, renderCharacterCreationUI)
- destroyCharacterCreatioGUI()
- addEventHandler("onClientRender", root, renderCharacterSelectInterface)
- elseif selectedChar == "newchardone" then
- if loadCharacterCreation then return end
- loadCharacterCreation = true
- setTimer(function()
- local name = guiGetText(nameEdit)
- local description = guiGetText(descriptionText)
- local gender = guiComboBoxGetItemText(genderCombos, guiComboBoxGetSelected(genderCombos))
- local nationality = guiComboBoxGetItemText(nationalityCombos, guiComboBoxGetSelected(nationalityCombos))
- name = name:gsub(" ", "_")
- if not name or name == "" then
- loadCharacterCreation = false
- characterCreationErrorMessage = "Karakter név megadása kötelező!"
- elseif #split(name, "_") < 2 then
- loadCharacterCreation = false
- characterCreationErrorMessage = "Név formátum: Vezetéknév Keresztnév"
- elseif #description < 100 then
- loadCharacterCreation = false
- characterCreationErrorMessage = "A karaktered leírása minimum 100 karakter kell álljon!"
- elseif #description > 500 then
- loadCharacterCreation = false
- characterCreationErrorMessage = "A karaktered leírása maximum 500 karakter lehet!"
- elseif gender == "" then
- loadCharacterCreation = false
- characterCreationErrorMessage = "Nem választottál a karakterednek nemet!"
- elseif nationality == "" then
- loadCharacterCreation = false
- characterCreationErrorMessage = "Nem választottál a karakterednek bőrszínt!"
- else
- local skin = 0
- if gender == "Férfi" then
- if nationality == "Fekete" then
- skin = 29
- elseif nationality == "Fehér" then
- skin = 31
- elseif nationality == "Ázsiai" then
- skin = 58
- end
- elseif gender == "Nő" then
- if nationality == "Fekete" then
- skin = 10
- elseif nationality == "Fehér" then
- skin = 12
- elseif nationality == "Ázsiai" then
- skin = 7
- end
- end
- triggerServerEvent("createCharacter", localPlayer, name, description, skin, getElementData(localPlayer, "char:gameaccountid"))
- end
- end, 1000, 1)
- elseif characters[selectedChar] then
- showCursor(false)
- triggerServerEvent("spawnCharacter", localPlayer, selectedChar)
- removeEventHandler("onClientRender", root, renderCharacterSelectInterface)
- removeEventHandler("onClientClick", root, spawnCharacter)
- characters = {}
- destroyElement(tempPed)
- tempPed = nil
- end
- end
- end
- function renderCharacterCreationUI()
- selectedChar = 0
- local cursorX, cursorY = getCursorPos()
- dxDrawRectangle(pX,pY,width,height,tocolor(0,0,0,150))
- dxDrawRectangle(pX,pY,width,30,tocolor(0,0,0,150))
- dxDrawText("Karakter létrehozás",pX+width/2,pY+7,pX+width/2,pY+7,tocolor(255,255,255,255),0.4,FONT,"center")
- dxDrawText("Karakter neve:",pX+10,pY+40,pX+10,pY+40,tocolor(255,255,255,255),0.4,FONT)
- dxDrawText("Karakter neme:",pX+10,pY+80,pX+10,pY+80,tocolor(255,255,255,255),0.4,FONT)
- dxDrawText("Karakter bőrszíne:",pX+10,pY+120,pX+10,pY+120,tocolor(255,255,255,255),0.4,FONT)
- dxDrawText("Karakter leírása:",pX+10,pY+185,pX+10,pY+185,tocolor(255,255,255,255),0.4,FONT)
- if errorFields[1] then
- dxDrawRectangle(pX+140,pY+40-5+30,width-150,1,tocolor(255,0,0,150))
- end
- if errorFields[2] then
- dxDrawRectangle(pX+140,pY+80-5+25,width-150,1,tocolor(255,0,0,150))
- end
- if errorFields[3] then
- dxDrawRectangle(pX+140,pY+120-5+25,width-150,1,tocolor(255,0,0,150))
- end
- if errorFields[4] then
- dxDrawRectangle(pX+140,pY+160-5+80,width-150,1,tocolor(255,0,0,150))
- end
- if loadCharacterCreation then
- imgrot = imgrot + 5
- if imgrot > 360 then
- imgrot = 0
- end
- dxDrawImage(pX+width/2-10,pY+height-115+5,20,20,"assets/loading.png", imgrot, 0, 0, nil, true)
- elseif characterCreationErrorMessage ~= "" then
- dxDrawText(characterCreationErrorMessage,pX+width/2,pY+height-115+7,pX+width/2,pY+height-115+7,tocolor(255,0,0,255),0.4,FONT,"center")
- end
- dxDrawRectangle(pX+10,pY+height-80,width-20,30,tocolor(0,0,0,100))
- if isInBox(cursorX, cursorY, pX+10, pX+10+width-20, pY+height-80, pY+height-80+30) then
- dxDrawRectangle(pX+10,pY+height-80,width-20,30,tocolor(0,0,0,100))
- selectedChar = "newchardone"
- end
- dxDrawText("Létrehoz",pX+width/2,pY+height-80+7,pX+width/2,pY+height-80+7,tocolor(255,255,255,255),0.4,FONT,"center")
- dxDrawRectangle(pX+10,pY+height-40,width-20,30,tocolor(0,0,0,100))
- if isInBox(cursorX, cursorY, pX+10, pX+10+width-20, pY+height-40, pY+height-40+30) then
- dxDrawRectangle(pX+10,pY+height-40,width-20,30,tocolor(0,0,0,100))
- selectedChar = "newchardeny"
- end
- dxDrawText("Mégsem",pX+width/2,pY+height-40+7,pX+width/2,pY+height-40+7,tocolor(255,255,255,255),0.4,FONT,"center")
- dxDrawRectangle(pX,pY+height-2,width,2,tocolor(50,125,200,255))
- end
- function renderCharacterSelectInterface()
- local cursorX, cursorY = getCursorPos()
- dxDrawRectangle(pX,pY,width,height,tocolor(0,0,0,150))
- dxDrawRectangle(pX,pY,width,30,tocolor(0,0,0,150))
- dxDrawText("Karakter választás",pX+width/2,pY+7,pX+width/2,pY+7,tocolor(255,255,255,255),0.4,FONT,"center")
- selectedChar = 0
- local y = pY+35
- for k,v in pairs(characters) do
- dxDrawRectangle(pX+10,y,width-20,60,tocolor(0,0,0,100))
- local skin = tonumber(v[3]) or 0
- if isInBox(cursorX, cursorY, pX+10, pX+10+width-20, y, y+60) then
- dxDrawRectangle(pX+10,y,width-20,60,tocolor(0,0,0,100))
- selectedChar = k
- setElementModel(tempPed, skin)
- end
- if skin < 10 then
- skin = "00"..skin
- elseif skin < 100 then
- skin = "0"..skin
- end
- if fileExists("assets/img/"..skin..".png") then
- dxDrawImage(pX+10,y,60,60,"assets/img/"..skin..".png")
- end
- dxDrawText(v[2]:gsub("_", " "),pX+width/2+30,y+5,pX+width/2+30,y+5,tocolor(255,255,255,255),0.4,FONT2,"center")
- dxDrawText("Utoljára a '"..v[4].."'-on láták,\n"..v[5]..".",pX+width/2+30,y+20,pX+width/2+30,y+20,tocolor(255,255,255,255),0.4,FONT,"center")
- y = y + 65
- end
- dxDrawRectangle(pX+10,pY+height-40,width-20,30,tocolor(0,0,0,100))
- if characterCount >= 4 then
- if isInBox(cursorX, cursorY, pX+10, pX+10+width-20, pY+height-40, pY+height-40+30) then
- dxDrawRectangle(pX+10,pY+height-40,width-20,30,tocolor(0,0,0,100))
- end
- dxDrawText("Nem hozhatsz létre több karaktert",pX+width/2,pY+height-40+7,pX+width/2,pY+height-40+7,tocolor(255,255,255,100),0.4,FONT,"center")
- else
- if isInBox(cursorX, cursorY, pX+10, pX+10+width-20, pY+height-40, pY+height-40+30) then
- dxDrawRectangle(pX+10,pY+height-40,width-20,30,tocolor(0,0,0,100))
- selectedChar = "new"
- end
- dxDrawText("Új karakter létrehozása",pX+width/2,pY+height-40+7,pX+width/2,pY+height-40+7,tocolor(255,255,255,255),0.4,FONT,"center")
- end
- dxDrawRectangle(pX,pY+height-2,width,2,tocolor(50,125,200,255))
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement