yanvr Posted April 29, 2012 Share Posted April 29, 2012 hi I'm doing this test gametype but I need to explain me how to make start another panel from other resource with a button still do not understand some things (enough) I try this but does not work fadeCamera(true, 6, 0, 0, 0) setCameraMatrix(-1545.4565429688,1018.2725830078,25.7421875, -1545.9423828125, 1014.6403198242, 26.99153137207) setCameraMatrix(2032.2386474609,1317.4577636719,10.8203125, 2032.2386474609, 1316.4416503906, 10.8203125) Menu = guiCreateWindow(100, 300, 300, 200, "Welcome", false ) Mn1 = guiCreateButton(25,20,250,30,"Enter",false,Menu) Mn2 = guiCreateButton(25,55,250,30,"Options",false,Menu) Mn3 = guiCreateButton(25,85,250,30,"Los Santos",false,Menu) Mn4 = guiCreateButton(25,120,250,30,"San fernando",false,Menu) Mn5 = guiCreateButton(25,150,250,30,"Help",false,Menu) showCursor(true) addEventHandler("onClientResourceStart",getRootElement(),setUp) addEventHandler ("onClientGUIClick", Mn1, call (getResourceFromName("login"),windowHandler) end the button is "Mn1 = "Enter" the login resource is "login_register ([crows]login)" https://community.multitheftauto.com/ind ... ls&id=3473 Link to comment
iFoReX Posted April 29, 2012 Share Posted April 29, 2012 First you cant call a resource from a event Second you need do your functions logins in your resource I think Link to comment
qaisjp Posted April 29, 2012 Share Posted April 29, 2012 Show entire code in both resources. Link to comment
Michael# Posted April 29, 2012 Share Posted April 29, 2012 First you cant call a resource from a event Second you need do your functions logins in your resource I think First you cant call a resource from a event What do you mean? He can, but not that way he is doing. Must be something like this: addEventHandler ( 'onClientGUIClick', root, function ( ) if ( source == testBtn ) then call ( getResourceFromName ( 'Example' ), 'initExample' ); end end ) Link to comment
iFoReX Posted April 29, 2012 Share Posted April 29, 2012 lol he cant -.- he had put the call in addEventHandler -.- Link to comment
Michael# Posted April 29, 2012 Share Posted April 29, 2012 He can, but not that way he is doing. Link to comment
yanvr Posted April 29, 2012 Author Share Posted April 29, 2012 I'm trying this and not works addEventHandler ( 'onClientGUIClick', root, function ( ) if ( source == Mn1 ) then call ( getResourceFromName ( 'login' ), 'guiSetVisible(LoginWin, true)' ); end end ) This is the login resource. when the login resource start the login gui is invisible. I want to setvisible the login gui with a button. login client: x,y = guiGetScreenSize() LoginWin = guiCreateWindow(x/2 - 150,y/2 - 110,300,220,"[Crows] Login",false) TabPanel = guiCreateTabPanel(17,30,261,152,false,LoginWin) TabLogin = guiCreateTab("Entrar",TabPanel) LblUsername = guiCreateLabel(11,27,70,16,"Usuario",false,TabLogin) LoginUsername = guiCreateEdit(76,26,171,21,"",false,TabLogin) LblPassword = guiCreateLabel(11,60,70,16,"Contraseña",false,TabLogin) LoginPassword = guiCreateEdit(76,58,171,21,"",false,TabLogin) guiEditSetMasked(LoginPassword,true) TabRegister = guiCreateTab("Registrarse",TabPanel) LblRegisterUsername = guiCreateLabel(11,27,70,16,"Usuario",false,TabRegister) EditRegisterUsername = guiCreateEdit(76,26,171,21,"",false,TabRegister) LblRegisterPassword = guiCreateLabel(11,60,70,16,"Contraseña",false,TabRegister) EditRegisterPassword = guiCreateEdit(76,58,171,21,"",false,TabRegister) guiEditSetMasked(EditRegisterPassword,true) LblRegisterEmail = guiCreateLabel(35,92,35,16,"¿Sexo?",false,TabRegister) EditRegisterEmail = guiCreateEdit(76,90,171,21,"",false,TabRegister) BtnAction = guiCreateButton(182,188,95,19,"Jugar!",false,LoginWin) guiSetVisible(LoginWin, false) local localPlayer = getLocalPlayer() function receiveVars( allow, email) local playername = getPlayerName(localPlayer) guiSetText(LoginUsername, "") guiSetText(EditRegisterUsername, "") if (email == "false") then guiSetVisible(LblRegisterEmail, false) guiSetVisible(EditRegisterEmail, false) end if (allow == "false") then guiDeleteTab(TabRegister, TabPanel) end guiSetSelectedTab(TabPanel, TabLogin) guiSetText(LoginUsername, playername) guiSetText(EditRegisterUsername, playername) guiSetVisible(LoginWin, true) guiBringToFront(LoginWin) guiSetInputEnabled(true) showCursor(true) end addEvent( "onSendVars", true ) addEventHandler( "onSendVars", getRootElement(), receiveVars ) function windowHandler() triggerServerEvent("onNeedVars", getLocalPlayer()) end function onClickBtn(button, state) if(button == "left" and state == "up") then if(source == BtnAction) then if(guiGetSelectedTab(TabPanel) == TabLogin) then triggerServerEvent("on4XLogin", getRootElement(), localPlayer, guiGetText(LoginUsername), guiGetText(LoginPassword)) else triggerServerEvent("on4XRegister", getRootElement(), localPlayer, guiGetText(EditRegisterUsername), guiGetText(EditRegisterPassword), guiGetText(EditRegisterEmail)) end end end end addEventHandler("onClientGUIClick", BtnAction, onClickBtn, false) function hideLoginWindow() guiSetInputEnabled(false) guiSetVisible(LoginWin, false) showCursor(false) end addEvent("hideLoginWindow", true) addEventHandler("hideLoginWindow", getRootElement(), hideLoginWindow) serverside: function on4XLogin ( player, user, pass ) local account = getAccount ( user, pass ) if ( account ~= false ) then if ( not isGuestAccount ( account ) ) then -- For every player that's logged in.... logOut ( player ) -- Log them out. end if (logIn ( player, account, pass ) == true) then triggerClientEvent ( player, "hideLoginWindow", getRootElement()) else outputChatBox ( "ERROR!", player, 255, 255, 0 ) -- Output they got the details wrong. end else outputChatBox ( "Contraseña o usuario Incorrecto/a!", player, 255, 255, 0 ) -- Output they got the details wrong. end end addEvent( "on4XLogin", true ) addEventHandler( "on4XLogin", getRootElement(), on4XLogin ) function on4XRegister ( player, user, pass, email ) local account = getAccount ( user, pass ) if ( account ~= false ) then if (logIn ( player, account, pass ) == true) then triggerClientEvent ( player, "hideLoginWindow", getRootElement()) else outputChatBox ( "Login error!", player, 255, 255, 0 ) -- Output they got the details wrong. end else account = addAccount ( user, pass ) setAccountData ( account, "email", email) if (logIn ( player, account, pass ) == true) then triggerClientEvent ( player, "hideLoginWindow", getRootElement()) else outputChatBox ( "Error de registro/entrada!", player, 255, 255, 0 ) -- Output they got the details wrong. end end end addEvent( "on4XRegister", true ) addEventHandler( "on4XRegister", getRootElement(), on4XRegister ) function needVars() local allow_register = get("allow_register") local email_on_register = get("email_on_register") triggerClientEvent(source, "onSendVars", getRootElement(), allow_register, email_on_register) end addEvent("onNeedVars", true) addEventHandler("onNeedVars", getRootElement(), needVars) Link to comment
Michael# Posted April 29, 2012 Share Posted April 29, 2012 call ( getResourceFromName ( 'login' ), 'guiSetVisible(LoginWin, true)' ); call function is to call exported functions from resources, not to execute functions in another resource. It does the same of: exports [ 'login' ]:initExample() -- or exports.login:initExample() Link to comment
qaisjp Posted April 30, 2012 Share Posted April 30, 2012 also add this in the login resource meta: 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