Last active
May 17, 2024 10:37
-
-
Save aimbot6120/65f7492525ca70876b13717196787dd9 to your computer and use it in GitHub Desktop.
Quest generation script for eclipse time. More at xgaming.club
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local ReplicatedStorage = game:GetService("ReplicatedStorage") | |
local HttpService = game:GetService("HttpService") | |
local apiEvent = ReplicatedStorage:WaitForChild("api_event") | |
local function callQuestGeneratorAPI() | |
local url = "https://authdev.xgaming.club/xquest/generate" | |
local data = | |
{ | |
goal = "Player crash landed near a cave and needs to learn to hunt", | |
key = "6mgxg5y2", | |
fields = { | |
"noun", | |
"verb" | |
}, | |
n = 1, | |
story = "The player crash landed on Zeloria, a mining plant abandoned long ago due to uncontrolled mutations of its flora and fauna. Thalion was a miner who was abandoned and is now a fierce hunter. Thalion says " | |
} | |
local jsonData = HttpService:JSONEncode(data) | |
print("Loaidng Quest") | |
local headers = { | |
["Content-Type"] = "application/json" | |
} | |
local response = HttpService:RequestAsync({ | |
Url = url, | |
Method = "POST", | |
Headers = headers, | |
Body = jsonData | |
}) | |
if response.Success then | |
local responseBody = HttpService:JSONDecode(response.Body) | |
print(responseBody) | |
return responseBody | |
else | |
warn("Failed to call API: " .. response.StatusCode .. " - " .. response.StatusMessage) | |
return nil | |
end | |
end | |
local function handleRequestFromClient(player) | |
local questDetails = callQuestGeneratorAPI() | |
if questDetails then | |
apiEvent:FireClient(player,questDetails) | |
end | |
end | |
apiEvent.OnServerEvent:Connect(handleRequestFromClient) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment