PLEASE READ BOTTOM FOR EDIT AND A HUGE PROBLEM THAT COULD BE EXPLOITED!!
Just posting this here for anyone else whose interested in how I’m gonna go about it (or if anyone has any quarrel with what I’ve done they can tell what I’ve done wrong
)
So dialogue is laid out in this table like so. With each final dialogue that an NPC has (‘End’) it has an UpdateStory
variable, and that determines whether this section of dialogue would update the story. As you can see, [0]
updates the story once dialogue has finished, while the others don’t. So when I talk to the NPC again, my story has been updated, and thus [1]
shows instead of [0]
return {
-- Main storyline dialogue
["Ol' Mate"] = {
Messages = {
[0] = {
[1] = {Msg = "Hello", Type = 'Normal'},
[2] = {Msg = "Do you wanna go on a quest?", Type = 'Question',
Responses = {
[1] = {
Answer = "Sure",
Direct = 3
},
},
},
[3] = {Msg = "Ok, go do stuff then!", Type = 'End', UpdateStory = true},
},
[1] = {
[1] = {Msg = "Go on! Go do the quest", Type = 'End', UpdateStory = false},
},
[2] = {
[1] = {Msg = "Thank you for doing this! I am happy now", Type = 'Normal'},
[2] = {Msg = "You can go do some other stuff now", Type = 'End', UpdateStory = false},
},
}
},
}
And then simply on the server, I can return and update the story as needed
local function Update(player)
local User = PlayerData[player.UserId]
if not User then return end
User.StoryProgress = User.StoryProgress + 1
end
local function ReturnStoryProgress(player)
local User = PlayerData[player.UserId]
if not User then return end
return User.StoryProgress
end
UpdateStoryProgress.OnServerEvent:Connect(Update)
StoryProgress.OnServerInvoke = ReturnStoryProgress
EDIT having written this, just realised a problem that could occur with this. Exploiters can fire RemoteEvents, correct? And thus, they could just constantly fire the UpdateStoryProgress
event, and get to the end story instantly. How can I prevent this? There is no real way to do sanity checks on the server 