Advertisement
Guest User

Untitled

a guest
Jan 20th, 2019
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 29.90 KB | None | 0 0
  1. local defX, defY, defZ = 1479.8171386719, -1741.1892089844, 13.546875 - -0, 0, 4.4301533699036
  2. local sx,sy = guiGetScreenSize()
  3. local salt = "vgrpkeyscotland"
  4. local wx,wy = sx/2-490/2,sy/2-368/2
  5. local guiElements = {}
  6. local activeGui = "login"
  7. local loadedUser = ""
  8. local loadedPassword = ""
  9. local md55 = false
  10. local emlekezz = false
  11. local localPlayer = getLocalPlayer()
  12. local tempPeds = {}
  13. local pedData = {}
  14. local isCameraOnMove = false
  15. local selectedCharacter = 1
  16.  
  17. local imgrot = 0
  18. local img = 3
  19. local destroyTimer
  20. function sendPasswordMail(username)
  21. if isTimer(destroyTimer) then
  22. killTimer(destroyTimer)
  23. end
  24. img = 1
  25. addEventHandler("onClientRender", root, renderGTAVLoading)
  26. triggerServerEvent("sendPasswordRecover", localPlayer, username)
  27. end
  28.  
  29. addEvent("receivePasswordRecover", true)
  30. addEventHandler("receivePasswordRecover", root, function(data)
  31. if data == "Done" then
  32. img = 2
  33. elseif data == "Fail" then
  34. img = 4
  35. elseif data == "Nomail" then
  36. img = 5
  37. else
  38. img = 3
  39. end
  40. destroyTimer = setTimer(function()
  41. removeEventHandler("onClientRender", root, renderGTAVLoading)
  42. end, 5000, 1)
  43. end)
  44.  
  45. function renderGTAVLoading()
  46. if img > 0 then
  47. dxDrawRectangle(sx-200,sy-25,200,25,tocolor(0,0,0,180), true)
  48. if img == 1 then
  49. imgrot = imgrot + 5
  50. dxDrawImage(sx-195,sy-23,20,20,"assets/loading.png", imgrot, 0, 0, nil, true)
  51. dxDrawText("Keresés folyamatban ...",sx-165,sy-19,20,20,tocolor(255,255,255,255),1,"default","left","top",false,false,true)
  52. elseif img == 2 then
  53. dxDrawImage(sx-195,sy-22,20,20,"assets/success.png", 0, 0, 0, nil, true)
  54. dxDrawText("Email sikeresen elküldve!",sx-165,sy-19,20,20,tocolor(255,255,255,255),1,"default","left","top",false,false,true)
  55. elseif img == 3 then
  56. dxDrawImage(sx-195,sy-22,20,20,"assets/error.png", 0, 0, 0, nil, true)
  57. dxDrawText("Sikertelen email küldés!",sx-165,sy-19,20,20,tocolor(255,255,255,255),1,"default","left","top",false,false,true)
  58. elseif img == 4 then
  59. dxDrawImage(sx-195,sy-22,20,20,"assets/error.png", 0, 0, 0, nil, true)
  60. dxDrawText("Nincs találat!",sx-165,sy-19,20,20,tocolor(255,255,255,255),1,"default","left","top",false,false,true)
  61. elseif img == 5 then
  62. dxDrawImage(sx-195,sy-22,20,20,"assets/error.png", 0, 0, 0, nil, true)
  63. 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)
  64. end
  65. end
  66. end
  67.  
  68. addEventHandler("onClientResourceStart", resourceRoot, function()
  69. if not getElementData(localPlayer, "spawned") then
  70. triggerEvent("showLoginPanel", localPlayer)
  71. end
  72.  
  73. setBlurLevel(0)
  74. end)
  75.  
  76. addEvent("showLoginPanel", true)
  77. addEventHandler("showLoginPanel", root, function()
  78. setCameraInterior(0)
  79. setCameraMatrix(456.46926879883, -1588.6673583984, 53.359394073486, 389.35961914063, -1517.9282226563, 31.172163009644, 0, exports.ex_core:getPlayerFov())
  80. setElementPosition(localPlayer, 456.46926879883, -1588.6673583984, 53.359394073486)
  81. showChat(false)
  82. showCursor(true)
  83. fadeCamera(true)
  84. addEventHandler("onClientRender",root,renderLoginPanel)
  85. addEventHandler("onClientKey",root,handleKeys)
  86. createGuiElements(activeGui)
  87. end)
  88.  
  89. function addGuiElement(e)
  90. local this = #guiElements + 1
  91. guiElements[this] = e
  92. end
  93.  
  94. local loginConfig = "@loginData.json"
  95. function jsonGET(file)
  96. local fileHandle
  97. local jsonDATA = {}
  98. if not fileExists(file) then
  99. fileHandle = fileCreate(file)
  100. fileWrite(fileHandle, toJSON({["username"] = "", ["password"] = ""}))
  101. fileClose(fileHandle)
  102. fileHandle = fileOpen(file)
  103. else
  104. fileHandle = fileOpen(file)
  105. end
  106. if fileHandle then
  107. local buffer
  108. local allBuffer = ""
  109. while not fileIsEOF(fileHandle) do
  110. buffer = fileRead(fileHandle, 500)
  111. allBuffer = allBuffer..buffer
  112. end
  113. jsonDATA = fromJSON(allBuffer)
  114. fileClose(fileHandle)
  115. end
  116. return jsonDATA
  117. end
  118.  
  119. function jsonSAVE(file, data)
  120. if fileExists(file) then
  121. fileDelete(file)
  122. end
  123. local fileHandle = fileCreate(file)
  124. fileWrite(fileHandle, toJSON(data))
  125. fileFlush(fileHandle)
  126. fileClose(fileHandle)
  127. return true
  128. end
  129.  
  130. function createGuiElements(typ)
  131. for k,v in ipairs(guiElements) do
  132. if isElement(v) then
  133. destroyElement(v)
  134. end
  135. end
  136. if typ == "login" then
  137. activeGui = "login"
  138. label1 = guiCreateLabel(wx+70,wy+43,350,50,"",false)
  139. label2 = guiCreateLabel(wx+70,wy+120,350,50,"",false)
  140.  
  141. window = guiCreateWindow(wx,wy,490,368,"Bejelentkezés",false)
  142. edit1 = guiCreateEdit(70,25,350,50,"",false,window)
  143. edit2 = guiCreateEdit(70,100,350,50,"",false,window)
  144. guiEditSetMaxLength(edit1, 30)
  145. guiEditSetMaxLength(edit2, 50)
  146.  
  147. addEventHandler("onClientGUIChanged", edit1, function()
  148. guiSetText(label1, guiGetText(edit1))
  149. md55 = false
  150. end)
  151.  
  152. addEventHandler("onClientGUIChanged", edit2, function()
  153. md55 = false
  154. local strin = tostring(guiGetText(edit2))
  155. if strin:len() > 0 then
  156. local temp = ""
  157. for i=1, strin:len() do
  158. temp = temp .. "*"
  159. end
  160. guiSetText(label2, temp)
  161. else
  162. guiSetText(label2, "")
  163. end
  164. end)
  165.  
  166. button = guiCreateButton(20,240,450,50,"",false,window)
  167. button2 = guiCreateButton(20,295,450,30,"",false,window)
  168. button3 = guiCreateButton(20,175,450,40,"",false,window)
  169. button4 = guiCreateButton(20,335,450,30,"",false,window)
  170. addEventHandler("onClientGUIClick", button3, function()
  171. if source == button3 then
  172. emlekezz = not emlekezz
  173. end
  174. end)
  175.  
  176. addEventHandler("onClientGUIClick", button2, function()
  177. if source == button2 then
  178. createGuiElements("register")
  179. end
  180. end)
  181.  
  182. addEventHandler("onClientGUIClick", button4, function()
  183. if source == button4 then
  184. createGuiElements("lost_pw")
  185. end
  186. end)
  187.  
  188. addEventHandler("onClientGUIClick", button, function()
  189. if source == button then
  190. validate("login")
  191. end
  192. end)
  193.  
  194. local data = jsonGET(loginConfig)
  195. if data then
  196. if data["username"] and data["username"] ~= "" and data["password"] and data["password"] ~= "" then
  197. guiSetText(edit1, data["username"])
  198. guiSetText(edit2, data["password"])
  199. md55 = true
  200. emlekezz = true
  201. end
  202. end
  203.  
  204. guiSetAlpha(window, 0)
  205.  
  206. addGuiElement(window)
  207. addGuiElement(label1)
  208. addGuiElement(label2)
  209. elseif typ == "lost_pw" then
  210. activeGui = "lost_pw"
  211. label1 = guiCreateLabel(wx+70,wy+175,350,50,"",false)
  212. text = [[
  213. A jelszó visszaállítás menete:
  214.  
  215. 1. Beírod a felhasználóneved / az email címed.
  216. 2. Rákattintasz a "Jelszó visszaállítás" gombra.
  217. 3. A rendszer küld egy megerősítő emailt.
  218. 4. Rákattintasz a megerősítő linkre.
  219. 5. A rendszer elküldi az új jelszavad az email címedre.
  220. ]]
  221. label2 = guiCreateLabel(wx+20,wy+20,490,300,text,false)
  222. guiLabelSetHorizontalAlign(label2, "center")
  223.  
  224. window = guiCreateWindow(wx,wy,490,368,"Elfelejtett jelszó",false)
  225. edit1 = guiCreateEdit(70,160,350,50,"",false,window)
  226. guiEditSetMaxLength(edit1, 60)
  227.  
  228. addEventHandler("onClientGUIChanged", edit1, function()
  229. guiSetText(label1, guiGetText(edit1))
  230. end)
  231.  
  232. button = guiCreateButton(20,240,450,50,"",false,window)
  233. addEventHandler("onClientGUIClick", button, function()
  234. if source == button then
  235. validate("lost_pw")
  236. end
  237. end)
  238.  
  239. button2 = guiCreateButton(20,300,450,50,"",false,window)
  240. addEventHandler("onClientGUIClick", button2, function()
  241. if source == button2 then
  242. createGuiElements("login")
  243. end
  244. end)
  245.  
  246. guiSetAlpha(window, 0)
  247.  
  248. addGuiElement(window)
  249. addGuiElement(label1)
  250. addGuiElement(label2)
  251. elseif typ == "register" then
  252. activeGui = "register"
  253. label1 = guiCreateLabel(wx+70,wy+43,350,50,"",false)
  254. label2 = guiCreateLabel(wx+70,wy+120,350,50,"",false)
  255. label3 = guiCreateLabel(wx+70,wy+195,350,50,"",false)
  256.  
  257. window = guiCreateWindow(wx,wy,490,368,"Regisztráció",false)
  258. edit1 = guiCreateEdit(70,25,350,50,"",false,window)
  259. edit2 = guiCreateEdit(70,100,350,50,"",false,window)
  260. edit3 = guiCreateEdit(70,175,350,50,"",false,window)
  261. guiEditSetMaxLength(edit1, 30)
  262. guiEditSetMaxLength(edit2, 50)
  263. guiEditSetMaxLength(edit3, 50)
  264.  
  265. button = guiCreateButton(20,240,450,50,"",false,window)
  266. button2 = guiCreateButton(20,300,450,50,"",false,window)
  267. addEventHandler("onClientGUIClick", button2, function()
  268. if source == button2 then
  269. createGuiElements("login")
  270. end
  271. end)
  272.  
  273. addEventHandler("onClientGUIClick", button, function()
  274. if source == button then
  275. validate("register")
  276. end
  277. end)
  278.  
  279. addEventHandler("onClientGUIChanged", edit1, function()
  280. guiSetText(label1, guiGetText(edit1))
  281. end)
  282.  
  283. addEventHandler("onClientGUIChanged", edit2, function()
  284. local strin = tostring(guiGetText(edit2))
  285. if strin:len() > 0 then
  286. local temp = ""
  287. for i=1, strin:len() do
  288. temp = temp .. "*"
  289. end
  290. guiSetText(label2, temp)
  291. else
  292. guiSetText(label2, "")
  293. end
  294. end)
  295.  
  296. addEventHandler("onClientGUIChanged", edit3, function()
  297. local strin = tostring(guiGetText(edit3))
  298. if strin:len() > 0 then
  299. local temp = ""
  300. for i=1, strin:len() do
  301. temp = temp .. "*"
  302. end
  303. guiSetText(label3, temp)
  304. else
  305. guiSetText(label3, "")
  306. end
  307. end)
  308.  
  309. guiSetAlpha(window, 0)
  310.  
  311. addGuiElement(window)
  312. addGuiElement(label1)
  313. addGuiElement(label2)
  314. addGuiElement(label3)
  315. end
  316. end
  317.  
  318. function handleKeys(k,s)
  319. if (k == "enter" or k == "num_enter") and s then
  320. validate(activeGui)
  321. end
  322. end
  323.  
  324. local startTick = nil
  325. function validate(typ)
  326. startTick = getTickCount()
  327. if isTimer(theTimer) then
  328. exports.ex_gui:showInfoBox("Várj 10 másodpercet két próbálkozás között!")
  329. return
  330. end
  331. theTimer = setTimer(function() end, 10000, 1)
  332. if typ == "login" then
  333. local username = tostring(guiGetText(edit1))
  334. local password = tostring(guiGetText(edit2))
  335. if username and password then
  336. if username:len() > 0 and password:len() > 0 then
  337. if not md55 then
  338. triggerServerEvent("serverLoginAttempt", localPlayer, username, md5(salt..password))
  339. else
  340. triggerServerEvent("serverLoginAttempt", localPlayer, username, password, password)
  341. end
  342. else
  343. exports.ex_gui:showInfoBox("Felhasználónév és jelszó megadása kötelező!")
  344. end
  345. else
  346. exports.ex_gui:showInfoBox("Felhasználónév és jelszó megadása kötelező!")
  347. end
  348. elseif typ == "lost_pw" then
  349. local username = tostring(guiGetText(edit1))
  350. if username then
  351. if username:len() > 4 then
  352. sendPasswordMail(username)
  353. else
  354. exports.ex_gui:showInfoBox("Felhasználónév / email cím minimum 4 karakterből kell álljon!")
  355. end
  356. else
  357. exports.ex_gui:showInfoBox("Felhasználónév / email cím megadása kötelező!")
  358. end
  359. elseif typ == "register" then
  360. local username = tostring(guiGetText(edit1))
  361. local password = tostring(guiGetText(edit2))
  362. local password2 = tostring(guiGetText(edit3))
  363. if username and password and password2 then
  364. if username:len() > 0 and password:len() > 0 and password2:len() > 0 then
  365. if password ~= password2 then
  366. exports.ex_gui:showInfoBox("A két jelszó nem egyezik!")
  367. elseif username:len() < 4 then
  368. exports.ex_gui:showInfoBox("A felhasználónév minimum 4 karakterből kell álljon!")
  369. elseif password:len() < 6 then
  370. exports.ex_gui:showInfoBox("A jelszó minimum 6 karakterből kell álljon!")
  371. else
  372. triggerServerEvent("registerPlayer", localPlayer, username, md5(salt..password), getPlayerSerial(localPlayer))
  373. end
  374. else
  375. exports.ex_gui:showInfoBox("Felhasználónév és jelszó megadása kötelező!")
  376. end
  377. else
  378. exports.ex_gui:showInfoBox("Felhasználónév és jelszó megadása kötelező.")
  379. end
  380. end
  381. end
  382.  
  383. local progressImage = 0
  384. function renderLoginPanel()
  385. exports.ex_blur:createBlur()
  386. if progressImage < 1 then
  387. progressImage = progressImage + 0.01
  388. end
  389. local iX,iY,iZ = interpolateBetween(sx/2-38/2, -50, 0, wx+490/2-38/2, wy-70, 0, progressImage, "OutBounce")
  390. dxDrawImage(iX,iY,38,61,"assets/logo_new.png")
  391.  
  392. if activeGui == "login" then
  393. dxDrawImage(wx,wy,490,368,"assets/login.png")
  394. if emlekezz then
  395. dxDrawImage(wx,wy,490,368,"assets/login2.png")
  396. end
  397. elseif activeGui == "register" then
  398. dxDrawImage(wx,wy,490,368,"assets/register.png")
  399. elseif activeGui == "lost_pw" then
  400. dxDrawImage(wx,wy,490,368,"assets/lost_pw.png")
  401. end
  402. end
  403.  
  404. addEvent("successRegister", true)
  405. addEventHandler("successRegister", getRootElement(), function()
  406. createGuiElements("login")
  407. exports.ex_gui:showInfoBox("Sikeresen regisztráltál! Most már bejelentkezhetsz.")
  408. end)
  409.  
  410. function clearChatBox()
  411. for i=1, getChatboxLayout()["chat_lines"] do
  412. outputChatBox(" ")
  413. end
  414. end
  415. addCommandHandler("clearchat", clearChatBox)
  416. addCommandHandler("clear", clearChatBox)
  417. addCommandHandler("cc", clearChatBox)
  418.  
  419. local chatBlockTime = 0
  420. addEvent("receiveServerCharacterData", true)
  421. addEventHandler("receiveServerCharacterData", root, function(data)
  422. local username = ""
  423. local password = ""
  424. if emlekezz then
  425. username = getElementData(localPlayer, "temp:Username") or ""
  426. password = getElementData(localPlayer, "temp:Password") or ""
  427. setElementData(localPlayer, "temp:Username", nil)
  428. setElementData(localPlayer, "temp:Password", nil)
  429. end
  430. jsonSAVE(loginConfig, {["username"] = username, ["password"] = password})
  431.  
  432. exports.ex_job_core:applyJob(data.job)
  433.  
  434. chatBlockTime = data.chatblocktime
  435. setElementData(localPlayer, "char:Chattime", chatBlockTime)
  436. if data.chatblocked == 1 then
  437. if chatBlockTime ~= 0 then
  438. startChatBlockTimer(chatBlockTime)
  439. end
  440. end
  441.  
  442. setElementData(localPlayer, "spawned", true)
  443. exports.ex_core:toggleComponents(false)
  444. triggerEvent("spawnVehiclesFunction", localPlayer)
  445.  
  446. setElementFrozen(localPlayer, false)
  447. setCameraTarget(localPlayer)
  448. toggleAllControls(true, true, true)
  449.  
  450. exports.ex_gui:showInfoBox("Sikeresen bejelentkeztél, jó szórakozást kivánunk a HL-en!")
  451.  
  452. if data.adolevonas == 0 then
  453. triggerEvent("initTax", localPlayer)
  454. end
  455. exports.ex_inventory:loadPlayerItems(data.id)
  456. exports.ex_drogplants:countDownPlantTime(data.plantTime)
  457. end)
  458.  
  459. local syncWithServer = false
  460. local syncTimer
  461. function startChatBlockTimer(time)
  462. if isTimer(syncTimer) then killTimer(syncTimer) end
  463. syncTimer = setTimer(function()
  464. syncWithServer = not syncWithServer
  465. end, 10000, 0)
  466. timer1 = setTimer(function()
  467. chatBlockTime = chatBlockTime - 1
  468. if chatBlockTime == 0 then
  469. if isTimer(timer1) then killTimer(timer1) end
  470. if isTimer(syncTimer) then killTimer(syncTimer) end
  471. if syncWithServer then
  472. syncWithServer = false
  473. setElementData(localPlayer, "char:Chatblocked", 0, true)
  474. else
  475. setElementData(localPlayer, "char:Chatblocked", 0, false)
  476. end
  477. outputChatBox("[HL] #FFFFFFLejárt a chat tiltásod!", 255, 0, 0, true)
  478. end
  479. setElementData(localPlayer, "char:Chattime", chatBlockTime)
  480. end, 1000, chatBlockTime)
  481. end
  482.  
  483. addEventHandler("onClientResourceStart", resourceRoot, function()
  484. if getElementData(localPlayer, "spawned") then
  485. local chatBlocked = tonumber(getElementData(localPlayer, "char:Chatblocked"))
  486. chatBlockTime = tonumber(getElementData(localPlayer, "char:Chattime")) or 0
  487. if chatBlocked == 1 then
  488. if chatBlockTime == 0 then
  489. else
  490. startChatBlockTimer(chatBlockTime)
  491. end
  492. end
  493. end
  494. end)
  495.  
  496. local countdown = 0
  497. addEvent("initChatBanCountDown", true)
  498. addEventHandler("initChatBanCountDown", root, function(t)
  499. countdown = t
  500. if t ~= 0 then
  501. if isTimer(timer1) then
  502. killTimer(timer1)
  503. end
  504. setElementData(localPlayer, "char:Chattime", t)
  505. timer1 = setTimer(function()
  506. countdown = countdown - 1
  507. if countdown == 0 then
  508. killTimer(timer1)
  509. setElementData(localPlayer, "char:Chatblocked", 0)
  510. outputChatBox("[HL] #FFFFFFLejárt a chat tiltásod!", 255, 0, 0, true)
  511. end
  512. setElementData(localPlayer, "char:Chattime", countdown)
  513. end, 1000, countdown)
  514. end
  515. end)
  516.  
  517. function removeLoginBox()
  518. for k,v in ipairs(guiElements) do
  519. if isElement(v) then
  520. destroyElement(v)
  521. end
  522. end
  523.  
  524. setCameraTarget(localPlayer)
  525. guiElements = {}
  526. showCursor(false)
  527. showChat(true)
  528. removeEventHandler("onClientRender",root,renderLoginPanel)
  529. removeEventHandler("onClientKey",root,handleKeys)
  530. end
  531.  
  532. --- KARAKTER VÁLASZTÓ BY XENIUS 2015
  533. local sm = {}
  534. sm.moov = 0
  535. sm.object1,sm.object2 = nil,nil
  536. local function removeCamHandler()
  537. if(sm.moov == 1)then
  538. sm.moov = 0
  539. end
  540. end
  541.  
  542. local function camRender()
  543. if (sm.moov == 1) then
  544. local x1,y1,z1 = getElementPosition(sm.object1)
  545. local x2,y2,z2 = getElementPosition(sm.object2)
  546. setCameraMatrix(x1,y1,z1,x2,y2,z2,0,exports.ex_core:getPlayerFov())
  547. end
  548. end
  549. addEventHandler("onClientPreRender",root,camRender)
  550.  
  551. local function smoothMoveCamera(x1,y1,z1,x1t,y1t,z1t,x2,y2,z2,x2t,y2t,z2t,time)
  552. if(sm.moov == 1)then return false end
  553. sm.object1 = createObject(1337,x1,y1,z1)
  554. sm.object2 = createObject(1337,x1t,y1t,z1t)
  555.  
  556. setElementDimension(sm.object1, getElementDimension(localPlayer))
  557. setElementDimension(sm.object2, getElementDimension(localPlayer))
  558.  
  559. setElementAlpha(sm.object1,0)
  560. setElementAlpha(sm.object2,0)
  561. setObjectScale(sm.object1,0.01)
  562. setObjectScale(sm.object2,0.01)
  563. moveObject(sm.object1,time,x2,y2,z2,0,0,0,"InOutQuad")
  564. setElementAlpha(localPlayer, 0)
  565. moveObject(sm.object2,time,x2t,y2t,z2t,0,0,0,"InOutQuad")
  566. sm.moov = 1
  567. setTimer(removeCamHandler,time,1)
  568. setTimer(destroyElement,time,1,sm.object1)
  569. setTimer(destroyElement,time,1,sm.object2)
  570. return true
  571. end
  572.  
  573. local pedPositions = {
  574. [1] = {
  575. pos = {402.17541503906, -1532.3784179688, 32.2734375},
  576. rot = {0, 0, 217.42056274414},
  577. cam = {405.01971435547, -1535.5256347656, 33.379688262939, 342.66143798828, -1460.1274414063, 12.726487159729},
  578. },
  579. }
  580.  
  581. function checkCursor()
  582. if isCursorShowing() then
  583. return true
  584. else
  585. return false
  586. end
  587. end
  588.  
  589. function getCursorPos()
  590. if checkCursor() then
  591. cx,cy = getCursorPosition()
  592. cx,cy = cx*sx,cy*sy
  593. else
  594. cx,cy = -500,-500
  595. end
  596. return cx,cy
  597. end
  598.  
  599. function isInBox(x, y, xmin, xmax, ymin, ymax)
  600. if checkCursor() then
  601. return x >= xmin and x <= xmax and y >= ymin and y <= ymax
  602. else
  603. return false
  604. end
  605. end
  606.  
  607. local tempPed = nil
  608. local selectedChar = 0
  609. local characters = {}
  610. local FONT = exports.ex_core:getFont("roboto.ttf")
  611. local FONT2 = exports.ex_core:getFont("montserrat.ttf")
  612. local width, height = 400, 350
  613. local pX = 0
  614. local pY = sy/2-height/2
  615. local loadCharacterCreation = false
  616. local characterCreationErrorMessage = ""
  617. local errorFields = {}
  618. local characterCount = 0
  619.  
  620. addEvent("receiveCharacters", true)
  621. addEventHandler("receiveCharacters", root, function(tbl, test, created)
  622. if isElement(tempPed) then
  623. destroyElement(tempPed)
  624. end
  625. if created then
  626. removeEventHandler("onClientRender", root, renderCharacterCreationUI)
  627. destroyCharacterCreatioGUI()
  628. addEventHandler("onClientRender", root, renderCharacterSelectInterface)
  629. else
  630. removeLoginBox()
  631. showCursor(true)
  632. exports.ex_core:toggleComponents(true)
  633. end
  634. characters = tbl
  635. characterCount = 0
  636. local position = pedPositions[1]
  637. for k,v in pairs(characters) do
  638. if characterCount == 0 then
  639. tempPed = createPed(v[3], unpack(position.pos))
  640. setElementRotation(tempPed, unpack(position.rot))
  641. setElementDimension(tempPed, getElementDimension(localPlayer))
  642. end
  643. characterCount=characterCount+1
  644. local x,y,z,dim
  645. if v[4] then
  646. x,y,z,dim = v[4][1],v[4][2],v[4][3],v[4][4]
  647. else
  648. x,y,z,dim = defX, defY, defZ, 0
  649. end
  650. local zone = getZoneName(x,y,z)
  651. v[4] = zone
  652. if dim > 0 then
  653. local id, entrance = exports.ex_building:findInterior(dim)
  654. if id > 0 and entrance then
  655. v[4] = getElementData(entrance, "name")
  656. end
  657. end
  658.  
  659. if v[5] == 0 or not v[5] then
  660. v[5] = "a mai napon"
  661. else
  662. v[5] = v[5].." nappal ezelőtt"
  663. end
  664. end
  665. if not created then
  666. if test then
  667. moveCameraToCharacter(1, 2000, true)
  668. addEventHandler("onClientClick", root, spawnCharacter)
  669. end
  670. end
  671. end)
  672.  
  673. addEvent("testSuccessful", true)
  674. addEventHandler("testSuccessful", root, function()
  675. moveCameraToCharacter(1, 2000, true)
  676. addEventHandler("onClientClick", root, spawnCharacter)
  677. end)
  678.  
  679. function moveCameraToCharacter(id, time, first)
  680. if isCameraOnMove then return end
  681. if pedPositions[id] then
  682. local x1,y1,z1,x1t,y1t,z1t = getCameraMatrix()
  683. local x2,y2,z2,x2t,y2t,z2t = unpack(pedPositions[id].cam)
  684. isCameraOnMove = true
  685. smoothMoveCamera(x1,y1,z1,x1t,y1t,z1t,x2,y2,z2,x2t,y2t,z2t,time)
  686. setTimer(function(first)
  687. isCameraOnMove = false
  688. if first then
  689. addEventHandler("onClientRender", root, renderCharacterSelectInterface)
  690. end
  691. end, time, 1, first)
  692. end
  693. end
  694.  
  695. local nameEdit, descriptionText, genderCombos, nationalityCombos
  696. function createCharacterCreatioGUI()
  697. nameEdit = guiCreateEdit(pX+140,pY+40-5,width-150,30,"",false)
  698. guiSetAlpha(nameEdit, 0.8)
  699.  
  700. descriptionText = guiCreateMemo(pX+140,pY+160-5,width-150,80,"",false)
  701. guiSetAlpha(descriptionText, 0.8)
  702.  
  703. genderCombos = guiCreateComboBox(pX+140,pY+80-2,width-150,80,"",false)
  704. guiSetAlpha(genderCombos, 0.8)
  705. guiComboBoxAddItem(genderCombos, "Férfi")
  706. guiComboBoxAddItem(genderCombos, "Nő")
  707.  
  708. nationalityCombos = guiCreateComboBox(pX+140,pY+120-2,width-150,80,"",false)
  709. guiSetAlpha(nationalityCombos, 0.8)
  710. guiComboBoxAddItem(nationalityCombos, "Fekete")
  711. guiComboBoxAddItem(nationalityCombos, "Fehér")
  712. guiComboBoxAddItem(nationalityCombos, "Ázsiai")
  713. addEventHandler("onClientGUIComboBoxAccepted", root, guiComboChange)
  714. end
  715.  
  716. function destroyCharacterCreatioGUI()
  717. removeEventHandler("onClientGUIComboBoxAccepted", root, guiComboChange)
  718. if isElement(nameEdit) then
  719. destroyElement(nameEdit)
  720. end
  721. if isElement(descriptionText) then
  722. destroyElement(descriptionText)
  723. end
  724. if isElement(genderCombos) then
  725. destroyElement(genderCombos)
  726. end
  727. if isElement(nationalityCombos) then
  728. destroyElement(nationalityCombos)
  729. end
  730. end
  731.  
  732. addEvent("receiveCharacterCreationError", true)
  733. addEventHandler("receiveCharacterCreationError", root, function(err)
  734. loadCharacterCreation = false
  735. characterCreationErrorMessage = err
  736. end)
  737.  
  738. function guiComboChange()
  739. local gender = guiComboBoxGetItemText(genderCombos, guiComboBoxGetSelected(genderCombos))
  740. local nationality = guiComboBoxGetItemText(nationalityCombos, guiComboBoxGetSelected(nationalityCombos))
  741. local skin = 0
  742. if gender == "Férfi" then
  743. if nationality == "Fekete" then
  744. skin = 29
  745. elseif nationality == "Fehér" then
  746. skin = 31
  747. elseif nationality == "Ázsiai" then
  748. skin = 58
  749. end
  750. elseif gender == "Nő" then
  751. if nationality == "Fekete" then
  752. skin = 10
  753. elseif nationality == "Fehér" then
  754. skin = 12
  755. elseif nationality == "Ázsiai" then
  756. skin = 7
  757. end
  758. end
  759. if skin > 0 then
  760. setElementModel(tempPed, skin)
  761. end
  762. end
  763.  
  764. function spawnCharacter(button, state)
  765. if isCameraOnMove then return end
  766. if button == "left" and state == "down" then
  767. if selectedChar == "new" then
  768. loadCharacterCreation = false
  769. characterCreationErrorMessage = ""
  770. removeEventHandler("onClientRender", root, renderCharacterSelectInterface)
  771. createCharacterCreatioGUI()
  772. addEventHandler("onClientRender", root, renderCharacterCreationUI)
  773. elseif selectedChar == "newchardeny" then
  774. removeEventHandler("onClientRender", root, renderCharacterCreationUI)
  775. destroyCharacterCreatioGUI()
  776. addEventHandler("onClientRender", root, renderCharacterSelectInterface)
  777. elseif selectedChar == "newchardone" then
  778. if loadCharacterCreation then return end
  779. loadCharacterCreation = true
  780. setTimer(function()
  781. local name = guiGetText(nameEdit)
  782. local description = guiGetText(descriptionText)
  783. local gender = guiComboBoxGetItemText(genderCombos, guiComboBoxGetSelected(genderCombos))
  784. local nationality = guiComboBoxGetItemText(nationalityCombos, guiComboBoxGetSelected(nationalityCombos))
  785. name = name:gsub(" ", "_")
  786. if not name or name == "" then
  787. loadCharacterCreation = false
  788. characterCreationErrorMessage = "Karakter név megadása kötelező!"
  789. elseif #split(name, "_") < 2 then
  790. loadCharacterCreation = false
  791. characterCreationErrorMessage = "Név formátum: Vezetéknév Keresztnév"
  792. elseif #description < 100 then
  793. loadCharacterCreation = false
  794. characterCreationErrorMessage = "A karaktered leírása minimum 100 karakter kell álljon!"
  795. elseif #description > 500 then
  796. loadCharacterCreation = false
  797. characterCreationErrorMessage = "A karaktered leírása maximum 500 karakter lehet!"
  798. elseif gender == "" then
  799. loadCharacterCreation = false
  800. characterCreationErrorMessage = "Nem választottál a karakterednek nemet!"
  801. elseif nationality == "" then
  802. loadCharacterCreation = false
  803. characterCreationErrorMessage = "Nem választottál a karakterednek bőrszínt!"
  804. else
  805. local skin = 0
  806. if gender == "Férfi" then
  807. if nationality == "Fekete" then
  808. skin = 29
  809. elseif nationality == "Fehér" then
  810. skin = 31
  811. elseif nationality == "Ázsiai" then
  812. skin = 58
  813. end
  814. elseif gender == "Nő" then
  815. if nationality == "Fekete" then
  816. skin = 10
  817. elseif nationality == "Fehér" then
  818. skin = 12
  819. elseif nationality == "Ázsiai" then
  820. skin = 7
  821. end
  822. end
  823. triggerServerEvent("createCharacter", localPlayer, name, description, skin, getElementData(localPlayer, "char:gameaccountid"))
  824. end
  825. end, 1000, 1)
  826. elseif characters[selectedChar] then
  827. showCursor(false)
  828. triggerServerEvent("spawnCharacter", localPlayer, selectedChar)
  829. removeEventHandler("onClientRender", root, renderCharacterSelectInterface)
  830. removeEventHandler("onClientClick", root, spawnCharacter)
  831. characters = {}
  832. destroyElement(tempPed)
  833. tempPed = nil
  834. end
  835. end
  836. end
  837.  
  838. function renderCharacterCreationUI()
  839. selectedChar = 0
  840. local cursorX, cursorY = getCursorPos()
  841. dxDrawRectangle(pX,pY,width,height,tocolor(0,0,0,150))
  842. dxDrawRectangle(pX,pY,width,30,tocolor(0,0,0,150))
  843. dxDrawText("Karakter létrehozás",pX+width/2,pY+7,pX+width/2,pY+7,tocolor(255,255,255,255),0.4,FONT,"center")
  844.  
  845. dxDrawText("Karakter neve:",pX+10,pY+40,pX+10,pY+40,tocolor(255,255,255,255),0.4,FONT)
  846. dxDrawText("Karakter neme:",pX+10,pY+80,pX+10,pY+80,tocolor(255,255,255,255),0.4,FONT)
  847. dxDrawText("Karakter bőrszíne:",pX+10,pY+120,pX+10,pY+120,tocolor(255,255,255,255),0.4,FONT)
  848. dxDrawText("Karakter leírása:",pX+10,pY+185,pX+10,pY+185,tocolor(255,255,255,255),0.4,FONT)
  849.  
  850. if errorFields[1] then
  851. dxDrawRectangle(pX+140,pY+40-5+30,width-150,1,tocolor(255,0,0,150))
  852. end
  853.  
  854. if errorFields[2] then
  855. dxDrawRectangle(pX+140,pY+80-5+25,width-150,1,tocolor(255,0,0,150))
  856. end
  857.  
  858. if errorFields[3] then
  859. dxDrawRectangle(pX+140,pY+120-5+25,width-150,1,tocolor(255,0,0,150))
  860. end
  861.  
  862. if errorFields[4] then
  863. dxDrawRectangle(pX+140,pY+160-5+80,width-150,1,tocolor(255,0,0,150))
  864. end
  865.  
  866. if loadCharacterCreation then
  867. imgrot = imgrot + 5
  868. if imgrot > 360 then
  869. imgrot = 0
  870. end
  871. dxDrawImage(pX+width/2-10,pY+height-115+5,20,20,"assets/loading.png", imgrot, 0, 0, nil, true)
  872. elseif characterCreationErrorMessage ~= "" then
  873. 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")
  874. end
  875.  
  876. dxDrawRectangle(pX+10,pY+height-80,width-20,30,tocolor(0,0,0,100))
  877. if isInBox(cursorX, cursorY, pX+10, pX+10+width-20, pY+height-80, pY+height-80+30) then
  878. dxDrawRectangle(pX+10,pY+height-80,width-20,30,tocolor(0,0,0,100))
  879. selectedChar = "newchardone"
  880. end
  881. 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")
  882.  
  883. dxDrawRectangle(pX+10,pY+height-40,width-20,30,tocolor(0,0,0,100))
  884. if isInBox(cursorX, cursorY, pX+10, pX+10+width-20, pY+height-40, pY+height-40+30) then
  885. dxDrawRectangle(pX+10,pY+height-40,width-20,30,tocolor(0,0,0,100))
  886. selectedChar = "newchardeny"
  887. end
  888. 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")
  889.  
  890. dxDrawRectangle(pX,pY+height-2,width,2,tocolor(50,125,200,255))
  891. end
  892.  
  893. function renderCharacterSelectInterface()
  894. local cursorX, cursorY = getCursorPos()
  895. dxDrawRectangle(pX,pY,width,height,tocolor(0,0,0,150))
  896. dxDrawRectangle(pX,pY,width,30,tocolor(0,0,0,150))
  897. dxDrawText("Karakter választás",pX+width/2,pY+7,pX+width/2,pY+7,tocolor(255,255,255,255),0.4,FONT,"center")
  898.  
  899. selectedChar = 0
  900. local y = pY+35
  901. for k,v in pairs(characters) do
  902. dxDrawRectangle(pX+10,y,width-20,60,tocolor(0,0,0,100))
  903. local skin = tonumber(v[3]) or 0
  904. if isInBox(cursorX, cursorY, pX+10, pX+10+width-20, y, y+60) then
  905. dxDrawRectangle(pX+10,y,width-20,60,tocolor(0,0,0,100))
  906. selectedChar = k
  907. setElementModel(tempPed, skin)
  908. end
  909. if skin < 10 then
  910. skin = "00"..skin
  911. elseif skin < 100 then
  912. skin = "0"..skin
  913. end
  914. if fileExists("assets/img/"..skin..".png") then
  915. dxDrawImage(pX+10,y,60,60,"assets/img/"..skin..".png")
  916. end
  917.  
  918. 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")
  919. 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")
  920. y = y + 65
  921. end
  922.  
  923. dxDrawRectangle(pX+10,pY+height-40,width-20,30,tocolor(0,0,0,100))
  924. if characterCount >= 4 then
  925. if isInBox(cursorX, cursorY, pX+10, pX+10+width-20, pY+height-40, pY+height-40+30) then
  926. dxDrawRectangle(pX+10,pY+height-40,width-20,30,tocolor(0,0,0,100))
  927. end
  928. 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")
  929. else
  930. if isInBox(cursorX, cursorY, pX+10, pX+10+width-20, pY+height-40, pY+height-40+30) then
  931. dxDrawRectangle(pX+10,pY+height-40,width-20,30,tocolor(0,0,0,100))
  932. selectedChar = "new"
  933. end
  934. 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")
  935. end
  936.  
  937. dxDrawRectangle(pX,pY+height-2,width,2,tocolor(50,125,200,255))
  938. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement