Jump to content

99isme

Members
  • Posts

    16
  • Joined

  • Last visited

Details

  • Location
    Vietnam
  • Occupation
    Student

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

99isme's Achievements

Square

Square (6/54)

0

Reputation

  1. so I got this error when using UDClogging of Noki local stdLogged = 0 local db = exports.UDCsql:getConnection() function adminLog() end function stdLog(plr, type1, action, type2) if (not plr) or (not type1) or (not action) then return nil end if (plr:getType() ~= "player") or (type(type1) ~= "string") or (type(action) ~= "string") then return false end if (not type2) then type2 = "N/A" end end function adminLog(admin, log_) local t = getRealTime().timestamp db:exec("INSERT INTO `adminlog` (`name`, `log_`, `datum`) VALUES (?, ?, ?)", admin, log_, t ) end function new(plr, type1, action, type2) if (not plr or not type1 or not action) then return nil end if (type(type1) ~= "string" or type(action) ~= "string") then return false end if (not type2) then type2 = "N/A" end local name local accname local serial if (plr and isElement(plr) and plr.type == "player") then if (exports.UDCaccounts:isPlayerLoggedIn(plr)) then accname = plr.account.name else accname = "N/A" end name = plr.name serial = plr.serial else name = tostring(plr) accname = "N/A" serial = "N/A" end dbExec(db, "INSERT INTO 'logging' SET name= 0, account= ?, type= ?, type2= ?, tick= ?, action= ?, serial= ?", name, accname, type1, type2, getRealTime{}.timestamp, action, serial ) stdLogged = stdLogged + 1 return true end function outputTotal(reset) if stdLogged ~= 0 then outputDebugString("[UDClogging] Total standard logs inserted in the past 5 minutes: "..stdLogged) end if (reset) then stdLogged = 0 end end setTimer(outputTotal, 60000 * 5, 0, true) addCommandHandler("logged", outputTotal) ------------------- -- Some stuff we need to log ------------------- function logConnections() -- The account will be guest, so we don't need to worry about the query not being successful new(source, "join", "Joined server", source.ip) end addEventHandler("onPlayerJoin", root, logConnections) function logDisconnections(quitType) new(source, "quit", tostring(quitType), source.ip) end addEventHandler("onPlayerQuit", root, logDisconnections) --File end
  2. local db = dbConnect( "mysql", "dbname="..db_name..";host="..host, user, password ) dbExec(db, "CREATE TABLE if not EXISTS 'banking'(id INT NOT NULL PRIMARY KEY AUTO_INCREMENT, name TEXT)") local database_online -- Is banking Database Online? local banking = {} -- 'banking' Database Cache addEvent("onDatabaseLoad", true) -- Triggers when gti database is ready addEvent("onLogDatabaseLoad", true) -- Triggers when log database is ready -- Database Cache ------------------>> addEventHandler("onResourceStart", resourceRoot, function() db = dbConnect( "mysql", "dbname="..db_name..";host="..host, user, password ) local exec = dbExec(db, "CREATE TABLE IF NOT EXISTS 'banking'") local query = dbQuery(cacheDatabase, db, "SELECT * FROM 'banking'") local result, rows, msg = dbPoll(query, 0) end) function cacheDatabase(qh) local result = dbPoll(qh, 0) banking["Console"] = {} for i,row in ipairs(result) do banking[row.name] = {} for column,value in pairs(row) do if (column ~= "id" or column ~= "name") then banking["Console"][column] = true if (value == "true") then value = true end if (value == "false") then value = false end banking[row.name][column] = value end end end database_online = true triggerEvent("onDatabaseLoad", resourceRoot, "banking") end -- Banking Data Exports ------------------------>> function setBankData(account, key, value) if (not database_online) then return false end if (not account or not key) then return false end if (isGuestAccount(account) or type(key) ~= "string") then return false end local account = getAccountName(account) if (type(banking[account]) ~= "table") then banking[account] = {} if (getServerPort() == SERVER_PORT) then dbExec(db, "INSERT INTO `banking`(name) VALUES(?)", account) end end if (banking["Console"][key] == nil) then if (getServerPort() == SERVER_PORT) then dbExec(db, "ALTER TABLE `banking` ADD `??` text", key) end banking["Console"][key] = true end banking[account][key] = value if (getServerPort() == SERVER_PORT) then if (value ~= nil) then dbExec(db, "UPDATE `banking` SET `??`=? WHERE name=?", key, tostring(value), account) else dbExec(db, "UPDATE `banking` SET `??`=NULL WHERE name=?", key, account) end end return true end function getBankData(account, key) if (not database_online) then return end if (not account or not key) then return end if (isGuestAccount(account) or type(key) ~= "string") then return end local account = getAccountName(account) if (banking[account] == nil) then return end if (banking[account][key] == nil or banking[account][key] == "nil") then return end if (key == "pin" or key == "acc_number") then return banking[account][key] end return tonumber(banking[account][key]) or banking[account][key] end addEvent("onAccountDelete") addEventHandler("onAccountDelete", root, function(account) dbExec(db, "DELETE FROM `banking` WHERE name=?", account) banking[account] = nil end) -- Transaction Log ------------------->> local dbLogs = dbConnect( "mysql", "dbname="..db_name..";host="..host, user, password ) function addLogToDatabase(category, timestamp, text, cash, balance, player, account) dbExec(dbLogs, "CREATE TABLE IF NOT EXISTS `log_"..category.."`(id INT NOT NULL AUTO_INCREMENT, timestamp INT, text TEXT, cash INT, balance INT, player TEXT, account TEXT, ip TEXT, serial TEXT, PRIMARY KEY(id))") local serial, ip if (isElement(player)) then serial = getPlayerSerial(player) ip = getPlayerIP(player) player = getPlayerName(player) end dbExec(dbLogs, "INSERT INTO `log_"..category.."`(timestamp, text, cash, balance, player, account, ip, serial) VALUES(?, ?, ?, ?, ?, ?, ?, ?)", timestamp, text, cash, balance, player, account, ip, serial) return true end function getAccountLogs(player, account, data_table, recovery) if (not player or not account or not data_table) then return false end if (data_table ~= "bank" and data_table ~= "cash" and data_table ~= "groupbank") then return false end if ( recovery ) then dbQuery(recoveryCallback, {player, data_table}, dbLogs, "SELECT * FROM `log_"..data_table.."` WHERE `account`=? ORDER BY `timestamp` DESC LIMIT 500", account) else dbQuery(returnDatabase, {player, data_table}, dbLogs, "SELECT * FROM `log_"..data_table.."` WHERE `account`=? ORDER BY `timestamp` DESC LIMIT 250", account) end end function returnDatabase(qh, player, data_table) local result = dbPoll(qh, 0) triggerEvent("onLogDatabaseLoad", player, data_table, result) end addEvent("onAccountDelete") addEventHandler("onAccountDelete", root, function(account) dbExec(dbLogs, "DELETE FROM `log_bank` WHERE account=?", account) dbExec(dbLogs, "DELETE FROM `log_cash` WHERE account=?", account) end) function getDatabaseLogs() return dbLogs end bad arguement #1 ipairs table expected got boolean from the cachedatabase line
  3. function getHourlyRentalCost(vehicle) local payment local _vehicle if isElement(vehicle) then _vehicle = getElementModel(vehicle) else _vehicle = vehicle end payment = math.floor(exports.vehicles:getVehicleCost(_vehicle) / 333) or 0 if (payment > MAX_HR_PAYMENT) then payment = MAX_HR_PAYMENT end return payment end attempt to perform arithmetic on a nil value
  4. I've suggested so many translations on translate.mtasa.com and these still don't get added and how it works? I can't wait to play MTASA in Vietnamese so I hope you guys will help me out.
  5. I'll pay 4$ for this script. Can you make it quick?
  6. I can't script it because I need to spend time studying at school. Can you help me?
  7. Just as the title said above, I want a script that make you can't be moved by explosion (Grenade, satchel, vehicle explosion, RPG, etc... ). I've searched in forum but there is no topics.
  8. Just as the title said above, I want a script that make you can't be moved by explosion (Grenade, satchel, vehicle explosion, RPG, etc... ). I've searched in forum but there is no topics.
  9. I don't know why doesn't it work! Please help me. client function centerWindow (center_window) local screenW, screenH = guiGetScreenSize() local windowW, windowH = guiGetSize(center_window, false) local x, y = (screenW - windowW) /2,(screenH - windowH) /2 guiSetPosition(center_window, x, y, false) end -- local screenX, screenY = guiGetScreenSize() local sound = false local videosData = {} local progress = 0 local musicWindow local isDownloaded = false local streamed = 0 local attempttoplay = 0 local link = "" addEventHandler("onClientResourceStart", resourceRoot, function() musicWindow = guiCreateWindow(0, 0, 615, 490, "Search music", false) musicClose = guiCreateLabel(0, 0, 15, 15, "X", false, musicWindow) centerWindow(musicWindow) guiWindowSetSizable(musicWindow, false) guiSetVisible(musicWindow, false) --showCursor(false) musicSearch = guiCreateEdit(9, 22, 390, 29, "", false, musicWindow) musicSource = guiCreateComboBox(410, 26, 100, 100, "Youtube", false, musicWindow) guiComboBoxAddItem ( musicSource, "Youtube" ) guiComboBoxAddItem ( musicSource, "Soundcloud" ) guiComboBoxAddItem ( musicSource, "vmuzice.com" ) musicButton = guiCreateButton(515, 22, 100, 29, "Search", false, musicWindow) --guiRadioButtonSetSelected(soloCheck,true) musicList = guiCreateGridList(10, 58, 595, 350, false, musicWindow) guiGridListSetSortingEnabled(musicList, false) guiGridListAddColumn(musicList, "Results", 0.7) guiGridListAddColumn(musicList, "Channel", 0.3) guiGridListAddColumn(musicList, "ID", 0.5) guiGridListAddColumn(musicList, "Source", 0.5) local labelID = guiCreateLabel(15, 417, 400, 29, "Play a direct URL here, youtube or mp3 ------------>", false, musicWindow) local hex = "FFFF0000" guiSetProperty(labelID, "TextColours", "tl:"..hex.." tr:"..hex.." bl:"..hex.." br:"..hex) guiSetFont(labelID, "default-bold-small") musicLink = guiCreateEdit(350, 412, 200, 29, "", false, musicWindow) musicPlay = guiCreateButton(555, 412, 50, 29, "➽", false, musicWindow) --musicLoad = guiCreateProgressBar( 9, 450, 515, 30, false, musicWindow) musicResume = guiCreateButton(575, 450, 30, 30, "➤", false, musicWindow) musicPause = guiCreateButton(540, 450, 30, 30, "||", false, musicWindow) guiSetFont(musicResume, "default-bold-small") guiSetFont(musicPause, "default-bold-small") guiSetEnabled(musicResume, false) guiSetEnabled(musicPause, false) function search() if guiGetEnabled(musicButton) then local item = guiComboBoxGetSelected(musicSource) local src = item == -1 and "Youtube" or guiComboBoxGetItemText(musicSource, item) guiSetEnabled(musicButton, false) setTimer(guiSetEnabled, 5000, 1, musicButton, true) triggerServerEvent ( "search:database", localPlayer, guiGetText(musicSearch), src ) end end addEventHandler("onClientGUIClick", musicButton, search, false) addEventHandler("onClientGUIAccepted", musicSearch, search, false) function directPlay() local editText = guiGetText(musicLink) link = editText if string.find(editText, "youtube") then link = "http://www.youtubeinmp3.com/fetch/?video="..editText end if isElement(sound) then stopSound(sound) removeEventHandler("onClientRender", root, updateInfo) end musicInfo = "00:00 - 00:00 | -" guiSetEnabled(musicResume, false) guiSetEnabled(musicPause, false) sound = playSound(link) if isElement(sound) then outputChatBox("Loading song...!") else outputChatBox("ERROR") end end addEventHandler("onClientGUIClick", musicPlay, directPlay, false) addEventHandler("onClientGUIAccepted", musicLink, directPlay, false) function pauseSound() setSoundPaused(sound, true) tickPause = getTickCount() end addEventHandler("onClientGUIClick", musicPause, pauseSound, false) function resumeSound() setSoundPaused(sound, false) tick = tick + (getTickCount()-tickPause) end addEventHandler("onClientGUIClick", musicResume, resumeSound, false) addEventHandler("onClientGUIClick", musicWindow, function(_, _, cx, cy) local x, y = guiGetPosition(source, false) if cx > x + 540 and cx < x + 598 and cy > y + 1 and cy < y + 15 then guiSetVisible(musicWindow, false) showCursor(false) end end , false) end ) local _showCursor = showCursor function showCursor(value) _showCursor(value) guiSetInputEnabled(value) end addCommandHandler("youtube", function(_, arg1) if arg1 == "stop" then if isElement(sound) then stopSound(sound) outputChatBox("Music has been stopped!", 0, 0, 255) end else local value = not guiGetVisible(musicWindow) guiSetVisible(musicWindow, value) showCursor(value) end end) addEventHandler("onClientGUIDoubleClick", root, function() if source == musicList then local row,column = guiGridListGetSelectedItem(musicList) if row ~= -1 then local id = guiGridListGetItemText(musicList, row, 3) local src = guiGridListGetItemText(musicList, row, 4) if src == "vmuzice.com" then link = id elseif src == "Youtube" then link = "http://www.youtubeinmp3.com/fetch/?video=https://www.youtube.com/watch?v="...tostring(ID) elseif src == "Soundcloud" then link = id.."?client_id="..soundcloudkey end if isElement(sound) then stopSound(sound) removeEventHandler("onClientRender", root, updateInfo) end sound = playSound(link) if src == "Youtube" then setClipboard("https://www.youtube.com/watch?v="...tostring(id)) elseif src ~= "Soundcloud" then setClipboard(link) end guiSetEnabled(musicResume, false) guiSetEnabled(musicPause, false) musicInfo = "00:00 - 00:00 | -" progress = 0 songName = guiGridListGetItemText(musicList, row, 1) if isElement(sound) then outputChatBox("Loading song and copied to the clipboard...!", 0, 0, 255) end end end end) addEventHandler("onClientSoundStream", resourceRoot, function(valid, length) if source == sound then if valid then streamed = 0 isDownloaded = false sLength = length tick = getTickCount() addEventHandler("onClientRender", root, updateInfo) outputChatBox("Use '/youtube stop' command to stop listening", 255, 255, 0) songName = songName or getSoundMetaTags(sound)["title"] or "Desconocido" if #songName > 40 then songName = string.sub(songName, 1, 40).."..." end if source == sound then guiSetEnabled(musicResume, true) guiSetEnabled(musicPause, true) end attempttoplay = 0 elseif attempttoplay <= 3 then attempttoplay = attempttoplay + 1 outputChatBox("Can't play that song! Trying again("..tostring(attempttoplay).."/3)..", 255, 0, 0) if isElement(sound) then stopSound(sound) removeEventHandler("onClientRender", root, updateInfo) end playSound(link) else attempttoplay = 0 outputChatBox("Can't play that song!", 255, 0, 0) end end end ) addEventHandler("onClientSoundFinishedDownload", resourceRoot, function(length) if source == sound then isDownloaded = true streamed = length / 1000 outputChatBox("You can now skip forward", 0, 0, 255) end end ) function updateInfo() if isElement(sound) then if not isSoundPaused(sound) then --Tiempo actual local tickNow = getTickCount() local milliseconds = tickNow-tick local sec = (milliseconds / 1000) % 60 ; local min = milliseconds / (1000*60); -- Duracion local secEnd = ( sLength % 60 ) local minEnd = math.floor ( ( sLength % 3600 ) /60 ) --Progress progress = ( (milliseconds/1000)* 510 ) / sLength -- guiProgressBarSetProgress(musicLoad, progress) musicInfo = string.format("%02d:%02d - %02d:%02d", min, sec, minEnd, secEnd).." | "..songName end else musicInfo = "00:00 - 00:00 | -" progress = 0 removeEventHandler("onClientRender", root, updateInfo) guiSetEnabled(musicResume, false) guiSetEnabled(musicPause, false) end end addEventHandler("onClientRender", root, function() local isOpen = guiGetVisible(musicWindow) if isOpen then local gx, gy = guiGetPosition(musicWindow, false) dxDrawRectangle(gx+9, gy+450, 515, 30, tocolor(255, 255, 255, 100), true) local cx, cy = getCursorPosition() cx, cy = cx * screenX, cy * screenY if isElement(sound) and cx > gx + 11.5 and cx < gx + 11.5 + 510 and cy > gy + 452.5 and cy < gy + 452.5 + 26 then --outputChatBox(tostring(cx - ( gx+11.5 ))) local mWidth = cx - ( gx+11.5 ) local width = isDownloaded and mWidth or math.min(mWidth, math.max(progress, ( streamed * 510 )/ sLength)) dxDrawRectangle(gx+11.5, gy+452.5, width, 26, tocolor(255, 255, 255, 200), true) end -- dxDrawRectangle(gx+11.5, gy+452.5, math.min(510, progress), 26, tocolor(255, 0, 0, 200), true) dxDrawText(musicInfo or "00:00 - 00:00 | -", gx*2+515, gy+457, 0, 0, tocolor(0, 0, 0, 255), 1.1, "default-bold", "center", _, false, false, true) dxDrawText("Close[X]", gx+540, gy+2, 0, 0, tocolor(255, 255, 255, 255), 1.1, "default-bold", _, _, false, false, true) end end ) addEventHandler("onClientClick", root, function(button, state, cx, cy) if button == "left" and state == "down" and guiGetVisible(musicWindow) and isElement(sound) then local gx, gy = guiGetPosition(musicWindow, false) if cx > gx + 11.5 and cx < gx + 11.5 + 510 and cy > gy + 452.5 and cy < gy + 452.5 + 26 then local seconds = ( ( cx - (gx + 11.5) ) * sLength ) / 510 local actualTime = getTickCount() - tick local actualSeconds = actualTime/1000 if not isDownloaded then seconds = math.min(seconds, math.max(actualSeconds, streamed)) end local diferencia = ( seconds * 1000 - actualTime ) --if isDownloaded or diferencia < 0 or ( actualSeconds + diferencia / 1000 ) < streamed then setSoundPosition(sound, seconds) tick = tick - diferencia streamed = actualSeconds > streamed and actualSeconds or streamed end end end ) function refreshGrid() guiGridListClear(musicList) for i,v in ipairs(videosData) do local row = guiGridListAddRow(musicList) guiGridListSetItemText(musicList, row, 1, tostring(v[1]), false, false) guiGridListSetItemText(musicList, row, 2, tostring(v[2]), false, false) guiGridListSetItemText(musicList, row, 3, tostring(v[3]), false, false) guiGridListSetItemText(musicList, row, 4, tostring(v[4]), false, false) end end function addTable (data, src, key) src = src or "Youtube" if src == "vmuzice.com" then data = convert(src, data) elseif src == "Soundcloud" then data = convert(src, data) soundcloudkey = key end if not data then outputChatBox("There is no result!", 255, 0, 0) return end videosData = {} data = fromJSON(data) if not data then guiSetEnabled(musicButton, true) return end local subData = data["items"] for i, v in ipairs( subData ) do local title = v["snippet"]["title"] local canal = v["snippet"]["channelTitle"] local videoID = v["id"]["videoId"] table.insert(videosData, {tostring(title), tostring(canal), tostring(videoID), tostring(src)}) end refreshGrid() --if #videosData == 0 then outputChatBox("Ups! No se han encontrado canciones, intenta con otro", 255, 0, 0) --else outputChatBox(videosData[1][1]) end guiSetEnabled(musicButton, true) end addEvent ( "song:sendTable", true ) addEventHandler ( "song:sendTable", root, addTable ) Server local youtubeKey = "AIzaSyCIJgKTiqGrIC3IlQpy1WtuaQV0jQi6bB4" -- Your youtube API Key! local soundcloudKey = "" -- Your soundcloud API Key! See more https://developers.soundcloud.com/ local maxResults = 25 -- How many results do you want? + results = + data to get and send to user = + bandwith function result ( data, errno, source, src, key ) if data and data ~= "ERROR" then triggerLatentClientEvent ( source, "song:sendTable", 40000, false, source, data, src, key ) outputChatBox("LOADING RESULTS...", source, 0, 255, 0) else outputChatBox(tostring(data).." ERRID: "..tostring(errno) or "Unknown", source, 255, 0, 0) end end addEvent ( "search:database", true ) function searchMusic( song, src ) if src == "Youtube" then fetchRemote ( "https://www.googleapis.com/youtube/v3/search?part=snippet&maxResults="..tostring(maxResults).."&order=viewCount&q="..string.gsub(song, " ", "+").."&type=video&videoDefinition=any&key="..youtubeKey, result, "", false, client, src ) elseif src == "Soundcloud" then fetchRemote ( "https://api.soundcloud.com/tracks/?q="..string.gsub(song, " ", "+").."&client_id="..soundcloudKey, result, "", false, client, src, soundcloudKey ) elseif src == "vmuzice.com" then fetchRemote ( "http://vmuzice.com/mp3/"..string.gsub(song, " ", "+"), result, "", false, client, src ) end outputChatBox("SEARCHING...", client, 255, 255, 0) end addEventHandler ( "search:database", root, searchMusic ) utils local function createXMLFile ( xmlData ) local number = 0 -- this loop will terminate on its own once a number is found which has no file with that specific number while ( fileExists (number) ) do -- if a file with this number already exists then number = number + 1 -- increase the number end local xmlName = tostring ( number )..".xml" local hFile = fileCreate( xmlName ) fileWrite(hFile, xmlData ) fileClose(hFile) return xmlName end print = outputChatBox function convert(src, data) if src == "Soundcloud" then local json = fromJSON("["..data.."]") local items = { ["items"] = {} } for i, v in ipairs(json) do table.insert(items["items"], { ["snippet"] = { ["title"] = v["title"], ["channelTitle"] = v["user"]["username"] }, ["id"] = { ["videoId"] = v["stream_url"] } } ) end return toJSON(items) elseif src == "vmuzice.com" then data = utf8.gsub(data, "%s&ndash;%s", "") local _,str2 = string.find(data,"</ul>") if str2 then data = string.sub(data, str2, #data) end --De nuevo local str1 = string.find(data, "<ul>") _,str2 = string.find(data,"</ul>") if not str1 or not str2 then return false end data = string.sub(data, str1, str2) -- local filePath = createXMLFile (data) local xml = xmlLoadFile(filePath) local items = { ["items"] = {} } for _,node in pairs(xmlNodeGetChildren(xml)) do local songName local artist local url local currentAttribute = xmlNodeGetAttribute(node,"class") if currentAttribute == "x-track" then for i, div in pairs(xmlNodeGetChildren(node)) do local child = xmlNodeGetChildren(div) if xmlNodeGetName(child[1]) == "span" then local artistNode = xmlNodeGetChildren(child[1], 0) artist = xmlNodeGetValue(artistNode) xmlDestroyNode(artistNode) songName = xmlNodeGetValue(child[1]) elseif xmlNodeGetName(child[2]) == "a" then url = xmlNodeGetAttribute(child[2],"data-url") end end table.insert(items["items"], { ["snippet"] = { ["title"] = tostring(songName), ["channelTitle"] = tostring(artist) }, ["id"] = { ["videoId"] = tostring(url) } } ) end end xmlUnloadFile(xml) fileDelete(filePath) return toJSON(items) end end Meta <meta> <info author="Zeno" version="2.0.1" type="script" name="Music searcher" /> <script src="utils.lua" type="client"/> <script src="server.lua" type="server" /> <script src="client.lua" type="client" /> </meta>
×
×
  • Create New...