Hey there guys, I'm kinda new to dev quest and I could need some help for setting autoloot_expire from account table to new players. This is what I got:
quest autoloot_expire_set begin
state start begin
when login begin
-- Retrieve the account ID of the current player
local account_id = pc.get_account_id()
syschat(string.format("Account ID: %d", account_id))
-- Check if autoloot_expire is already set
local query = string.format(
"SELECT autoloot_expire FROM account.account WHERE id = %d;",
account_id
)
local affected_rows, result = mysql_direct_query(query)
if affected_rows > 0 and result[1] and result[1].autoloot_expire ~= "0000-00-00 00:00:00" then
return -- Exit if autoloot_expire is already set
end
-- Set the expiration date to 2026-01-01 00:00:00
local expire_date = "2026-01-01 00:00:00"
local update_query = string.format(
"UPDATE account.account SET autoloot_expire = '%s' WHERE id = %d;",
expire_date,
account_id
)
-- Execute the update query
local update_affected_rows, update_result = mysql_direct_query(update_query)
-- Debugging output to verify changes
syschat(string.format("Rows affected: %d", update_affected_rows))
if not update_affected_rows or update_affected_rows == 0 then
syschat("Error: Update query did not affect any rows.")
else
syschat("Autoloot expiration successfully set.")
end
-- Inform the player
say("You have received autoloot until January 1, 2026.")
-- Mark the quest as complete
set_state(_COMPLETE_)
end
end
state _COMPLETE_ begin
end
end
regards