Lalalu Posted October 4, 2023 Share Posted October 4, 2023 Hello everyone, I need help with something, I'm creating missions for my server, I want the missions to only be done daily, I mean, the marker and ped once the mission is done disappears and appears the next day. The problem is, when I destroy the ped and the marker (destroyElement) and I quit or reconnect into the server, the ped and the marker appears again. How can I save destroyElements and make it appears daily once it's destroyed? Link to comment
alex17" Posted October 5, 2023 Share Posted October 5, 2023 (edited) If they don't show us your code it is difficult to help you, first of all, how are you working on your missions on the server or on the client? Edited October 5, 2023 by alex17" Link to comment
Lalalu Posted October 6, 2023 Author Share Posted October 6, 2023 (edited) 9 hours ago, alex17" said: If they don't show us your code it is difficult to help you, first of all, how are you working on your missions on the server or on the client? Sorry, it's client side. I'm using destroyElement with setTimer to destroy the markers and to create it again, but when i quit the server and join again the markers appears. The missions I have created work like this: When you hit a marker, execute the mission and immediately delete that marker, that way the mission cannot be done again until the marker appears again. What I'm looking for is to save that, 'cause the missions must be daily, I want to make that the marker reappears only the next day once its deleted Edited October 6, 2023 by Lalalu Link to comment
Other Languages Moderators androksi Posted October 6, 2023 Other Languages Moderators Share Posted October 6, 2023 Hello. I believe that it's better to do all the saving logics server-side, using a database or whatever you prefer. Once the player hits the marker and start the mission, call a server-side through triggerServerEvent function and store the information in the database. It would be interesting to save timestamps too, as you stated that missions are made once a day. Now, when the player reconnects from the server, all you need to do is checking database to get the player's mission. Link to comment
alex17" Posted October 6, 2023 Share Posted October 6, 2023 We still don't know how your missions are working, it would be easier if you provide us with the code. Likewise, I leave you a small example of how you could work it, although in my opinion it would be much easier if you worked everything on the server and not on the client. -- Server local day = getRealTime().monthday --- Set the server day addEventHandler("onPlayerLogin", root, function() if getRealTime().monthday ~= day then --- When a player connects, check if the day has changed day = getRealTime().monthday --- If it is another day, save it in the variable setAccountData(getPlayerAccount(source), "isMissionCompleted", false) -- resets the player's mission data triggerClientEvent(source, "createMissionMarker", source) --- send a trigger to the client to create the marker else -- If the day still does not change, check if the player has already completed the mission local isMissionCompleted = getAccountData(getPlayerAccount(source), "isMissionCompleted") if not isMissionCompleted then --- If the mission has not yet been completed, send a trigger to create the marker triggerClientEvent(source, "createMissionMarker", source) end end end ) --- When you complete the mission, send a trigger to the server to save the data addEvent("onMissionCompleted", true) addEventHandler("onMissionCompleted", root, function() setAccountData(getPlayerAccount(client), "isMissionCompleted", true) end) -- Client addEvent("createMissionMarker", true) addEventHandler("createMissionMarker", root, function() marker = createMarker(...) end) Link to comment
Lalalu Posted October 7, 2023 Author Share Posted October 7, 2023 6 hours ago, alex17" said: We still don't know how your missions are working, it would be easier if you provide us with the code. Likewise, I leave you a small example of how you could work it, although in my opinion it would be much easier if you worked everything on the server and not on the client. -- Server local day = getRealTime().monthday --- Set the server day addEventHandler("onPlayerLogin", root, function() if getRealTime().monthday ~= day then --- When a player connects, check if the day has changed day = getRealTime().monthday --- If it is another day, save it in the variable setAccountData(getPlayerAccount(source), "isMissionCompleted", false) -- resets the player's mission data triggerClientEvent(source, "createMissionMarker", source) --- send a trigger to the client to create the marker else -- If the day still does not change, check if the player has already completed the mission local isMissionCompleted = getAccountData(getPlayerAccount(source), "isMissionCompleted") if not isMissionCompleted then --- If the mission has not yet been completed, send a trigger to create the marker triggerClientEvent(source, "createMissionMarker", source) end end end ) --- When you complete the mission, send a trigger to the server to save the data addEvent("onMissionCompleted", true) addEventHandler("onMissionCompleted", root, function() setAccountData(getPlayerAccount(client), "isMissionCompleted", true) end) -- Client addEvent("createMissionMarker", true) addEventHandler("createMissionMarker", root, function() marker = createMarker(...) end) Thanks Im gonna try, I used to use serverside, but then when many players took the mission at the same time everything got mixed up lol 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