anybox Posted July 25, 2013 Posted July 25, 2013 Hi. I have this code addEventHandler("onPlayerJoin", getRootElement(), function () triggerClientEvent ("playerJoinEventClient", source) end ) in the server-side script. So when I first time join the server nothing happens, the funcion "playerJoinEventClient" just doesn't work. But the second time when i join the server the function works perfectly. I think the problem is missing client-side script on the first launch, so maybe I can check if all the resources are downloaded then call triggerClientEvent? Thanks.
anybox Posted July 25, 2013 Author Posted July 25, 2013 The rest of the code on server-side script is not so important for this thread. This is on the client side. function playerJoinHandler() outputChatBox("Client joined") fadeCamera(true, 3) showPlayerHudComponent("radar", false); showPlayerHudComponent("area_name", false); setCameraMatrix(-911.46545410156, 1931.513671875, 130.02493286133, -392.18316650391, 1589.7071533203, 101.35176849365) end addEvent("playerJoinEventClient", true) addEventHandler("playerJoinEventClient", getRootElement(), playerJoinHandler)
DiSaMe Posted July 25, 2013 Posted July 25, 2013 Trigger an event from client to server when resource starts on the client's side (onClientResourceStart). This way the server will know when client-side script has already started.
TAPL Posted July 25, 2013 Posted July 25, 2013 I don't see a need for trigger from the server to the client. This will do the job on client side only. function playerJoinHandler() outputChatBox("Client joined") fadeCamera(true, 3) showPlayerHudComponent("radar", false); showPlayerHudComponent("area_name", false); setCameraMatrix(-911.46545410156, 1931.513671875, 130.02493286133, -392.18316650391, 1589.7071533203, 101.35176849365) end addEventHandler("onClientResourceStart", resourceRoot, playerJoinHandler) Btw. your trigger is actually wrong, this way it going trigger for all clients not only who join. triggerClientEvent ("playerJoinEventClient", source) Should be: triggerClientEvent (source, "playerJoinEventClient", source)
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