DutchCaffeine Posted June 22, 2008 Share Posted June 22, 2008 Hello everybody, Here i'm again! In my client side scripts i made 2 event: addEvent("onStartSelection", true) addEventHandler("onStartSelection", getRootElement(), class_start) addEvent("onRegisterStart", true) addEventHandler("onRegisterStart", getRootElement(), toggleRegister) The event "onRegisterStart" will be called up when a player joins the server, it need to popup the registration window. But if i join at the first time, and i be not registered, it will give an error "Event onRegisterStart is not created." I also added a bind key (F5) when i press it it will popup the register window, if i fill everything in, and register my self (everything ok) it should call onStartSelection event but it gives the same error If i rejoin it works fine that, but i want that it works when i first join the server. Link to comment
Ace_Gambit Posted June 22, 2008 Share Posted June 22, 2008 Correct me if I'm wrong but I think that has to do with the fact that the client script is not fully loaded yet. Link to comment
50p Posted June 24, 2008 Share Posted June 24, 2008 Correct me if I'm wrong but I think that has to do with the fact that the client script is not fully loaded yet. True. Alexander, use onClientResourceStart instead. I have a question though, is F5 key bound in client-side script or server-side? Link to comment
DutchCaffeine Posted June 24, 2008 Author Share Posted June 24, 2008 F5 was bound in the client script. But deleted it! I just found the best solution for this problem: Client side code: function clientResStart() triggerServerEvent("clientResourceStart", getRootElement(), getLocalPlayer()) end addEventHandler("onClientResourceStart", getRootElement(), clientResStart) Simple and small and works like how it need to work Server side code: function clientResStart(player) if checkAccount(player) then -- Show login window triggerClientEvent("onLoginAccount", getRootElement()) else -- outputChatBox("#FF0000It look's like you are not registered, please register your self!", source, 255, 255, 255, true) triggerClientEvent("onRegisterStart", getRootElement()) end end addEvent("clientResourceStart", true) addEventHandler("clientResourceStart", getRootElement(), clientResStart) That is perfect solution for what i want, and now I HAVE IT!!! Thanks to you all for the help, reply's to you. Link to comment
50p Posted June 24, 2008 Share Posted June 24, 2008 Use addEventHandler( "onClientResourceStart", getResourceRootElement( getThisResource() ), clientResStart) to prevent triggering the server event whenever any resource starts. 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