Jump to content

DELETE mapinterims with a command


koragg

Recommended Posts

Hey everyone, I need a bit of help with deleting the delay time from top1 on a map shown by the race_delay_indicator with a simple command. I tried putting this in the 'delayindicator_server.lua' file but it said that 'allCpTimes' is nil or something.

function deleteTimeDelay(player)
    local accName = getAccountName(getPlayerAccount(player))
    if isObjectInACLGroup("user."..accName, aclGetGroup("Admin")) or isObjectInACLGroup("user."..accName, aclGetGroup("SuperModerator")) then
        local sql = executeSQLQuery("SELECT * FROM mapinterims WHERE mapname = ?", mapName)
        local interims = table.concat(allCpTimes[source], ",")
        if #sql > 0 then
            executeSQLQuery("DELETE FROM mapinterims WHERE interims=?", interims)
        end
    end
end
addCommandHandler("deletedelay", deleteTimeDelay)

Can someone edit that^ function so that when I do the command the top1 delay time would get deleted? MySQL is really confusing to me and I'm kind of scared to try things as I may completely bug my server if I don't know what I'm doing :P So, please, someone help :D

Link to comment

Nevermind, my first approach was totally wrong. I fixed it with the code below, just had to see how it was deleted in another function in that resource.

function deleteTimeDelay(player)
	local currentMap = exports.mapmanager:getRunningGamemodeMap()
	local mapName = getResourceName(currentMap)
	local sql = executeSQLQuery("SELECT * FROM mapinterims WHERE mapname = ?", mapName)
    local accName = getAccountName(getPlayerAccount(player))
    if isObjectInACLGroup("user."..accName, aclGetGroup("Admin")) or isObjectInACLGroup("user."..accName, aclGetGroup("SuperModerator")) then
        if #sql > 0 then
			executeSQLQuery("DELETE FROM mapinterims WHERE mapname=?", mapName)
			outputServerLog("Delay time for "..mapName.." deleted!")
        end
    end
end
addCommandHandler("deletedelay", deleteTimeDelay)

Guess MySQL isn't that hard after all :D

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...