Sam Fisher Posted June 28, 2008 Share Posted June 28, 2008 This is the clientside code: localPlayer = getLocalPlayer() wnd_window = {} addEventHandler( "onClientLogin", getResourceRootElement( getThisResource() ), function ( theResource ) --outputConsole( "wnd_showServerInfo called" ) --outputConsole( " source: ".. tostring( source ) ) --outputConsole( " resourceStarted: ".. tostring( theResource ) ) if source == getResourceRootElement( theResource ) then --outputConsole( " passed if: source == resource" ) local xml = xmlLoadFile( "server.xml" ) local contents = xmlNodeGetValue( xml ) wnd_create( "Ablakgeci", "logo.png", contents ) end end ) function wnd_close() guiSetVisible( wnd_window.wnd, false ) showCursor( false ) end addEvent( "window_text", true ) function wnd_create( title, logo, content ) --outputConsole( "wnd_create called" ) if not wnd_window.wnd then --outputConsole( " passed if" ) wnd_window.wnd = guiCreateWindow( 0.1, 0.15, 0.8, 0.7, title, true ) guiWindowSetSizable( wnd_window.wnd, false ) guiWindowSetMovable( wnd_window.wnd, false ) wnd_window.logo = guiCreateStaticImage( 0.01, 0.035, 0.98, 0.25, logo, true, wnd_window.wnd ) --wnd_window.text = content wnd_window.memo = guiCreateMemo( 0, 0.3, 1, .6, content, true, wnd_window.wnd ) guiMemoSetReadOnly( wnd_window.memo, true ) wnd_window.close_btn = guiCreateButton( 0, .91, .3, 1, "Bezar", true, wnd_window.wnd ) --outputConsole( " window created: ".. tostring( wnd_window.wnd ) ) showCursor( true ) addEventHandler( "onClientGUIClick", wnd_window.close_btn, wnd_close ) end end addEventHandler( "window_text", getRootElement(), wnd_create ) I'd like the window appear after a client logged in to my server. After the login nothing happens with this script. Can someone help me please? Link to comment
robhol Posted June 28, 2008 Share Posted June 28, 2008 (edited) --- post deleted by me. Way off. Edited June 29, 2008 by Guest Link to comment
50p Posted June 28, 2008 Share Posted June 28, 2008 1. onClientLogin is server-side only. 2. "The source of this event is the client element that just logged in." 3. Parameters for a function are wrong. 4. Don't attach this event handler to resources' root element, because player element (player who joins for example) are in the Root of the element tree. Unless you player element is a child of the resource (e.g. you're a team member of a team created by this resource) 5. Read wiki 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