We can add items or licenses to player using our system instead of reinventing the wheel.
You need to paste the function into the onResult function, specifically in the data.result == "passed", like this:
config.lua
...
OnResult = function(data)
-- Data contains the following values:
-- id (number) - quiz id
-- percent (number) - percentage of correct answers
-- result (string) - result (passed/failed)
-- EXAMPLE:
if data.result == "passed" then
-- PASTE THE FUNCTION HERE! <---
else
print("You failed the quiz!")
print(data.percent .. " % of your answers were correct!")
end
end,
},
Give Item
We don't want hacker to be able to give themselves an item so we created a feature to whitelist certain items and assign an unique id to them.
item_list.lua
ItemList = {
[1] = {
itemName = "exampleItem",
maxAmount = 1, -- Maximum amount of the item that can be given on each use
},
[2] = {
itemName = "drivingLicense",
maxAmount = 1, -- Maximum amount of the item that can be given on each use
},
-- 3 and so on. Dont forget to add a comma after each item
}
We can add as much items as we want, but make sure the ids are not same.
Value
Explanation
itemName
name of the item that will be given to the players inventory
maxAmount
maximum amount of items added on each exam pass
Now we just need to add our function to the config
config.lua
OnResult = function(data)
-- Data contains the following values:
-- id (number) - quiz id
-- percent (number) - percentage of correct answers
-- result (string) - result (passed/failed)
-- EXAMPLE:
if data.result == "passed" then
local itemId = 1 -- The id in the item_list.lua
local amount = 1 -- amount given to the player. Don't forget about the limits you specified in the item_list.lua
else
print("You failed the quiz!")
print(data.percent .. " % of your answers were correct!")
end
end,
Give license
config.lua
OnResult = function(data)
-- Data contains the following values:
-- id (number) - quiz id
-- percent (number) - percentage of correct answers
-- result (string) - result (passed/failed)
-- EXAMPLE:
if data.result == "passed" then
local license = "DMV" -- Which license you want to add
Basics.AddLicense(license) -- <-- Add this function
else
print("You failed the quiz!")
print(data.percent .. " % of your answers were correct!")
end
end,