Advertisement
Guest User

Untitled

a guest
Feb 13th, 2016
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 15.08 KB | None | 0 0
  1. local screenWidth, screenHeight = guiGetScreenSize()
  2.  
  3. resourceRoot = getResourceRootElement( getThisResource( ) )
  4. localPlayer = getLocalPlayer()
  5. infoTable = {}
  6. Login_Edit = {}
  7. marwinButtons = {}
  8. font = {}
  9. font[-1] = guiCreateFont( "font2.ttf", 8 )
  10. font[0] = guiCreateFont( "font.ttf", 12 )
  11. font[1] = guiCreateFont( "font.ttf", 16 )
  12. font[2] = guiCreateFont( "font.ttf", 20 )
  13. font[3] = guiCreateFont( "font.ttf", 24 )
  14.  
  15. --Button
  16. function createMarwinButton(x,y,widht,height,text,bool,parent,info)
  17. button = guiCreateStaticImage(x,y,widht,height,"images/button_standart.png", bool,parent or nil)
  18. table.insert(marwinButtons,button)
  19. guiBringToFront(button)
  20. label = guiCreateLabel(0,0,1,1,text,bool,button)
  21. guiBringToFront(label)
  22. setElementData(label,"parent",button)
  23. setElementData(button,"info",info)
  24. guiSetFont(label,font[1])
  25. guiLabelSetVerticalAlign (label, "center")
  26. guiLabelSetHorizontalAlign (label, "center")
  27. addEventHandler("onClientMouseEnter",label,markButton,false)
  28. addEventHandler("onClientMouseLeave",label,unmarkButton,false)
  29. return label
  30. end
  31.  
  32. function markButton ()
  33. parent = getElementData(source,"parent")
  34. guiStaticImageLoadImage (parent,"images/button_mouse.png")
  35. setElementData(getLocalPlayer(),"clickedButton",parent)
  36. end
  37.  
  38. function unmarkButton (b,s)
  39. parent = getElementData(source,"parent")
  40. guiStaticImageLoadImage (parent,"images/button_standart.png")
  41. setElementData(getLocalPlayer(),"clickedButton",false)
  42. end
  43. --Button end
  44.  
  45.  
  46.  
  47. function build_loginWin()
  48. guiSetInputMode("no_binds_when_editing")
  49. showCursor(true)
  50. confFile = xmlLoadFile("preferencesL.xml")
  51. if (confFile) then
  52. infoTable["account"] = xmlNodeGetAttribute(confFile,"username")
  53. infoTable["pass"] = xmlNodeGetAttribute(confFile,"pass")
  54. else
  55. confFile = xmlCreateFile("preferencesL.xml","user")
  56. xmlNodeSetAttribute(confFile,"username","")
  57. xmlNodeSetAttribute(confFile,"pass","")
  58.  
  59. infoTable["account"] = getPlayerName(localPlayer)
  60. infoTable["pass"] = ""
  61. end
  62. xmlSaveFile(confFile)
  63. confFile = xmlLoadFile("preferences.xml")
  64. if (confFile) then
  65. xmlNodeSetAttribute(confFile,"username","")
  66. xmlNodeSetAttribute(confFile,"pass","")
  67. end
  68. --Create Window
  69. --Background
  70. tab_front1 = guiCreateStaticImage( 0, 0, screenWidth, screenHeight, "images/bg.png", true )
  71. background_front = guiCreateStaticImage( 0.2, 0.25, 0.6, 0.5, "images/background_1.png", true ,tab_front1)
  72. --tab_front = guiCreateStaticImage( 0.2, 76, 0.3, 0.15, "images/tab.png", true ,tab_front1)
  73. --Header Text
  74. --headline = guiCreateLabel(0,0.15,1,0.8,"Willkommen auf dem Deutschen DayZ Server",true,tab_front)
  75. --guiSetFont(headline,font[2])
  76. --guiLabelSetHorizontalAlign (headline, "center")
  77. --Login
  78. --login_box = guiCreateStaticImage( 0.025, 0.1, 0.325, 0.85, "images/box_background.png", true , background_front)
  79. loginButton = createMarwinButton(0.38,0.4,0.175,0.1,"Einloggen",true,background_front,"login")
  80. --Text
  81. --loginInfo = guiCreateLabel(0.025, 0.325, 0.325, 0.175,"Einloggen\noder\nRegistrieren!",true,background_front)
  82. --guiSetFont(loginInfo,font[1])
  83. --guiLabelSetHorizontalAlign (loginInfo, "center")
  84. --guiLabelSetColor ( loginInfo,132,18,18)
  85. --Username
  86. --username = guiCreateLabel(0.1, 0.2, 0.325, 0.04,"Benutzername",true,background_front)
  87. --guiSetFont(username,font[0])
  88. --guiLabelSetHorizontalAlign (username, "center")
  89. --Edit Box
  90. Login_Edit[1] = guiCreateEdit(0.25, 0.2, 0.175, 0.05, infoTable["account"], true,background_front)
  91. --Passwort
  92. --password = guiCreateLabel(0.1, 0.3, 0.325, 0.04,"Passwort",true,background_front)
  93. --guiSetFont(password,font[0])
  94. --guiLabelSetHorizontalAlign (password, "center")
  95. --loginIcon = guiCreateStaticImage( 0.1, 0.525, 0.04, 0.05, "images/login_icon.png", true , background_front)
  96. --Edit Box
  97. Login_Edit[2] = guiCreateEdit(0.25, 0.29, 0.175, 0.05, infoTable["pass"], true,background_front)
  98. guiEditSetMasked(Login_Edit[2],true)
  99. --Register
  100. --register_box = guiCreateStaticImage( 0.375, 0.45, 0.325, 0.5, "images/box_background.png", true , background_front)
  101. registerButton = createMarwinButton(0.38,0.86,0.175,0.1,"Registrieren",true,background_front,"register")
  102. --Text
  103. --registerInfo = guiCreateLabel(0.375, 0.475, 0.325, 0.1,"Regestrieren!",true,background_front)
  104. --guiSetFont(registerInfo,font[1])
  105. --guiLabelSetHorizontalAlign (registerInfo, "center")
  106. --guiLabelSetColor ( registerInfo,132,18,18)
  107. --Username
  108. --username = guiCreateLabel(0.375, 0.55, 0.325, 0.04,"Benutzername",true,background_front)
  109. --guiSetFont(username,font[0])
  110. --guiLabelSetHorizontalAlign (username, "center")
  111. --Edit Box
  112. Login_Edit[3] = guiCreateEdit(0.25, 0.645, 0.175, 0.05, "", true,background_front)
  113. --Passwort
  114. --password = guiCreateLabel(0.375, 0.675, 0.325, 0.04,"Passwort",true,background_front)
  115. --guiSetFont(password,font[0])
  116. --guiLabelSetHorizontalAlign (password, "center")
  117. --loginIcon = guiCreateStaticImage( 0.45, 0.475, 0.04, 0.05, "images/signup_icon.png", true , background_front)
  118. --Edit Box
  119. Login_Edit[4] = guiCreateEdit(0.25, 0.735, 0.175, 0.05, "", true,background_front)
  120. guiEditSetMasked(Login_Edit[4],true)
  121. --Playing as a Guest
  122. --guest_box = guiCreateStaticImage( 0.375, 0.105, 0.325, 0.3, "images/box_background.png", true , background_front)
  123. --guestButton = createMarwinButton(0.45,0.275,0.175,0.1,"Guestmode",true,background_front,"guest")
  124. --guiSetFont(guestButton,font[0])
  125. --Text
  126. --guestInfo = guiCreateLabel(0.375, 0.125, 0.325, 0.225,"Der Offizielle Deutsche\nMulti Theft Auto: San Andreas\nDayZ - Zombie Survival Server \n Letztes Update am: \n 07.10.14",true,background_front)
  127. --guiSetFont(guestInfo,font[1])
  128. --guiLabelSetHorizontalAlign (guestInfo, "center")
  129. --guiLabelSetColor ( guestInfo,50,255,50)
  130. --News/Updates
  131. --News Headline
  132. --newsH = guiCreateLabel(0.726, 0.115, 0.25, 0.05,"News:",true,background_front)
  133. --guiSetFont(newsH,font[0])
  134. --guiLabelSetHorizontalAlign (newsH, "center")
  135. --guiLabelSetColor ( newsH,50,255,50)
  136. --news_box1
  137. news_box1 = guiCreateStaticImage( 0.58, 0.16, 0.39, 0.2, "images/news.png", true , background_front)
  138. guiSetAlpha(news_box1,0.8)
  139. news1 = guiCreateLabel(0.025, 0.125, 0.9, 0.9,"#Update 01.05.2015\nDie Script-Lua Engine wurde aktuallisiert bzw. auf\nauf den neusten Stand gebracht um mehr FPS aus dem Server\nrauszuholen damit mehr Spieler als 50, und mehr Loot\nPunkte als 32376 exestieren können..",true,news_box1)
  140. guiSetFont(news1,"default-bold-small")
  141. --news_box1_new = guiCreateStaticImage( 0, 0, 0.15, 0.1, "images/new.png", true , news_box1)
  142. guiSetVisible(news_box1_new,false)
  143. --news_box2
  144. news_box2 = guiCreateStaticImage( 0.58, 0.36, 0.39, 0.2, "images/news.png", true , background_front)
  145. guiSetAlpha(news_box2,0.4)
  146. news2 = guiCreateLabel(0.025, 0.125, 0.9, 0.9,"#Update 28.04.2015\nDie kompletten Script-Archive wurden gesäubert und\n neu sortiert angeordnet. Das alles einen\ngewissen überblich behällt.",true,news_box2)
  147. guiSetFont(news2,"default-bold-small")
  148. --news_box2_new = guiCreateStaticImage( 0, 0, 0.15, 0.1, "images/new.png", true , news_box2)
  149. guiSetVisible(news_box2_new,false)
  150. --news_box3
  151. news_box3 = guiCreateStaticImage( 0.58, 0.56, 0.39, 0.2, "images/news.png", true , background_front)
  152. guiSetAlpha(news_box3,0.8)
  153. news3 = guiCreateLabel(0.025, 0.125, 0.9, 0.9,"#Update 25.04.2015\nSicherheits Fixxes sowie Bugfixxes wurden durchgeführt an den\nBekannten fehlern wie z.B. das auffüllen der Wasserflasche..",true,news_box3)
  154. guiSetFont(news3,"default-bold-small")
  155. --news_box3_new = guiCreateStaticImage( 0, 0, 0.15, 0.1, "images/new.png", true , news_box3)
  156. guiSetVisible(news_box3_new,false)
  157. --news_box4
  158. news_box4 = guiCreateStaticImage( 0.58, 0.76, 0.39, 0.19, "images/news.png", true , background_front)
  159. guiSetAlpha(news_box4,0.4)
  160. news4 = guiCreateLabel(0.025, 0.125, 0.9, 0.9,"#Update 13.03.2015\nWir haben uns mal dran gesetzt und ein neues Scoreboard gecoded.\nFür das Scoreboard wird noch einiges Besprochen werden müssen\nwie und wann wir das einbauen da wir den Server evt. Neustarten müssen.",true,news_box4)
  161. guiSetFont(news4,"default-bold-small")
  162. --news_box4_new = guiCreateStaticImage( 0, 0, 0.15, 0.1, "images/new.png", true , news_box4)
  163. guiSetVisible(news_box4_new,false)
  164. --others
  165. --news_box = guiCreateStaticImage( 0.626, 0.1, 0.25, 0.85, "images/box_background.png", true , background_front)
  166. --guiCreateStaticImage(0.77, 0.1075, 0.04, 0.05, "images/on.png", true , background_front)
  167. end
  168.  
  169.  
  170.  
  171. --LOGIN
  172. function clickPanelButton (button, state)
  173. if button == "left" and state == "up" then
  174. local element = getElementData(getLocalPlayer(),"clickedButton")
  175. if element then
  176. local info = getElementData(element,"info")
  177. if info and info == "login" then
  178. local username = guiGetText(Login_Edit[1])
  179. local password = guiGetText(Login_Edit[2])
  180. if not (tostring(username) == "") and not (tostring(password) == "") then
  181. triggerServerEvent("onClientSendLoginDataToServer", getLocalPlayer(), username, password)
  182. else
  183. outputChatBox("Kein Benutzername und Passwort gewählt",255,255,255,true)
  184. end
  185. elseif info and info == "guest" then
  186. showLoginWindow(false)
  187. elseif info and info == "register" then
  188. local username = guiGetText(Login_Edit[3])
  189. local pass1 = guiGetText(Login_Edit[4])
  190. if not (tostring(username) == "") then
  191. if not (tostring(pass1) == "") then
  192. triggerServerEvent("onClientSendRegisterDataToServer", getLocalPlayer(), username, pass1)
  193. else
  194. reason = "Kein Passwort eingegeben!"
  195. outputChatBox("[Login]#FF9900"..reason,255,255,255,true)
  196. end
  197. else
  198. reason = "Kein Benutzername eingegeben!"
  199. outputChatBox("[Login]#FF9900"..reason,255,255,255,true)
  200. end
  201. end
  202. end
  203. end
  204. end
  205. addEventHandler("onClientClick",getRootElement(),clickPanelButton)
  206.  
  207. function onClientGetNews(text1,text2,text3,text4,bool1,bool2,bool3,bool4)
  208. guiSetText(news1,text1)
  209. guiSetText(news2,text2)
  210. guiSetText(news3,text3)
  211. guiSetText(news4,text4)
  212. guiSetVisible(news_box1_new,bool1 == "true" and true or false)
  213. guiSetVisible(news_box2_new,bool2 == "true" and true or false)
  214. guiSetVisible(news_box3_new,bool3 == "true" and true or false)
  215. guiSetVisible(news_box4_new,bool4 == "true" and true or false)
  216. end
  217. addEvent("onClientGetNews",true)
  218. addEventHandler("onClientGetNews",getRootElement(),onClientGetNews)
  219.  
  220. --BUILD WINDOW ON RESOURCE START
  221. addEventHandler("onClientResourceStart", resourceRoot,
  222. function ()
  223. build_loginWin()
  224. guiSetVisible(background_front,false)
  225. showLoginWindow(true)
  226. setPlayerHudComponentVisible ("radar", false )
  227. ped = createPed ( 115, -2239.3713378906,-1746.8660888672,480.82662963867, 485,true )
  228. setPedAnimation( ped, "ped", "XPRESSscratch",-1,true,true,false,false) -- "ped", "XPRESSscratch" -- default "ped", endchat_01
  229. thePed = createPed(116, -2240.9713378906,-1744.7660888672,480.82662963867, 485) --- Creates a ped
  230. setPedAnimation( thePed, "ped", "XPRESSscratch",-1,true,true,false,false) -- "ped", "XPRESSscratch" -- default "ped", endchat_01
  231. setElementRotation(ped1, -20)
  232. guiSetInputMode("no_binds_when_editing")
  233. fadeCamera (true)
  234. setCameraMatrix(-2241.9584960938,-1747.4710693359,481.54472045898, 2659.0986328125, 2728.521484375, 10.774273872375)
  235. end
  236. )
  237.  
  238. --onPlayerDoneLogin
  239. function hideLoginWindow(accountName, pass)
  240. showLoginWindow(false)
  241. guiSetVisible(tab_front1,false)
  242. toggleSavePassword(accountName, pass)
  243. end
  244. addEvent("onPlayerDoneLogin", true)
  245. addEventHandler("onPlayerDoneLogin", getRootElement(), hideLoginWindow)
  246.  
  247. --toggle save password
  248. function toggleSavePassword(name, pass)
  249. confFile = xmlLoadFile("preferencesL.xml")
  250. xmlNodeSetAttribute(confFile, "username", name)
  251. xmlNodeSetAttribute(confFile, "pass", pass)
  252. xmlSaveFile(confFile)
  253. end
  254.  
  255. function showLoginWindow(bool)
  256. setElementData(getLocalPlayer(),"clickedButton",false)
  257. showCursor(bool)
  258. if bool then
  259. guiSetPosition(background_front,0.2, -0.75,true)
  260. addEventHandler("onClientRender",getRootElement(),rollLoginPanel)
  261. position = -0.75
  262. rollIn = true
  263. guiSetInputMode("no_binds_when_editing")
  264. else
  265. guiSetPosition(background_front,0.2, 0.25,true)
  266. addEventHandler("onClientRender",getRootElement(),rollLoginPanel)
  267. position = 0.25
  268. rollIn = false
  269. guiSetInputMode("allow_binds")
  270. end
  271. end
  272.  
  273. rollIn = true
  274. rollPosition = 0.0225
  275. function rollLoginPanel ()
  276. if rollIn then
  277. local x,y = guiGetPosition(background_front,true)
  278. if y > 0.25 then
  279. removeEventHandler("onClientRender",getRootElement(),rollLoginPanel)
  280. return
  281. end
  282. guiSetPosition(background_front,0.2,position+rollPosition,true)
  283. guiSetVisible(background_front,true)
  284. position = position+rollPosition
  285. else
  286. local x,y = guiGetPosition(background_front,true)
  287. if y <= -0.75 then
  288. removeEventHandler("onClientRender",getRootElement(),rollLoginPanel)
  289. return
  290. end
  291. guiSetPosition(background_front,0.2,position-rollPosition,true)
  292. guiSetVisible(background_front,true)
  293. position = position-rollPosition
  294. end
  295. end
  296. addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource()), function()
  297. setTimer(function()
  298. playSound("winsound.mp3")
  299. end, 2000, 1)
  300. end
  301. )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement