FlyingSpoon Posted April 8, 2015 Share Posted April 8, 2015 function setCamera() setCameraMatrix(-688, 930, 50, 1468.388671875, -918.42474365234, 99.881813049316) fadeCamera(true, 1) end btnLogin = guiCreateButton(316, 469, 75, 31, "Login", false) btnRegister = guiCreateButton(662, 467, 75, 31, "Register", false) usrEdit = guiCreateEdit(436, 340, 169, 26, "", false) passEdit = guiCreateEdit(435, 394, 169, 26, "", false) guiEditSetMasked(passEdit, true) When I restart any other resource, it sets my camera matrix and and sets all this visible! Help ;( (I wont delete code now ) Link to comment
WhoAmI Posted April 8, 2015 Share Posted April 8, 2015 addEventHandler ( "onClientResourceStart", resourceRoot, function ( ) setCameraMatrix(-688, 930, 50, 1468.388671875, -918.42474365234, 99.881813049316) fadeCamera(true, 1) btnLogin = guiCreateButton(316, 469, 75, 31, "Login", false) btnRegister = guiCreateButton(662, 467, 75, 31, "Register", false) usrEdit = guiCreateEdit(436, 340, 169, 26, "", false) passEdit = guiCreateEdit(435, 394, 169, 26, "", false) guiEditSetMasked(passEdit, true) end ); Link to comment
FlyingSpoon Posted April 8, 2015 Author Share Posted April 8, 2015 When I restart another resource this is what happens, Link to comment
WhoAmI Posted April 8, 2015 Share Posted April 8, 2015 With my code it's impossible. It will appear only if you start the resource where the code is written. Link to comment
FlyingSpoon Posted April 8, 2015 Author Share Posted April 8, 2015 Here's my whole code, addEventHandler ( "onClientResourceStart", resourceRoot, function ( ) setCameraMatrix(-688, 930, 50, 1468.388671875, -918.42474365234, 99.881813049316) fadeCamera(true, 1) btnLogin = guiCreateButton(316, 469, 75, 31, "Login", false) btnRegister = guiCreateButton(662, 467, 75, 31, "Register", false) usrEdit = guiCreateEdit(436, 340, 169, 26, "", false) passEdit = guiCreateEdit(435, 394, 169, 26, "", false) guiEditSetMasked(passEdit, true) end ); function mainGUI() dxDrawLine(305 - 1, 288 - 1, 305 - 1, 506, tocolor(255, 255, 255, 255), 1, false) dxDrawLine(744, 288 - 1, 305 - 1, 288 - 1, tocolor(255, 255, 255, 255), 1, false) dxDrawLine(305 - 1, 506, 744, 506, tocolor(255, 255, 255, 255), 1, false) dxDrawLine(744, 506, 744, 288 - 1, tocolor(255, 255, 255, 255), 1, false) dxDrawRectangle(305, 288, 439, 218, tocolor(0, 0, 0, 120), false) dxDrawText("Username", 488, 323, 551, 340, tocolor(255, 255, 255, 255), 1.00, "default-bold", "left", "top", false, false, false, false, false) dxDrawText("Password", 488, 380, 551, 397, tocolor(255, 255, 255, 255), 1.00, "default-bold", "left", "top", false, false, false, false, false) end addEventHandler("onClientRender", root, mainGUI) startX, startY = 400, 11; -- starting position endX, endY = 425, 165; -- ending position t = 1; -- time function startIt() local startTime = getTickCount ( ); local duration = t * 1000; render = function ( ) local elapsedTime = getTickCount ( ) - startTime; local progress = elapsedTime / duration; local x, y = interpolateBetween ( startX, startY, 0, endX, endY, 0, progress, "OutBounce" ); main = dxDrawImage ( x, y, 197, 105, "logo.png", 0, 0, 0, tocolor ( 255, 255, 255, 255 ), false ); end addEventHandler ( "onClientRender", root, render ); end addEventHandler ( "onClientResourceStart", resourceRoot, startIt) function resourceStart() setCamera() guiSetVisible(btnLogin, true) guiSetVisible(btnRegister, true) guiSetVisible(usrEdit, true) guiSetVisible(passEdit, true) end showCursor(true) addEventHandler("onClientResourceStart", root, resourceStart) function clientSubmitLogin(button, state) if source == btnLogin then if button == "left" and state == "up" then local username = guiGetText(usrEdit) local password = guiGetText(passEdit) if username and password then triggerServerEvent("submitLogin", getRootElement(), localPlayer, username, password) else outputChatBox("Please enter a Username and Password!", 255, 0, 0) end end end end addEventHandler("onClientGUIClick", root, clientSubmitLogin) function clientSubmitRegister(button, state) if source == btnRegister then if button == "left" and state == "up" then local username = guiGetText(usrEdit) local password = guiGetText(passEdit) if username and password then triggerServerEvent("submitRegister", getRootElement(), localPlayer, username, password) removeEventHandler ( "onClientRender", root, render ) else outputChatBox("Please enter a Username and Password!", 255, 0, 0) end end end end addEventHandler("onClientGUIClick", root, clientSubmitRegister) function hideLoginWindow() guiSetInputEnabled(false) showCursor(false) removeEventHandler ( "onClientResourceStart", root, startIt ) removeEventHandler ( "onClientRender", root, mainGUI ) removeEventHandler ( "onClientRender", root, render ) guiSetVisible(btnLogin, false) guiSetVisible(btnRegister, false) guiSetVisible(usrEdit, false) guiSetVisible(passEdit, false) end addEvent("hideLoginWindow", true) addEventHandler("hideLoginWindow", root, hideLoginWindow) Link to comment
WhoAmI Posted April 8, 2015 Share Posted April 8, 2015 addEventHandler("onClientResourceStart", root, resourceStart) Change to addEventHandler("onClientResourceStart", resourceRoot, resourceStart) Link to comment
.:DoA:.Backflip Posted April 9, 2015 Share Posted April 9, 2015 How did you fix it? What was the problem? I'm asking you because it could help other people with the same or similar problem. Link to comment
FlyingSpoon Posted April 9, 2015 Author Share Posted April 9, 2015 I did as you said : p, well as other's said haha, I had a few other resources that were as addEventHandler("onClientRender", root, [FuncName] ) and I changed root to resourceRoot simple Just needed some thought! 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