Donny7878 Posted August 1, 2009 Share Posted August 1, 2009 Server: addEventHandler( "onPlayerJoin", getRootElement(), function () outputChatBox( "Welcome " .. getPlayerName ( source ) .. " to the test server" , source, 255, 255, 255 ) fadeCamera( source, true ) setCameraTarget( source ) spawnPlayer( source, 0.0, 0.0, 3.0, 0.0 ) triggerClientEvent( source, "onRequestBuildGUI", getRootElement() ) end ) Client: addEvent ( "onRequestBuildGUI", true ) addEventHandler ( "onRequestBuildGUI", getRootElement(), CreateGUI ) function CreateGUI( source ) outputChatBox ( "The CreateGUI function fired", 255, 255, 255 ) end Just trying to trigger the CreateGUI function when the player joins and send the message (currently) but for some reason I'm getting nothing. I debugged the trigger and it is sending the event trigger (returned true) but the client never seems to get the call or doesn't want to fire the event, could you tell me why ? I have been working from this page on the Wiki -> TriggerClientEvent Link to comment
Remp Posted August 1, 2009 Share Posted August 1, 2009 when the player joins the server (onPlayerJoin triggers) they havent necessarily finished downloading the clientside scripts, so you may end up trying to trigger a client event that simply does not exist yet you can use onClientResourceStart clientside to achieve what you are trying to do, it is triggered when the player finishes downloading the client script when they join the server function CreateGUI() outputChatBox ( "The CreateGUI function fired", 255, 255, 255 ) end addEventHandler("onClientResourceStart",getResourceRootElement(getThisResource()),CreateGUI) Link to comment
Donny7878 Posted August 1, 2009 Author Share Posted August 1, 2009 when the player joins the server (onPlayerJoin triggers) they havent necessarily finished downloading the clientside scripts, so you may end up trying to trigger a client event that simply does not exist yetyou can use onClientResourceStart clientside to achieve what you are trying to do, it is triggered when the player finishes downloading the client script when they join the server function CreateGUI() outputChatBox ( "The CreateGUI function fired", 255, 255, 255 ) end addEventHandler("onClientResourceStart",getResourceRootElement(getThisResource()),CreateGUI) Makes sense that, it would explain why some other code isn't working also. Works perfectly when using your code so cheers for the that and the info, it's apreciated. 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