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! <---elseprint("You failed the quiz!")print(data.percent .." % of your answers were correct!")endend, },
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.
Now we just need to add our function to the config
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" thenlocal license ="DMV" -- Which license you want to add Basics.AddLicense(license) -- <-- Add this functionelseprint("You failed the quiz!")print(data.percent .." % of your answers were correct!")endend,
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" thenlocal 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
elseprint("You failed the quiz!")print(data.percent .." % of your answers were correct!")endend,
itemName
name of the item that will be given to the players inventory