SuperBrandy Posted September 1, 2014 Share Posted September 1, 2014 Hi there! I want to trigger a server event with onClientResourceStop but it does nothing at all. Don't worry about savings, they work when i call them with a command Handler. CLIENT addEventHandler("onClientResourceStop", getResourceRootElement(getThisResource()), function() triggerServerEvent("Save", getRootElement(), SaveVariable) end) SERVER function Save(SaveVariable) setElementData(SaveObject, Slot, SaveVariable) end addEvent("Save", true) addEventHandler("Save", getRootElement(), Save) I could imagine that this isn't working because the Client is shutting down to early but honestly, i have no idea. It would be very nice if someone could help me and fix this or suggest another way to save "onClientResourceStop" ! Thanks a lot SuperBrandy Link to comment
Bonsai Posted September 1, 2014 Share Posted September 1, 2014 What do you wanna save? This event is hardly triggered. Maps are the only resources that getting started and stopped a lot. If its about maps and you are using race resource then there is an event for map ending. Else you might wanna go with onPlayerQuit. Link to comment
SuperBrandy Posted September 2, 2014 Author Share Posted September 2, 2014 Hey thanks for your answer! Well, first of all this code is for a script so i don't think the race resource would work. I also tried onPlayerClientQuit, isn't working either. So i need to trigger this function client side when the player disconnects because i want to pass a variable and save it with the setElementData() function. Link to comment
DiSaMe Posted September 2, 2014 Share Posted September 2, 2014 It doesn't make much sense to send the data to server right before quitting. Even if it seemed to work, what guarantees that the data won't be lost on the way to server and have to be resent again? Then the client would have to wait until all data is delivered before quitting. What if connection is lost? Then the event will never be triggered. I don't see much use in sending some data from client to server upon quit, anyway. Link to comment
Anubhav Posted September 2, 2014 Share Posted September 2, 2014 Hey thanks for your answer! Well, first of all this code is for a script so i don't think the race resource would work. I also tried onPlayerClientQuit, isn't working either. So i need to trigger this function client side when the player disconnects because i want to pass a variable and save it with the setElementData() function. Its onClientPlayerQuit. Link to comment
SuperBrandy Posted September 2, 2014 Author Share Posted September 2, 2014 @Anunhav- I explained that i have to use Clientside because i need to send from Client to Server @CrystalMV- Good Point, thanks for your answer! I hoped that this may work but it seems like i need to find another way 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