DefearT Posted September 3, 2012 Share Posted September 3, 2012 Hola, regrese luego de un tiempo; la verdad me quitaron la pc Bueno primero un ejemplo! Quiero hacer que cuando inice el server salgan los resource 1 tras del otro; mas especifico es que cuando pongo una imagen de intro, la que solo que se quita con "espacio" y luego quiero que salga el login y luego el spawn! Como se puede hacer eso? Porque cuando inicio el server con todos los resource al mismo tiempo se vuelve un despelote al entrar al server! Otra cosa Quiero que me enseñen a usar el Tooltips https://community.multitheftauto.com/index.php?p=resources&s=details&id=3054 para ponerlo en unos resources, como paneles, loginsystem, shoppanel bueno esas cosas! Espero que me ayuden con la primera! Es importante quisiera saber como hacer eso Link to comment
BorderLine Posted September 3, 2012 Share Posted September 3, 2012 podrias la imagen, todas sus funciones, agregarla al login. y al login quitarle el evento onResourceStart (si es que ese fuese el evento) modificar las funciones de la imagen y que al apretar la espaciadora, o la bind ke tengas, desaparesca la imagen y agregar la funcion guiVisible, no recuerdo como eso.. Y al spawn, cambiarle el evento, en vez de onResourceStart ponerle onPlayerLogin Link to comment
DefearT Posted September 3, 2012 Author Share Posted September 3, 2012 Nada, no funciona, que el evento cambia eso? Bueno pero el spawn no funcionara porque mi login no es como los otros el que tengo yo es diferente mira el server.side function PlayerLogin(username,password,checksave) if not (username == "") then if not (password == "") then local account = getAccount ( username, password ) if ( account ~= false ) then logIn(source, account, password) triggerClientEvent (source,"hideLoginWindow",getRootElement()) if checksave == true then triggerClientEvent(source,"saveLoginToXML",getRootElement(),username,password) else triggerClientEvent(source,"resetSaveXML",getRootElement(),username,password) end else triggerClientEvent(source,"set_warning_text",getRootElement(),"Login","Wrong username and/or password!") end else triggerClientEvent(source,"set_warning_text",getRootElement(),"Login","Please enter your password!") end else triggerClientEvent(source,"set_warning_text",getRootElement(),"Login","Please enter your username!") end end addEvent("onRequestLogin",true) addEventHandler("onRequestLogin",getRootElement(),PlayerLogin) function registerPlayer(username,password,passwordConfirm) if not (username == "") then if not (password == "") then if not (passwordConfirm == "") then if password == passwordConfirm then local account = getAccount (username,password) if (account == false) then local accountAdded = addAccount(tostring(username),tostring(password)) if (accountAdded) then outputChatBox ("#FF0000* #00FF00You have sucessfuly registered! [username: #FFFFFF" .. username .. " #00FF00| Password: #FFFFFF" .. password .. "#00FF00 ]",source,255,255,255,true ) else triggerClientEvent(source,"set_warning_text",getRootElement(),"Register","An unknown error has occured! Please choose a different username/password and try again.") end else triggerClientEvent(source,"set_warning_text",getRootElement(),"Register","An account with this username already exists!") end else triggerClientEvent(source,"set_warning_text",getRootElement(),"Register","Passwords do not match!") end else triggerClientEvent(source,"set_warning_text",getRootElement(),"Register","Please confirm your password!") end else triggerClientEvent(source,"set_warning_text",getRootElement(),"Register","Please enter a password!") end else triggerClientEvent(source,"set_warning_text",getRootElement(),"Register","Please enter a username you would like to register with!") end end addEvent("onRequestRegister",true) addEventHandler("onRequestRegister",getRootElement(),registerPlayer) entonces si el login no es parecido a los otros el spawn tampoco; como seria ya el spawn porque ya lo probe y cuando doy spawn no sale el jugador! Por sierto este es el codigo de la imagen-intro! function showClientImage() myImage = guiCreateStaticImage( 0.0,0.0,1279.0,767.0, "images/image.png", true ) end addEventHandler( "onClientResourceStart", resourceRoot, showClientImage ) function hideClientImage() if isElement ( myImage ) then destroyElement ( myImage ) end end bindKey("space", "down", hideClientImage) que es lo que tengo que cambiar? Link to comment
BorderLine Posted September 3, 2012 Share Posted September 3, 2012 postea el client de tu login y server del spawn Link to comment
DefearT Posted September 3, 2012 Author Share Posted September 3, 2012 Este es el client-side del loginpanel wdwLogin_Pannel = {} tabPannel_Main = {} tab_Login = {} tab_Register = {} --Settings blackLoginScreen = true --True/false Black screen, while player login... blackScreenTime = 5 --Time to complete disappearance of the black screen in seconds. GuestEnable = true --Can a Player play as Guest, or no. [true/false] function open_log_reg_pannel() if not(isElement(wdwLogin_Pannel)) then if blackLoginScreen == true then fadeCamera(false,0,0,0,0) end local sWidth,sHeight = guiGetScreenSize() -- The variables local Width,Height = 473,284 --Ширина, Высота окна local X = (sWidth/2) - (Width/2) --Получение центра по X (По ширине экрана) local Y = (sHeight/2) - (Height/2) --Получение центра по Y (Высоте экрана) wdwLogin_Pannel = guiCreateWindow(X,Y,Width,Height,"Login Panel",false) guiWindowSetSizable(wdwLogin_Pannel,false) tabPannel_Main = guiCreateTabPanel(9,23,455,251,false,wdwLogin_Pannel) tab_Login = guiCreateTab("Login",tabPannel_Main) lbl_Login = guiCreateLabel(103,72,42,19,"Login:",false,tab_Login) guiLabelSetVerticalAlign(lbl_Login,"center") guiLabelSetHorizontalAlign(lbl_Login,"right",false) guiSetFont(lbl_Login,"default-bold-small") edit_Login = guiCreateEdit(156,72,169,23,"",false,tab_Login) --Поле ввода логина edit_password = guiCreateEdit(156,106,169,23,"",false,tab_Login) --Поле ввода пароля guiEditSetMaxLength ( edit_Login,25) guiEditSetMaxLength ( edit_password,25) guiEditSetMasked ( edit_password, true ) lbl_Password = guiCreateLabel(48,106,96,19,"Password:",false,tab_Login) guiLabelSetVerticalAlign(lbl_Password,"center") guiLabelSetHorizontalAlign(lbl_Password,"right",false) guiSetFont(lbl_Password,"default-bold-small") lbl_top_info = guiCreateLabel(109,6,244,35,"Please write your username and password.",false,tab_Login) guiLabelSetColor(lbl_top_info,68,255,134) guiLabelSetVerticalAlign(lbl_top_info,"center") guiLabelSetHorizontalAlign(lbl_top_info,"center",false) lbl_about_legth = guiCreateLabel(142,42,184,18,"Max Length: 25 symbols",false,tab_Login) guiLabelSetColor(lbl_about_legth,253,255,68) guiLabelSetVerticalAlign(lbl_about_legth,"center") guiLabelSetHorizontalAlign(lbl_about_legth,"center",false) checkbox_save = guiCreateCheckBox(329,110,100,20,"(Save)",false,false,tab_Login) guiSetFont(checkbox_save,"default-small") btn_Login = guiCreateButton(164,162,147,41,"Login",false,tab_Login) guiSetFont(btn_Login,"default-bold-small") login_tab_error_msg = guiCreateLabel(31,131,419,25,"Error_login_tab",false,tab_Login) guiLabelSetColor(login_tab_error_msg,255,0,0) guiLabelSetVerticalAlign(login_tab_error_msg,"center") guiLabelSetHorizontalAlign(login_tab_error_msg,"center",false) guiSetFont(login_tab_error_msg,"default-bold-small") --Guest func if GuestEnable == true then btnGuest = guiCreateButton(29,168,94,32,"Play as Guest",false,tab_Login) guiSetFont(btnGuest,"default-small") guiSetVisible(btnGuest,true) else if isElement(btnGuest) then guiSetVisible(btnGuest,false) end btnGuest = nil end tab_Register = guiCreateTab("Register",tabPannel_Main) lbl_account_name = guiCreateLabel(43,39,119,21,"Account Name:",false,tab_Register) guiLabelSetVerticalAlign(lbl_account_name,"center") guiLabelSetHorizontalAlign(lbl_account_name,"right",false) guiSetFont(lbl_account_name,"default-bold-small") lbl_reg_top_info = guiCreateLabel(66,5,364,31,"Please, fill in all fields! (Don't use \"!@#$\"%'^&*()\")",false,tab_Register) guiLabelSetColor(lbl_reg_top_info,255,234,55) guiLabelSetVerticalAlign(lbl_reg_top_info,"center") guiLabelSetHorizontalAlign(lbl_reg_top_info,"center",false) edit_account_name = guiCreateEdit(172,40,176,23,"",false,tab_Register) guiEditSetMaxLength ( edit_account_name,25) lbl__reg_tab_password = guiCreateLabel(43,71,119,21,"Password:",false,tab_Register) guiLabelSetVerticalAlign(lbl__reg_tab_password,"center") guiLabelSetHorizontalAlign(lbl__reg_tab_password,"right",false) guiSetFont(lbl__reg_tab_password,"default-bold-small") edit__reg_tab_password = guiCreateEdit(172,71,176,23,"",false,tab_Register) guiEditSetMaxLength ( edit__reg_tab_password,25) edit__reg_tab_Repassword = guiCreateEdit(172,102,176,23,"",false,tab_Register) guiEditSetMaxLength ( edit__reg_tab_Repassword,25) lvl_reg_tab_Repassword = guiCreateLabel(43,102,119,21,"Repeat password:",false,tab_Register) guiLabelSetVerticalAlign(lvl_reg_tab_Repassword,"center") guiLabelSetHorizontalAlign(lvl_reg_tab_Repassword,"right",false) guiSetFont(lvl_reg_tab_Repassword,"default-bold-small") btn_reg_tab_register = guiCreateButton(153,161,174,42,"Confirm & register!",false,tab_Register) guiSetFont(btn_reg_tab_register,"default-bold-small") reg_tab_error_msg = guiCreateLabel(66,129,364,31,"Error_reg_ttab",false,tab_Register) guiLabelSetColor(reg_tab_error_msg,255,20,0) guiLabelSetVerticalAlign(reg_tab_error_msg,"center") guiLabelSetHorizontalAlign(reg_tab_error_msg,"center",false) guiSetFont(reg_tab_error_msg,"default-bold-small") guiSetVisible(wdwLogin_Pannel,true) --guiSetInputEnabled(true) showCursor(true) --Изменение надписей: guiSetText(reg_tab_error_msg, "") --Поле ошибки в Reg табе guiSetText(login_tab_error_msg, "") --Поле ошибки в Login табе local username, password = loadLoginFromXML() if not( username == "" or password == "") then guiCheckBoxSetSelected ( checkbox_save, true ) guiSetText ( edit_Login, tostring(username)) guiSetText ( edit_password, tostring(password)) else guiCheckBoxSetSelected ( checkbox_save, false ) guiSetText ( edit_Login, tostring(username)) guiSetText ( edit_password, tostring(password)) end --Эвенты addEventHandler("onClientGUIClick",btn_Login,onClickBtnLogin) addEventHandler("onClientGUIClick",btn_reg_tab_register,onClickBtnRegister) if GuestEnable == true then addEventHandler("onClientGUIClick",btnGuest,onClickGuest) end --else --destroyElement(wdwLogin_Pannel) --guiSetInputEnabled(false) --wdwLogin_Pannel = nil --showCursor(false) end end function start_cl_resource() --При старте open_log_reg_pannel() end addEventHandler("onClientResourceStart",getResourceRootElement(getThisResource()),start_cl_resource) function loadLoginFromXML() --Загрузка логина и пароля из XML local xml_save_log_File = xmlLoadFile ("files/xml/userdata.xml") if not xml_save_log_File then xml_save_log_File = xmlCreateFile("files/xml/userdata.xml", "login") end local usernameNode = xmlFindChild (xml_save_log_File, "username", 0) local passwordNode = xmlFindChild (xml_save_log_File, "password", 0) if usernameNode and passwordNode then return xmlNodeGetValue(usernameNode), xmlNodeGetValue(passwordNode) else return "", "" end xmlUnloadFile ( xml_save_log_File ) end function saveLoginToXML(username, password) --Сохрание логина и пароля в XML local xml_save_log_File = xmlLoadFile ("files/xml/userdata.xml") if not xml_save_log_File then xml_save_log_File = xmlCreateFile("files/xml/userdata.xml", "login") end if (username ~= "") then local usernameNode = xmlFindChild (xml_save_log_File, "username", 0) if not usernameNode then usernameNode = xmlCreateChild(xml_save_log_File, "username") end xmlNodeSetValue (usernameNode, tostring(username)) end if (password ~= "") then local passwordNode = xmlFindChild (xml_save_log_File, "password", 0) if not passwordNode then passwordNode = xmlCreateChild(xml_save_log_File, "password") end xmlNodeSetValue (passwordNode, tostring(password)) end xmlSaveFile(xml_save_log_File) xmlUnloadFile (xml_save_log_File) end addEvent("saveLoginToXML", true) addEventHandler("saveLoginToXML", getRootElement(), saveLoginToXML) function resetSaveXML() --Сохрание логина и пароля в XML local xml_save_log_File = xmlLoadFile ("files/xml/userdata.xml") if not xml_save_log_File then xml_save_log_File = xmlCreateFile("files/xml/userdata.xml", "login") end if (username ~= "") then local usernameNode = xmlFindChild (xml_save_log_File, "username", 0) if not usernameNode then usernameNode = xmlCreateChild(xml_save_log_File, "username") end end if (password ~= "") then local passwordNode = xmlFindChild (xml_save_log_File, "password", 0) if not passwordNode then passwordNode = xmlCreateChild(xml_save_log_File, "password") end xmlNodeSetValue (passwordNode, "") end xmlSaveFile(xml_save_log_File) xmlUnloadFile (xml_save_log_File) end addEvent("resetSaveXML", true) addEventHandler("resetSaveXML", getRootElement(), resetSaveXML) function onClickBtnLogin(button,state) --При нажатии на кнопку Login if(button == "left" and state == "up") then if (source == btn_Login) then username = guiGetText(edit_Login) password = guiGetText(edit_password) if guiCheckBoxGetSelected ( checkbox_save ) == true then checksave = true else checksave = Link to comment
Recommended Posts