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:
Lua
x
function Debug(text) if Config.Debug then print("^3[DEBUG] "..text.."^0") endendfunction DebugSQL(text) if Config.DebugSQL then print("^5[DEBUG SQL] "..text.."^0") endendSQL Execution Function
Executes SQL queries based on the configured database:
Lua
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") endendCode Activation Function
Handles the activation of codes by players:
Lua
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)endReward Handling Function
Distributes rewards to players based on the activated code:
Lua
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) endendDiscord Webhook Handling Function
This feature is very good for logging. Feel free to use it everywhere you like.
Lua
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' }) endendType to search, ESC to discard
Type to search, ESC to discard
Type to search, ESC to discard
Last updated on
Was this page helpful?
Next to read:
Domas_RPXPDiscard 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