Domas Scripts
v1.0
Title
Message
Create new category
What is the title of your new category?
Edit page index title
What is the title of the page index?
Edit category
What is the new title of your category?
Edit link
What is the new title and URL of your link?
How does it work?
Copy Markdown
Open in ChatGPT
Open in Claude
As always, once I release free script, I want you guys to learn something from it, so I try my best to comment everything so you can learn!
Functions 🚀
Debugging Functions
These functions help you print debug messages:
function Debug(text)
if Config.Debug then
print("^3[DEBUG] "..text.."^0")
end
end
function DebugSQL(text)
if Config.DebugSQL then
print("^5[DEBUG SQL] "..text.."^0")
end
end
SQL Execution Function
Executes SQL queries based on the configured database:
function ExecuteSql(query, params, callback)
DebugSQL("Executing SQL query: " .. query)
if Config.Database == "oxmysql" then
if exports.oxmysql then
exports.oxmysql:execute(query, {}, callback)
else
DebugSQL("oxmysql is not exported. Make sure you have it installed.")
end
elseif Config.Database == "mysql-async" then
if MySQL.Async then
MySQL.Async.execute(query, {}, callback)
else
DebugSQL("mysql-async is not available. Make sure you have it installed.")
end
elseif Config.Database == "ghmattimysql" then
if exports.ghmattimysql then
exports.ghmattimysql:execute(query, {}, callback)
else
DebugSQL("ghmattimysql is not exported. Make sure you have it installed.")
end
else
DebugSQL("Invalid database option in Config.Database")
end
end
Code Activation Function
Handles the activation of codes by players:
function ActivateCode(playerId, code)
local query = ("SELECT * FROM Domas_IC_Codes WHERE code = '%s';"):format(code)
local identifier = GetPlayerIdentifierByType(playerId, 'license')
ExecuteSql(query, {}, function(result)
if result[1] then
local codeData = result[1]
local activationQuery = ("SELECT * FROM Domas_IC_Players WHERE player = '%s' AND code = '%s';"):format(identifier, code)
ExecuteSql(activationQuery, {}, function(activationResult)
if not activationResult[1] then
if Config.AllowOnlyOne then
local previousActivationQuery = ("SELECT * FROM Domas_IC_Players WHERE player = '%s';"):format(identifier)
ExecuteSql(previousActivationQuery, {}, function(previousResult)
if not previousResult[1] then
ProcessCodeActivation(playerId, identifier, codeData)
else
Notify(Config.Text['only_one'], playerId)
end
end)
else
ProcessCodeActivation(playerId, identifier, codeData)
end
else
Debug("Code has already been activated by this player.")
Notify(Config.Text['already_used'], playerId)
end
end)
else
Debug("Invalid code.")
Notify(Config.Text['no_code'], playerId)
end
end)
end
Reward Handling Function
Distributes rewards to players based on the activated code:
function HandleReward(code, playerId)
local rewardData = GetRewardByCode(code)
if rewardData then
if rewardData.type == 'money' then
local amount = rewardData.amount
AddMoney(playerId, amount)
elseif rewardData.type == 'item' then
local item = rewardData.item
local amount = rewardData.amount
GiveItem(playerId, item, amount)
elseif rewardData.type == 'null' then
Debug("Null reward - no action needed")
else
Debug("Unknown reward type:", rewardData.type)
end
else
Debug("No reward data found for code:", code)
end
end
Discord Webhook Handling Function
This feature is very good for logging. Feel free to use it everywhere you like.
function Log2Discord(kodas, playerId)
local name = GetPlayerName(playerId)
if Config.DiscordLog then
local embeds = {
{
["title"]= Config.Text['active_new'],
["type"]="rich",
["color"] = 1770588,
["footer"]= {
["text"]= Config.Text['active_text'],
},
["fields"] = {
{
name = Config.Text['active_player']..name,
value = Config.Text['active_code']..kodas,
},
}
}
}
PerformHttpRequest(Config.Webhook, function(err, text, headers) end, 'POST', json.encode({ username = name,embeds = embeds}), { ['Content-Type'] = 'application/json' })
end
end
Last updated on
Was this page helpful?
Next to read:
Domas_RPXPnull
Discard Changes
Do you want to discard your current changes and overwrite with the template?
Archive Synced Block
Message
Create new Template
What is this template's title?
Delete Template
Message