Advertisement
Guest User

Untitled

a guest
Oct 5th, 2017
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 20.29 KB | None | 0 0
  1. local screenWidth, screenHeight = guiGetScreenSize()
  2. function callClientFunction_s(funcname, ...)
  3.     local arg = { ... }
  4.     if (arg[1]) then
  5.         for key, value in next, arg do arg[key] = tonumber(value) or value end
  6.     end
  7.     loadstring("return "..funcname)()(unpack(arg))
  8. end
  9. addEvent("onServerCallsClientFunction_s", true)
  10. addEventHandler("onServerCallsClientFunction_s", root, callClientFunction_s)
  11. local language = 1
  12. local Hud_Data = {acc = "",kills = "",deaths = "",pos = "",ratio = ""}
  13. local colors_t = {black2=tocolor( 69 ,69 ,69),gold=tocolor(238,180,34,255),gray=tocolor(200,200,200,255),green=tocolor(100,180,34,255),green2=tocolor(100,200,34,255),black=tocolor(0,0,0,255),gray2=tocolor( 25 ,24 ,24),red=tocolor( 225 ,25 ,25),blue=tocolor( 5 ,50 ,225)}
  14. function math.format(number)
  15. return tonumber(string.format("%.4f", number))
  16. end
  17.  
  18. function math.round(number, decimals, method)
  19.     decimals = decimals or 0
  20.     local factor = 10 ^ decimals
  21.     if (method == "ceil" or method == "floor") then return math[method](number * factor) / factor
  22.     else return tonumber(("%."..decimals.."f"):format(number)) end
  23. end
  24.  
  25. function getScreenPositionByRelative(x,y)
  26.     local nX,nY =x*screenWidth,y*screenHeight
  27.     return math.format(nX),math.format(nY)
  28. end
  29. function yhy2(h,s)
  30. local mn = s/h
  31. return tonumber(string.format("%.1f", screenHeight*mn))
  32. end
  33. function UpdateHudData(type_d,val)
  34.     if type_d == "t" then
  35.         for k,v in pairs(val) do
  36.             if k == "ratio" then
  37.             Hud_Data[k] = tostring(math.round(v ,2))
  38.             else
  39.             Hud_Data[k] = tostring(v)
  40.             end
  41.         end
  42.     else
  43.         if type_d == "ratio" then
  44.         Hud_Data[type_d] = tostring(math.round(val ,2))
  45.         else
  46.         Hud_Data[type_d] = tostring(val)
  47.         end
  48.     end
  49. end
  50.  
  51. function callServerFunction_s(funcname, ...)
  52.     local arg = { ... }
  53.     if (arg[1]) then
  54.         for key, value in next, arg do
  55.             if (type(value) == "number") then arg[key] = tostring(value) end
  56.         end
  57.     end
  58.     triggerServerEvent("onClientCallsServerFunction_s", root, funcname, unpack(arg))
  59. end
  60. function getSizeFromResolution2(x)
  61. local s1,s2 = 0,0
  62.     if x > 1279 then
  63.     s1 = 1.4 s2 = 1.0
  64.     elseif x > 1023 then
  65.     s1 = 1.2 s2 = 1.0
  66.     elseif x > 799 then
  67.     s1 = 1.0 s2 = 1.0
  68.     else
  69.     s1 = 0.85 s2 = 1.0
  70.     end
  71.     return s1,s2
  72. end
  73.  
  74.  
  75.  
  76.  
  77.  
  78.    
  79.   local window_login   
  80.   local edit
  81.   local edit1
  82.   local obrazek
  83.  
  84.   function outputEditBox ( )
  85.     if source == edit or source == edit1 then
  86.        toggleControl ( "chatbox", false )
  87.       else
  88.  toggleControl ( "chatbox",true )    
  89.     end
  90. end
  91. addEventHandler( "onClientResourceStart", getRootElement( ),
  92.     function (res  )
  93.     if res == getThisResource() then
  94.         --LoginMenu_hs()
  95.         chooseLang()
  96.      end
  97.     end
  98. )
  99.  
  100. function LoginMenu_hs()
  101. if window_login == nil then
  102. local x_,y_ = guiGetScreenSize()
  103.     fadeCamera(false)
  104.     addEventHandler("onClientRender", getRootElement(), draw_loginf)
  105.             local as_x= x_/3.53103448
  106.     local as_y= y_/25.6
  107.         guiCreateStaticImage ( (x_-as_x)/2, 0, as_x, as_y, "mini.png",  false )
  108.        edit = guiCreateEdit ( 0.41, 0.495, 0.12, 0.035, "",  true)
  109.        guiSetAlpha(edit,0.8)
  110.         guiSetFont ( edit, "default-bold-small" )
  111.        edit1 = guiCreateEdit (  0.41, 0.55, 0.12, 0.035, "",  true )
  112.        guiSetAlpha(edit1,0.8)
  113.         guiSetFont ( edit1, "default-bold-small" ) 
  114.         guiEditSetMaxLength ( edit,16 )
  115.         guiEditSetMaxLength ( edit1,16 )
  116. button = guiCreateButton ( 0.3, 0.625, 0.15, 0.04, "Login",  true )
  117.         addEventHandler ( "onClientGUIClick", button, Login )
  118. button2 = guiCreateButton ( 0.5 ,0.625, 0.15, 0.04, "Register",  true  )
  119.         addEventHandler ( "onClientGUIClick", button2,Register )
  120.        
  121.         showChat(true)
  122.         showCursor(true)
  123.         addEventHandler ( "onClientGUIClick", getRootElement(), outputEditBox )
  124. end
  125. end
  126.    
  127.     local texts_t = {
  128.     info= {
  129.     [1]="Regulamin:",
  130.     [2]="Rules"},
  131.     rule = {
  132.     [1]="1. Wykazujemy sie kultura osobist¹ i szanujemy innych graczy. \n2. Dzia³anie zgodnie z zasadami serwera, oraz regulaminem. \n3. Team Say (Nie piszemy na ogólnym czacie niepotrzebnych rzeczy) \n4. Czysta gra. \n5. Nie mo¿na wychodzic po za teren areny. \n6. Wykonywanie poleceñ admina \n7. W ka¿dym przypadku nie przestrzegania regulaminu gracz zostaje\n   ukarany kick'iem\ban'em.",
  133.     [2]="1. Be fully cultural towards other players, respect their. \n2. Follow the rules of the server. \n3. Use Team Say (do not write unnecessary things at global chat) \n4. Do not use any cheats, only clean playing. \n5. Do not try to run away from the arena's area. \n6. Follow the admin's orders. \n7. Everyone, who won't follow the rules, will be kicked or banned."},
  134.     has = {
  135.     [1]="Haslo:",
  136.     [2]="Password:"},
  137.     aut = {
  138.     [1]="Podany login, bedzie automatycznie ustawiany jako nick gracza.",
  139.     [2]="The given login name will be set as your player nickname automatically."}
  140.     }
  141.     local draw_login = {
  142.     box={getScreenPositionByRelative(0.25,0.15)},
  143.     boxsize={getScreenPositionByRelative(0.5,0.55)},
  144.     boxcolor = tocolor(255,255,255,25),
  145.     info={getScreenPositionByRelative(0.35,0.155)},
  146.     rule={getScreenPositionByRelative(0.265,0.22)},
  147.     login={getScreenPositionByRelative(0.345,0.50)},
  148.     register={getScreenPositionByRelative(0.345,0.555)},
  149.     att={getScreenPositionByRelative(0.275,0.45)},
  150.     size1=yhy2(768,1.2),
  151.     size2=yhy2(640,1.0),
  152.     }
  153. function draw_loginf()
  154.     dxDrawRectangle ( draw_login.box[1],draw_login.box[2],draw_login.boxsize[1],draw_login.boxsize[2] ,draw_login.boxcolor )
  155.     --dxDrawImage ( draw_login.box[1],draw_login.box[2],draw_login.boxsize[1],draw_login.boxsize[2], "s.png" ,0, 0, 0, draw_login.boxcolor )
  156.     dxDrawText (texts_t.info[language], draw_login.info[1],draw_login.info[2] , 0, 0,colors_t.gold,draw_login.size1 , "bankgothic")
  157.     dxDrawText (texts_t.rule[language], draw_login.rule[1],draw_login.rule[2] , 0, 0,colors_t.gray,draw_login.size2 , "default")
  158.     dxDrawText ("    Nick:", draw_login.login[1],draw_login.login[2] , 0, 0,colors_t.gold,draw_login.size1 , "default-bold")
  159.     dxDrawText (texts_t.has[language], draw_login.register[1],draw_login.register[2] , 0, 0,colors_t.gold,draw_login.size1 , "default-bold")
  160.     dxDrawText (texts_t.aut[language], draw_login.att[1],draw_login.att[2] , 0, 0,colors_t.red,draw_login.size1 , "default-bold")
  161. end
  162.  
  163.     function Login()
  164.     local username = guiGetText ( edit )
  165.     local password = guiGetText ( edit1 )
  166.         if(password ~= "" and username ~= "" ) then
  167.             callServerFunction_s("LoginOnAccount",getLocalPlayer(),username,password)
  168.         end
  169.  
  170.     end
  171.     function Register()
  172.     local username = guiGetText ( edit )
  173.     local password = guiGetText ( edit1 )
  174.     if type(tonumber(password)) == "number" then
  175.         local txt = {
  176.     [1]="#FF0000** Blad:#0AC419 Haslo musi zawierac chociaz jednen znak inny niz cyfra.",
  177.     [2]="#FF0000** Error:#0AC419 Your login must contain at least one letter besides numbers."}
  178.     outputChatBox ( txt[language], 255, 255, 255, true )
  179.     elseif string.len(username) < 4 then
  180.     local txt = {
  181.     [1]="#FF0000** Blad:#0AC419 Login musi sk³adac sie z minimum 4 znakow.",
  182.     [2]="#FF0000** Error:#0AC419 Username must consist of a minimum of 4 characters."}
  183.     outputChatBox ( txt[language], 255, 255, 255, true )
  184.     elseif string.len(password) < 5 then
  185.     local txt = {
  186.     [1]="#FF0000** Blad:#0AC419 Haslo musi sk³adac sie z minimum 5 znakow.",
  187.     [2]="#FF0000** Error:#0AC419 Password must consist of a minimum of 5 characters."}
  188.     outputChatBox ( txt[language], 255, 255, 255, true )
  189.     elseif type(tonumber(username)) == "number" then
  190.     local txt = {
  191.     [1]="#FF0000** Blad:#0AC419 Login musi zawierac chociaz jednen znak inny niz cyfra.",
  192.     [2]="#FF0000** Error:#0AC419 Your login must contain at least one letter besides numbers."}
  193.     outputChatBox ( txt[language], 255, 255, 255, true )
  194.     elseif string.find(username,"\"") then
  195.     local txt = {
  196.     [1]="#FF0000** Blad:#0AC419 Nie moza uzywac znaku \".",
  197.     [2]="#FF0000** Error:#0AC419 This character is not allowed to use - \"."}
  198.     outputChatBox ( txt[language], 255, 255, 255, true )
  199.     else
  200.    
  201.         if(password ~= "" and username ~= "" ) then
  202.             callServerFunction_s("CreateNewAccount",getLocalPlayer(),username,password)
  203.         end
  204.    
  205.     end
  206.     end
  207.    
  208.     function destroyLogWin()
  209.     addEventHandler("onClientRender", getRootElement(), s_onClientPreRender_Hud)
  210.     removeEventHandler ( "onClientGUIClick", getRootElement(), outputEditBox )
  211.     removeEventHandler("onClientRender", getRootElement(), draw_loginf)
  212.      toggleControl ( "chatbox",true )    
  213.     showCursor(false)
  214.     destroyElement(edit )
  215.     destroyElement(edit1    )
  216.     destroyElement(button)
  217.     destroyElement(button2)
  218.     fadeCamera(true)
  219.     --setTimer(triggerEvent,200,1,"introEvent",getLocalPlayer())
  220.      texts_t= nil
  221.     end
  222.    
  223.  
  224.  
  225. local help_win
  226. function Help()
  227. if help_win == nil then
  228. help_win = guiCreateWindow ( 0.25, 0.2, 0.5, 0.45, "Help", true )
  229.  local l = guiCreateLabel ( 0.15, 0.15, 1, 1, "                          ** Commands: \n\n/top10 - list of top10 players\n/stats - to check your own statistics \n/stats loginID - to check other players stats\n\n                          ** Other Commands:\n\n /vote [arena/base] [ID]  \nnp: /vote arena 20 \nlub /vote arena 20 26 34 56 ", true, help_win   )
  230.     guiSetFont ( l, "default-bold-small" )
  231.  
  232. local Button = guiCreateButton ( 0.05, 0.9, 0.9, 0.05, "ok", true, help_win )
  233. addEventHandler ( "onClientGUIClick", Button, OkButton2 )
  234. showCursor(true)
  235. end
  236. end
  237. addCommandHandler("help",Help)
  238.  
  239. function OkButton2 ()
  240. removeEventHandler ( "onClientGUIClick", source, OkButton2 )
  241. destroyElement(help_win)
  242. help_win = nil
  243. showCursor(false)
  244. end
  245.  
  246.  
  247.  
  248.  
  249. local top_win
  250. function DrawTop15(t)
  251. if top_win == nil then
  252. local c = {
  253. [1]={109,109,109},
  254. [2]={69,69,69 },
  255. c = 1}
  256. top_win = guiCreateStaticImage ((screenWidth-400)/2, (screenHeight-500)/2,400, 500, "top10.png", false)
  257. r = guiCreateLabel ( 0.10, 0.110, 1, 1,"Pos", true, top_win )
  258. guiSetFont ( r, "default-bold-small" )
  259. guiLabelSetColor ( r,c[c.c][1],c[c.c][2],c[c.c][3] )
  260. r = guiCreateLabel ( 0.23, 0.110, 1, 1,"Name", true, top_win )
  261. guiSetFont ( r, "default-bold-small" )
  262. guiLabelSetColor ( r,c[c.c][1],c[c.c][2],c[c.c][3] )
  263. r = guiCreateLabel ( 0.45, 0.110, 1, 1,"Kills", true, top_win )
  264. guiSetFont ( r, "default-bold-small" )
  265. guiLabelSetColor ( r,c[c.c][1],c[c.c][2],c[c.c][3] )
  266. r = guiCreateLabel ( 0.6, 0.110, 1, 1,"Deaths", true, top_win )
  267. guiSetFont ( r, "default-bold-small" )
  268. guiLabelSetColor ( r,c[c.c][1],c[c.c][2],c[c.c][3] )
  269. r = guiCreateLabel ( 0.775, 0.110, 1, 1,"Ratio", true, top_win )
  270. guiSetFont ( r, "default-bold-small" )
  271. guiLabelSetColor ( r,c[c.c][1],c[c.c][2],c[c.c][3] )
  272. local yP = 0.18
  273. for k,v in ipairs(t) do
  274. c.c = c.c + 1
  275. if c.c > 2 then
  276. c.c = 1
  277. end
  278. r = guiCreateLabel ( 0.1, yP, 1, 1,tostring(k)..".", true, top_win )
  279. guiSetFont ( r, "default-bold-small" )
  280. guiLabelSetColor ( r,c[c.c][1],c[c.c][2],c[c.c][3] )
  281. r = guiCreateLabel ( 0.23, yP, 1, 1,tostring(t[k].acc), true, top_win )
  282. guiSetFont ( r, "default-bold-small" )
  283. guiLabelSetColor ( r,c[c.c][1],c[c.c][2],c[c.c][3] )
  284. r = guiCreateLabel ( 0.45, yP, 1, 1,tostring(t[k].kills), true, top_win )
  285. guiSetFont ( r, "default-bold-small" )
  286. guiLabelSetColor ( r,c[c.c][1],c[c.c][2],c[c.c][3] )
  287. r = guiCreateLabel ( 0.6, yP, 1, 1,tostring(t[k].deaths), true, top_win )
  288. guiSetFont ( r, "default-bold-small" )
  289. guiLabelSetColor ( r,c[c.c][1],c[c.c][2],c[c.c][3] )
  290. r = guiCreateLabel ( 0.775, yP, 1, 1,tostring(math.round(t[k].ratio ,2)), true, top_win )
  291. guiSetFont ( r, "default-bold-small" )
  292. guiLabelSetColor ( r,c[c.c][1],c[c.c][2],c[c.c][3] )
  293. yP = yP + 0.07
  294. end
  295. local Button = guiCreateButton ( 0.05, 0.9, 0.9, 0.05, "", true, top_win )
  296. r = guiCreateLabel ( 0.45, 0.25, 1, 1,"CLOSE!", true, Button )
  297. guiSetFont ( r, "default-bold-small" )
  298. guiSetAlpha(Button,0.5)
  299. guiLabelSetColor (r,255,255,255)
  300. addEventHandler ( "onClientGUIClick", Button, OkButton )
  301. showCursor(true)
  302. end
  303. end
  304.  
  305.  
  306. function OkButton ()
  307. removeEventHandler ( "onClientGUIClick", source, OkButton )
  308. destroyElement(top_win)
  309. top_win = nil
  310. showCursor(false)
  311. end
  312.  
  313.     local She_L = {
  314.     box={getScreenPositionByRelative(0.78,0.185)},
  315.     boxsize={getScreenPositionByRelative(0.17,0.135)},
  316.     boxcolor=tocolor(0,0,0,130),
  317.     info={getScreenPositionByRelative(0.8,0.195)},
  318.     kills={getScreenPositionByRelative(0.795,0.235)},
  319.     kills2={getScreenPositionByRelative(0.83,0.235)},
  320.     deaths={getScreenPositionByRelative(0.865,0.235)},
  321.     deaths2={getScreenPositionByRelative(0.915,0.235)},
  322.     ratio={getScreenPositionByRelative(0.795,0.27)},
  323.     ratio2={getScreenPositionByRelative(0.835,0.27)},
  324.     pos={getScreenPositionByRelative(0.875,0.27)},
  325.     pos2={getScreenPositionByRelative(0.915,0.27)},
  326.     size1=yhy2(768,1.2),
  327.     size2=yhy2(768,0.8),
  328.     }
  329.  
  330.     function s_onClientPreRender_Hud()
  331.      dxDrawImage ( She_L.box[1],She_L.box[2],She_L.boxsize[1],She_L.boxsize[2], "s.png" ,0, 0, 0, She_L.boxcolor )
  332.      
  333.      dxDrawText ("Ranking:", She_L.info[1],She_L.info[2] , 0, 0,colors_t.green,She_L.size2 , "bankgothic")
  334.      
  335.       dxDrawText ("Kills: ", She_L.kills[1],She_L.kills[2] , 0, 0,colors_t.gold,She_L.size1 , "default-bold")
  336.       dxDrawText (Hud_Data.kills, She_L.kills2[1],She_L.kills2[2] , 0, 0,colors_t.gray,She_L.size1 , "default-bold")
  337.      
  338.       dxDrawText ("Deaths: ", She_L.deaths[1],She_L.deaths[2] , 0, 0,colors_t.gold,She_L.size1 , "default-bold")
  339.       dxDrawText (Hud_Data.deaths, She_L.deaths2[1],She_L.deaths2[2] , 0, 0,colors_t.gray,She_L.size1 , "default-bold")
  340.      
  341.       dxDrawText ("Ratio: ", She_L.ratio[1],She_L.ratio[2] , 0, 0,colors_t.gold,She_L.size1 , "default-bold")
  342.       dxDrawText (Hud_Data.ratio, She_L.ratio2[1],She_L.ratio2[2] , 0, 0,colors_t.gray,She_L.size1 , "default-bold")
  343.      
  344.       dxDrawText ("Rank: ", She_L.pos[1],She_L.pos[2] , 0, 0,colors_t.gold,She_L.size1 , "default-bold")
  345.       dxDrawText (Hud_Data.pos, She_L.pos2[1],She_L.pos2[2] , 0, 0,colors_t.gray,She_L.size1 , "default-bold")
  346.  
  347.     end
  348.  
  349.     local lang = {
  350.     info={getScreenPositionByRelative(0.3,0.3)},
  351.     plf={getScreenPositionByRelative(0.22,0.61)},
  352.     engf={getScreenPositionByRelative(0.635,0.61)},
  353.     size1=yhy2(768,1.2),
  354.     }
  355. function chooseLang()
  356. lang.pl = guiCreateStaticImage ( 0.16, 0.43, 0.25, 0.16, "pl.png",  true )
  357. lang.eng = guiCreateStaticImage ( 0.57, 0.43, 0.25, 0.16, "eng.png",  true )
  358. addEventHandler("onClientRender", getRootElement(), bm_onClientPreRender_Login1)
  359. addEventHandler ( "onClientGUIClick", lang.pl, onClickFlag, false )
  360. addEventHandler ( "onClientGUIClick", lang.eng, onClickFlag, false )
  361. showCursor(true)
  362. end
  363.  
  364.     function bm_onClientPreRender_Login1()
  365.      dxDrawText ("Select Your Language: \n      (click on flag)", lang.info[1],lang.info[2] , 0, 0,colors_t.gold,lang.size1 , "bankgothic")
  366.      dxDrawText ("Polski", lang.plf[1],lang.plf[2] , 0, 0,colors_t.red,lang.size1 , "bankgothic")
  367.      dxDrawText ("English", lang.engf[1],lang.engf[2] , 0, 0,colors_t.blue,lang.size1 , "bankgothic")
  368.      end
  369.      
  370.     function onClickFlag()
  371.         if source == lang.pl then
  372.             removeEventHandler("onClientRender", getRootElement(), bm_onClientPreRender_Login1)
  373.             removeEventHandler ( "onClientGUIClick", lang.pl, onClickFlag, false )
  374.             removeEventHandler ( "onClientGUIClick", lang.eng, onClickFlag, false )
  375.             destroyElement(lang.pl)
  376.             destroyElement(lang.eng)
  377.             lang = {}
  378.             language = 1
  379.             callServerFunction_s("lang_upd",getLocalPlayer(),language)
  380.             LoginMenu_hs()
  381.         else
  382.             removeEventHandler("onClientRender", getRootElement(), bm_onClientPreRender_Login1)
  383.             removeEventHandler ( "onClientGUIClick", lang.pl, onClickFlag, false )
  384.             removeEventHandler ( "onClientGUIClick", lang.eng, onClickFlag, false )
  385.             destroyElement(lang.pl)
  386.             destroyElement(lang.eng)
  387.             lang = {}
  388.             language = 2
  389.             callServerFunction_s("lang_upd",getLocalPlayer(),language)
  390.             LoginMenu_hs()
  391.         end
  392.     end
  393.    
  394.     local konto = {}
  395.     function konto_f(data)
  396.         showCursor(true)
  397.         konto.window = guiCreateWindow(0.35,0.35,0.3,0.3,"Your account Panel.",true)
  398.         local tt = {{"Nazwa","Name"},{"Zabojstwa","Kills"},{"Smierci","Deaths"},{
  399.         "Ratio","Ratio"},{"Pozycja","Ranking"},{"Zadane obrazania","Damages"}}
  400.         local yP = 0.1
  401.             for i=1,6 do
  402.                 local r = guiCreateLabel ( 0.1, yP, 1, 1,tt[i][language]..":", true, konto.window )
  403.                 guiSetFont ( r, "default-bold-small" )
  404.                 guiLabelSetColor ( r,125,125,125 )
  405.                 r = guiCreateLabel ( 0.4, yP, 1, 1,tostring(data[i]), true, konto.window )
  406.                 guiSetFont ( r, "default-bold-small" )
  407.                 guiLabelSetColor ( r,225,225,225 )
  408.                 yP = yP + 0.07
  409.             end
  410.         local txt = {"Zmien Nick","Change Nick"}
  411.         konto.nick = guiCreateButton ( 0.05, 0.56, 0.9, 0.07, txt[language], true, konto.window )
  412.         addEventHandler ( "onClientGUIClick", konto.nick, konto_f_onClientGUIClick )
  413.         local txt = {"Zmien Haslo","Change Password"}
  414.         konto.haslo = guiCreateButton ( 0.05, 0.7, 0.9, 0.07, txt[language], true, konto.window )
  415.         addEventHandler ( "onClientGUIClick", konto.haslo, konto_f_onClientGUIClick )
  416.         local txt = {"Zamknij","Close"}
  417.         konto.close = guiCreateButton ( 0.05, 0.84, 0.9, 0.07, txt[language], true, konto.window )
  418.         addEventHandler ( "onClientGUIClick", konto.close, konto_f_onClientGUIClick )
  419.     end
  420.     --addCommandHandler("konto",konto_f)
  421.  
  422.     function konto_f_onClientGUIClick()
  423.         if source == konto.close then
  424.             removeEventHandler ( "onClientGUIClick", konto.nick, konto_f_onClientGUIClick )
  425.             removeEventHandler ( "onClientGUIClick", konto.haslo, konto_f_onClientGUIClick )
  426.             removeEventHandler ( "onClientGUIClick", konto.close, konto_f_onClientGUIClick )
  427.             destroyElement(konto.window)
  428.             konto = {}
  429.             showCursor(false)
  430.         elseif source == konto.change_button_close then
  431.             removeEventHandler ( "onClientGUIClick", konto.change_button)
  432.             removeEventHandler ( "onClientGUIClick",  konto.change_button_close )
  433.             destroyElement(konto.change)
  434.             guiSetVisible(konto.window,true)
  435.         elseif source == konto.change_button then  
  436.             if konto.type == "pass" then
  437.                 local password = guiGetText ( konto.change_edit )
  438.                 if type(tonumber(password)) == "number" then
  439.                     local txt = {
  440.                     [1]="#FF0000** Blad:#0AC419 Haslo musi zawierac chociaz jednen znak inny niz cyfra.",
  441.                     [2]="#FF0000** Error:#0AC419 Your login must contain at least one letter besides numbers."}
  442.                     outputChatBox ( txt[language], 255, 255, 255, true )
  443.                 elseif string.len(password) < 5 then
  444.                     local txt = {
  445.                     [1]="#FF0000** Blad:#0AC419 Haslo musi sk³adac sie z minimum 5 znakow.",
  446.                     [2]="#FF0000** Error:#0AC419 Password must consist of a minimum of 5 characters."}
  447.                     outputChatBox ( txt[language], 255, 255, 255, true )
  448.                 else
  449.                 callServerFunction_s("doThinkWithAccount",getLocalPlayer(),"pass",password)
  450.                 guiSetEnabled(source,false)
  451.                 end
  452.             elseif konto.type == "name" then
  453.                     local username = guiGetText ( konto.change_edit )
  454.                     if string.len(username) < 4 then
  455.                         local txt = {
  456.                         [1]="#FF0000** Blad:#0AC419 Login musi sk³adac sie z minimum 4 znakow.",
  457.                         [2]="#FF0000** Error:#0AC419 Username must consist of a minimum of 4 characters."}
  458.                     outputChatBox ( txt[language], 255, 255, 255, true )
  459.                     elseif type(tonumber(username)) == "number" then
  460.                         local txt = {
  461.                         [1]="#FF0000** Blad:#0AC419 Login musi zawierac chociaz jednen znak inny niz cyfra.",
  462.                         [2]="#FF0000** Error:#0AC419 Your login must contain at least one letter besides numbers."}
  463.                         outputChatBox ( txt[language], 255, 255, 255, true )
  464.                     elseif string.find(username,"\"") then
  465.                         local txt = {
  466.                         [1]="#FF0000** Blad:#0AC419 Nie moza uzywac znaku \".",
  467.                         [2]="#FF0000** Error:#0AC419 This character is not allowed to use - \"."}
  468.                         outputChatBox ( txt[language], 255, 255, 255, true )
  469.                     else
  470.                     callServerFunction_s("doThinkWithAccount",getLocalPlayer(),"name",username)
  471.                     guiSetEnabled(source,false)
  472.                     end
  473.             end
  474.         elseif source == konto.haslo then
  475.         createChangeWindow({"Zmien Haslo","Change your password:"},"pass")
  476.         elseif source == konto.nick then
  477.         createChangeWindow({"Zmien nikc","Change your nickname:"},"name")
  478.         end
  479.     end
  480.    
  481.     function createChangeWindow(title,type)
  482.     guiSetVisible(konto.window,false)
  483.     konto.type = type
  484.     konto.change = guiCreateWindow(0.35,0.35,0.3,0.15,title[language],true)
  485.     konto.change_edit = guiCreateEdit (  0.05, 0.25, 0.9, 0.175, "",  true,konto.change )
  486.     local txt = {"Zmnien.","Change."}
  487.     konto.change_button = guiCreateButton ( 0.05, 0.5, 0.9, 0.15, txt[language], true, konto.change )
  488.     addEventHandler ( "onClientGUIClick", konto.change_button, konto_f_onClientGUIClick )
  489.     local txt = {"Zamknij","Close"}
  490.     konto.change_button_close = guiCreateButton ( 0.05, 0.75, 0.9, 0.15, txt[language], true, konto.change )
  491.     addEventHandler ( "onClientGUIClick", konto.change_button_close, konto_f_onClientGUIClick )
  492.    
  493.     end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement