Jump to content

onClientResourceStop Problem


SuperBrandy

Recommended Posts

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

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

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
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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...