Bostjan96 Posted October 23, 2011 Share Posted October 23, 2011 I need help with two scripts. I do not know what is wrong! The first script is login_panel loginpanel_client : ---------------------------------- -----------| Settings |----------- ---------------------------------- blackLoginScreen = true -- Set to 'true' to display a black screen to the player untill they log in or choose to play as a guest. enableKickPlayer = true -- Set whether to kick the player after they fail to login specified amount of times. disallowLogout = false -- Set whether to show the userpanel to the players if they log out of their accounts. removeBlackScreenTime = 4 -- The time it takes for the black screen to dissapear - If you choose to display the black screen. [iN SECONDS] maxLoginAttempts = 32 -- Set the maximum incorrect login attempts before the player gets kicked - If player kicking is enabled. ---------------------------------- -- Set the text you want displayed in the "rules" window here - use '\n' to go into the next line infoText = "------ Rules ------ \n\n*text\n*text\n*text\n\n*text\n\n\n\n\n\n\n\nLogin panel by Bostjan96" -- Screen and GUI window sizes screenWidth,screenHeight = guiGetScreenSize() mainWidth,mainHeight = 749,472 regWidth,regHeight = 439,344 -- Generate the XML file name function getServerName() triggerServerEvent("onClientLoginLoaded",getLocalPlayer()) end addEventHandler("onClientResourceStart",getResourceRootElement(getThisResource()),getServerName) function setXmlFileName(sName) xmlFileName = tostring("login_"..sName..".xml") loginPanel() end addEvent("onGetServerData",true) addEventHandler("onGetServerData",getRootElement(),setXmlFileName) ---------------------------------- addEvent("onRequestIncreaseAttempts",true) addEvent("onRequestDisplayPanel",true) function loginPanel() -- Check if autologin is enabled - If yes, then log the player in, else create and show the userpanel local xmlFile = xmlLoadFile(xmlFileName) if xmlFile then status = xmlNodeGetAttribute(xmlFile,"autologin") if (status == "true") then local username = tostring(xmlNodeGetAttribute(xmlFile,"username")) local password = tostring(xmlNodeGetAttribute(xmlFile,"password")) if not (username == "") and not (password == "") then triggerServerEvent("onRequestAutologin",getLocalPlayer(),username,password) end else if blackLoginScreen == true then fadeCamera(false,0,0,0,0) end mainWindow = guiCreateWindow(screenWidth/2-mainWidth/2,screenHeight/2-mainHeight/2,mainWidth,mainHeight,"Login panel",false) guiWindowSetSizable(mainWindow,false) mInfo = guiCreateMemo(21,36,411,278,infoText,false,mainWindow) guiMemoSetReadOnly(mInfo,true) editUsername = guiCreateEdit(53,364,187,25,"",false,mainWindow) guiEditSetMaxLength(editUsername,30) editPassword = guiCreateEdit(53,421,187,25,"",false,mainWindow) guiEditSetMaxLength(editPassword,30) guiEditSetMasked(editPassword,true) lblUsername = guiCreateLabel(67,330,158,38,"Username:",false,mainWindow) guiLabelSetColor(lblUsername,0,85,255) guiLabelSetVerticalAlign(lblUsername,"center") guiLabelSetHorizontalAlign(lblUsername,"center",false) guiSetFont(lblUsername,"default-bold-small") lblPassword = guiCreateLabel(67,389,158,38,"Password:",false,mainWindow) guiLabelSetColor(lblPassword,0,85,255) guiLabelSetVerticalAlign(lblPassword,"center") guiLabelSetHorizontalAlign(lblPassword,"center",false) guiSetFont(lblPassword,"default-bold-small") btnPlayAsGuest = guiCreateButton(548,368,168,74,"Play as guest",false,mainWindow) guiSetFont(btnPlayAsGuest,"default-bold-small") btnLogin = guiCreateButton(280,368,242,74,"Login",false,mainWindow) guiSetFont(btnLogin,"sa-header") btnToggleRegister = guiCreateButton(490,246,206,68,"Register an account",false,mainWindow) guiSetFont(btnToggleRegister,"default-bold-small") registerWindow = guiCreateWindow(screenWidth/2-regWidth/2,screenHeight/2-regHeight/2,regWidth,regHeight,"Registration",false) guiWindowSetSizable(registerWindow,false) editRegistrationUsername = guiCreateEdit(98,138,242,25,"",false,registerWindow) editRegistrationPassword = guiCreateEdit(98,195,242,25,"",false,registerWindow) guiEditSetMasked(editRegistrationPassword,true) editRegistrationRepeatPassword = guiCreateEdit(99,252,242,25,"",false,registerWindow) guiEditSetMasked(editRegistrationRepeatPassword,true) lblRegister = guiCreateLabel(24,24,391,97,"Register",false,registerWindow) guiLabelSetColor(lblRegister,0,85,255) guiLabelSetVerticalAlign(lblRegister,"center") guiLabelSetHorizontalAlign(lblRegister,"center",false) guiSetFont(lblRegister,"sa-gothic") lblRUsername = guiCreateLabel(98,113,242,17,"Username:",false,registerWindow) guiLabelSetColor(lblRUsername,0,85,255) guiLabelSetVerticalAlign(lblRUsername,"center") guiLabelSetHorizontalAlign(lblRUsername,"center",false) guiSetFont(lblRUsername,"default-bold-small") lblRPassword = guiCreateLabel(98,171,242,17,"Password:",false,registerWindow) guiLabelSetColor(lblRPassword,0,85,255) guiLabelSetVerticalAlign(lblRPassword,"center") guiLabelSetHorizontalAlign(lblRPassword,"center",false) guiSetFont(lblRPassword,"default-bold-small") lblRepeatPassword = guiCreateLabel(98,230,242,17,"Repeat password:",false,registerWindow) guiLabelSetColor(lblRepeatPassword,0,85,255) guiLabelSetVerticalAlign(lblRepeatPassword,"center") guiLabelSetHorizontalAlign(lblRepeatPassword,"center",false) guiSetFont(lblRepeatPassword,"default-bold-small") btnCancel = guiCreateButton(232,292,179,38,"Cancel",false,registerWindow) guiSetFont(btnCancel,"default-bold-small") btnConfirmRegistration = guiCreateButton(29,292,179,38,"Confirm & register!",false,registerWindow) guiSetFont(btnConfirmRegistration,"default-bold-small") guiCreateStaticImage(440,23,300,225,"logo.png",false,mainWindow) guiSetVisible(mainWindow, true) guiSetVisible(registerWindow, false) guiSetInputEnabled(true) showCursor(true) addEventHandler("onClientGUIClick",btnLogin,onClickLogin) addEventHandler("onClientGUIClick",btnToggleRegister,onClickRegisterToggle) addEventHandler("onClientGUIClick",btnPlayAsGuest,onClickGuest) addEventHandler("onClientGUIClick",btnConfirmRegistration,onClickRegisterConfirm) addEventHandler("onClientGUIClick",btnCancel,onClickCancel) addEventHandler("onRequestIncreaseAttempts",getRootElement(),increaseAttempts) attemptedLogins = 0 end xmlUnloadFile(xmlFile) else xmlFileHandler(true) end addEventHandler("onRequestDisplayPanel",getRootElement(),logoutHandler) end --addEventHandler("onClientResourceStart",getResourceRootElement(getThisResource()),loginPanel) -- Disable autologin function removeAutoLogin() local xmlFile = xmlLoadFile(xmlFileName) if xmlFile then local status = xmlNodeGetAttribute(xmlFile,"autologin") if status == "true" then xmlNodeSetAttribute(xmlFile,"autologin","false") outputChatBox("#0000FF* #FFFFFFAuto-login is now #FF0000DISABLED#FFFFFF!",255,255,255,true) xmlSaveFile(xmlFile) xmlUnloadFile(xmlFile) else outputChatBox("#0000FF* #FFFFFFAuto-login is already #FF0000DISABLED#FFFFFF!",255,255,255,true) xmlUnloadFile(xmlFile) end end end addCommandHandler("disableauto", removeAutoLogin) -- Enable autologin function addAutoLogin() local xmlFile = xmlLoadFile(xmlFileName) if xmlFile then local status = xmlNodeGetAttribute(xmlFile,"autologin") if status == "false" then xmlNodeSetAttribute(xmlFile,"autologin","true") outputChatBox("#0000FF* #FFFFFFAuto-login is now #00FF00ENABLED#FFFFFF! You will be automatically logged in every time you join the server.",255,255,255,true) setTimer(outputChatBox,1000,1,"#0000FF* #FFFFFFTo #FF0000DISABLE#FFFFFF auto-login, use #ABCDEF/disableauto#FFFFFF!",255,255,255,true) xmlSaveFile(xmlFile) xmlUnloadFile(xmlFile) else outputChatBox("#0000FF* #FFFFFFAuto-login is already #00FF00ENABLED#FFFFFF!",255,255,255,true) xmlUnloadFile(xmlFile) end end end addCommandHandler("enableauto", addAutoLogin) -- LOGIN PLAYER function onClickLogin(button,state) if(button == "left" and state == "up") then if (source == btnLogin) then username = guiGetText(editUsername) password = guiGetText(editPassword) triggerServerEvent("onRequestLogin",getLocalPlayer(),username,password,enableKickPlayer,attemptedLogins,maxLoginAttempts) xmlFileHandler() end end end -- REGISTER PLAYER function onClickRegisterConfirm(button,state) if(button == "left" and state == "up") then if (source == btnConfirmRegistration) then username = guiGetText(editRegistrationUsername) password = guiGetText(editRegistrationPassword) passwordConfirm = guiGetText(editRegistrationRepeatPassword) triggerServerEvent("onRequestRegister",getLocalPlayer(),username,password,passwordConfirm) end end end -- Open registration window function onClickRegisterToggle(button,state) if(button == "left" and state == "up") then if (source == btnToggleRegister) then guiSetVisible(registerWindow, true) guiBringToFront(registerWindow) guiSetInputEnabled(true) showCursor(true) end end end -- Cancel registration function onClickCancel(button,state) Link to comment
Bostjan96 Posted October 23, 2011 Author Share Posted October 23, 2011 The other one is welcome welcome_client : local screenX,screenY = guiGetScreenSize() local checkbox local button local help = {} help[1] = {"img/ghostmode.png","You can choose wether to enable ghostmode or not. \nPress F2 to disable or enable the ghostmode. \nSome races have forced ghostmode off, a warning will be given when a race like that starts."} help[2] = {"img/f1.png","Press F1 to view stats of yourself & others \nor to change your personal preferences"} help[3] = {"img/models.png","This server has custom models, default gta cars were replaced with new ones. \nThese models have to be downloaded at the start of a new race, don't worry its one time only! \nPress F7 to reload the vehicle if the texture did not load correctly."} addEventHandler("onClientResourceStart",resourceRoot, function (res) fadeCamera(true) local cookie = xmlLoadFile("cookie.xml") if cookie then local child = xmlFindChild(cookie,"build",0) if child then if getElementData(resourceRoot,"build") == xmlNodeGetValue(child) then xmlUnloadFile(cookie) return end end xmlDestroyNode(cookie) end showCursor(true) checkbox = guiCreateCheckBox((screenX/2)+150,(screenY/2)-93+#help*120,120,20,"Don't show again",false,false) button = guiCreateButton((screenX/2)+280,(screenY/2)-90+#help*120,50,20,"Ok",false) addEventHandler("onClientGUIClick",button,continue) addEventHandler("onClientRender",root,drawWin) end ) function continue (btn) if btn ~= "left" then return end if guiCheckBoxGetSelected(checkbox) then local cookie = xmlCreateFile("cookie.xml","cookie") xmlNodeSetValue(xmlCreateChild(cookie,"build"),getElementData(resourceRoot,"build")) xmlSaveFile(cookie) xmlUnloadFile(cookie) end removeEventHandler("onClientRender",root,drawWin) destroyElement(checkbox) destroyElement(button) showCursor(false) end function drawWin () dxDrawImage((screenX/2)-340,(screenY/2)-250,680,170,"img/banner.png") dxDrawRectangle((screenX/2)-340,(screenY/2)-90,680,#help*120+40,tocolor(0,0,0)) for i,h in ipairs (help) do dxDrawImage((screenX/2)-320,(screenY/2)-90+((i-1)*120),120,120,h[1]) for k,line in ipairs (Split(h[2],"\n") or {}) do dxDrawText(line,(screenX/2)-190,(screenY/2)-50+((i-1)*120+((k-1)*20))) end end dxDrawText("Need more help or info? Press F9 or visit teamskc.co.uk",(screenX/2)-320,(screenY/2)-90+#help*120) end function Split (text,sep,plain) local res={} local searchPos=1 while true do local matchStart, matchEnd=string.find(text, sep, searchPos, plain) if matchStart and matchEnd >= matchStart then -- insert string up to separator into result table.insert(res, string.sub(text, searchPos, matchStart-1)) -- continue search after separator searchPos=matchEnd+1 else -- insert whole reminder as result table.insert(res, string.sub(text, searchPos)) break end end return res end meta.xml : "Bostjan96" version="1.0.0" description="Wellcome" /> in "Login_Panel" in my server refuses to open. the "welcome", the same is not open to the server. without Error Link to comment
Charlie_Jefferson Posted October 24, 2011 Share Posted October 24, 2011 What errors do you get? Link to comment
Bostjan96 Posted October 24, 2011 Author Share Posted October 24, 2011 No errors! Only when I run my script it will not open. It should be open the black box with a picture and the Sun just download it and then nothing. As with login as well as welcome. Link to comment
Charlie_Jefferson Posted October 24, 2011 Share Posted October 24, 2011 There's a lot of functions which are mixed. That means you have a lot of client-side and server-side functions in 1 lua. You must organize them into 2 lua. 1 lua should be server wide and the second one is client. The GUI stuff is client-side only. getServerName is server-side only, XML stuff is server-side and client-side too. Try using the wiki to solve it. Link to comment
Castillo Posted October 24, 2011 Share Posted October 24, 2011 "Bostjan96" version="1.0.0" description="Wellcome" /> You had the script as server side. Link to comment
Bostjan96 Posted October 24, 2011 Author Share Posted October 24, 2011 Hmmmmm I do not understand something more only if someone can link business how to find assistance would help a lot! Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now