JuniorMelo Posted June 11, 2013 Share Posted June 11, 2013 Can anyone identify this error ?? TopTimes_Server g_MapName = "-" function loadTimes(map) local tts = {} local query = dbQuery(ttHandler,"SELECT * FROM `toptimes` WHERE `mapname` = '"..tostring(map).."' LIMIT 0,1;") if query then local result, row = dbPoll(query,-1) if result and row > 0 then for id, res in ipairs(result) do --outputChatBox("Works till here") tts = fromJSON(res['toptimes']) end end end dbFree(query) return tts end function saveTimes(time,map) local query = dbQuery(ttHandler,"SELECT * FROM `toptimes` WHERE `mapname` = '"..tostring(map).."'") local result = dbPoll( query, 10 ) if query and #result > 0 then outputDebugString("Succesfully Loaded TopTime") local exec = dbQuery(ttHandler,"UPDATE `toptimes` SET `toptimes` = '"..toJSON(time).."' WHERE `mapname` = '"..tostring(map).."'") if exec ~= false then outputDebugString("Updating Toptimes for '"..tostring(map)) end else local querryb = dbQuery(ttHandler, "INSERT INTO toptimes (mapname,toptimes) VALUES (?,?)", tostring(map),toJSON(time)) local resulbt = dbPoll( querryb, 10 ) if resulbt ~= false then outputDebugString("Added Toptimes for '"..tostring(map)) end end dbFree(query) end function sortToptimes(tabl) local oldT = tabl[12] table.sort(tabl, function(a,b) return a.time < b.time end) local newT = tabl[12] triggerClientEvent(root,"updateToptimesTable",root,tabl) return tabl end function addNewToptime(ttable, accname, ttime, date, country) for i,v in ipairs(ttable) do if v.name == accname then if v.time > ttime then if v.date and v.country then v.time = ttime v.date = date v.country = country sortToptimes(ttable) return true end end return false end end local playertable = {} playertable.name = accname playertable.time = ttime playertable.date = date playertable.country = country ttable[#ttable+1] = playertable sortToptimes(ttable) return true end function getPlayerTopTime(tts, player) for id, v in ipairs(tts) do if v.name == getPlayerName(player) then local rtts = {} rtts.name = v.name rtts.i = id rtts.time = msToTimeStr(v.time) return rtts end end end gToptimes = false addEvent("onMapStarting") addEventHandler("onMapStarting", root, function(mapInfo) local OldMap = g_MapName if OldMap ~= mapInfo.name then if gToptimes ~= false then --outputChatBox(#gToptimes) saveTimes(gToptimes,g_MapName) end gToptimes = false end g_MapName = mapInfo.name if string.find(mapInfo.name,"[DM]") or string.find(mapInfo.name,"race-[DM]") then for id, player in ipairs(getElementsByType("player")) do if OldMap ~= mapInfo.name then gToptimes = loadTimes(g_MapName) triggerClientEvent(player,"doSendClientToptimes",root,player,gToptimes,g_MapName) end end end end) addEvent("onPlayerPickUpRacePickup") addEventHandler("onPlayerPickUpRacePickup",root,function(id,sort,model) if sort == "vehiclechange" then if (model == 425) then --if (getElementModel(getPedOccupiedVehicle(source))~= 425 ) then local time = exports['race']:getTimePassed() local name = getPlayerNametagText(source) local t = getRealTime() local ct --outputChatBox(time) local date = t.monthday.."."..(t.month+1).."."..(t.year+1900) local country = exports['admin']:getPlayerCountry(source) if country then ct = ':admin/client/images/flags/'..country..'.png' else ct = "N/A" end addNewToptime(gToptimes,name,time,date,ct) local t = getPlayerTopTime(gToptimes,source) outputChatBox("#0087FF[HUNTER] #ffffff"..getPlayerName(source).." #ffffffmade a new toptime #0087FF"..t.time.." #ffffffand got position #0087FF"..t.i, getRootElement(), 255, 255, 255, true) --end end end end) function removeToptime(player, cmd, i) if tonumber(getElementData(player,"team")) >= 3 then if not tonumber(i) or i == nil then outputChatBox("#0087FF[HUNTER] #ffffffThis was not a valid number", player, 255, 255, 255, true) return end i = tonumber(i) if gToptimes[i] then table.remove(gToptimes,i) sortToptimes(gToptimes) outputChatBox("#0087FF[HUNTER] #ffffffYou deleted Toptime 0087FF#"..i, player, 255, 255, 255, true) end end end addCommandHandler("deletetime", removeToptime) addEvent('onLoadedAtClient_tt', true) addEventHandler('onLoadedAtClient_tt', g_Root, function() -- Tell newly joined client current settings clientCall(source,'updateSettings', g_Settings) end ) addEvent('onClientRequestToptimesUpdates', true) addEventHandler('onClientRequestToptimesUpdates', getRootElement(), function( bOn, clientRevision ) g_SToptimesManager:doOnClientRequestToptimesUpdates( source, bOn, clientRevision ) end ) function msToTimeStr(ms) if not ms then return '' end local centiseconds = tostring(math.floor(math.fmod(ms, 1000)/10)) if #centiseconds == 1 then centiseconds = '0' .. centiseconds end local s = math.floor(ms / 1000) local seconds = tostring(math.fmod(s, 60)) if #seconds == 1 then seconds = '0' .. seconds end local minutes = tostring(math.floor(s / 60)) return minutes .. ':' .. seconds .. ':' .. centiseconds end Link to comment
Castillo Posted June 11, 2013 Share Posted June 11, 2013 There's a missing part, the OOP part. Link to comment
JuniorMelo Posted June 11, 2013 Author Share Posted June 11, 2013 There's a missing part, the OOP part. this part ?? toptimes_client function CToptimes:enableToptimeUpdatesFromServer( bOn ) if bOn ~= self.bGettingUpdates then self.bGettingUpdates = bOn triggerServerEvent('onClientRequestToptimesUpdates', g_Me, bOn, self.clientRevision ) end if self.bGettingUpdates and self.listStatus == 'Empty' then self.listStatus = 'Loading' end end Link to comment
JuniorMelo Posted June 11, 2013 Author Share Posted June 11, 2013 No. could show me which part missing ?? Link to comment
denny199 Posted June 11, 2013 Share Posted June 11, 2013 How could he show that part, when you are having the script? LoL 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