koragg Posted April 14, 2017 Share Posted April 14, 2017 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 So, please, someone help Link to comment
Gordon_G Posted April 14, 2017 Share Posted April 14, 2017 allCpTimes[source] This is not defined in your script, what should it be ? Link to comment
koragg Posted April 14, 2017 Author Share Posted April 14, 2017 15 minutes ago, Gordon_G said: allCpTimes[source] This is not defined in your script, what should it be ? It is defined in the file i mentioned. Can't i use it like that if it's defined and used in other places in the script? Link to comment
Gordon_G Posted April 14, 2017 Share Posted April 14, 2017 It depends when allCpTimes table is defined : print(test) -- print nil test = "try" print(test) -- print try Link to comment
koragg Posted April 15, 2017 Author Share Posted April 15, 2017 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 Link to comment
Gordon_G Posted April 15, 2017 Share Posted April 15, 2017 1 hour ago, koragg said: Guess MySQL isn't that hard after all That's not Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now