Jump to content

Rockyz

Members
  • Posts

    1,862
  • Joined

  • Days Won

    8

Everything posted by Rockyz

  1. You could use callbacks to avoid that an example from the wiki: local dbConnection = dbConnect("sqlite", "sql.db") function onServerCallback(queryHandler, extraData) local queryResult = dbPoll(queryHandler, 0) print(extraData) if type(queryResult) == "table" then print("queryResult == table") if #queryResult > 0 then print("#queryResult > 0") else print("#queryResult == 0") end else print("queryResult ~= table") end end dbQuery(onServerCallback, {"Extra data :)"}, dbConnection, "SELECT * FROM `Players` WHERE `playerName` = ?", "playerName")
  2. function stringToMS(str) local ms = 0 str = str:lower(); ms = ms + tonumber(str:match("(%d+)%s*s") or "0") * 1000 -- Seconds ms = ms + tonumber(str:match("(%d+)%s*m") or "0") * (1000 * 60) -- Minutes ms = ms + tonumber(str:match("(%d+)%s*h") or "0") * (1000 * 60 * 60) -- Hours ms = ms + tonumber(str:match("(%d+)%s*d") or "0") * (1000 * 60 * 60 * 24) -- Days ms = ms + tonumber(str:match("(%d+)%s*y") or "0") * (1000 * 60 * 60 * 24 * 365) -- Years return ms end
  3. Rockyz

    Scroll label

    Then what about that function guiLabelGetTextHeight(label) local text = guiGetText(label) local height = guiLabelGetFontHeight(label) return ((text:len()-text:gsub("\n", ""):len())*height)+height end I haven't test it tho
  4. Rockyz

    Scroll label

    That might help you guiLabelGetFontHeight
  5. استخدم https://wiki.multitheftauto.com/wiki/Matrix local forwardPosition = player.matrix.position + player.matrix.forward * 2
  6. For better performance, create an element and set it as the parent for the markers instead of adding an event for every single marker. local markersParent = createElement("markersParent") local t = { {2450, -1670, 12}, {2455, -1670, 12}, {2460, -1670, 12} } addEventHandler("onResourceStart", resourceRoot, function() for i = 1, #t do local v = t[i] local marker = createMarker(v[1], v[2], v[3], "cylinder", 2.5, 255, 255, 255) setElementParent(marker, markersParent) end end) addEventHandler("onMarkerHit", markersParent, function(hitElement) if getElementType(hitElement) == "player" then if isPedInVehicle(hitElement) then outputChatBox("Vehicles not allowed.", hitElement) else setElementPosition(hitElement, 2400, -1650, 12) outputChatBox("You're spawned.", hitElement) end end end)
  7. You're getting this error because you've missed a bracket on the end of the db string: CREATE TABLE IF NOT EXISTS `vehicles` (id INT, model INT, x FLOAT, y FLOAT, z FLOAT)
  8. I don't know what are you trying to do, but anyways try to replace the db string with this: CREATE TABLE IF NOT EXISTS `vehicles` (id INT, model INT, x FLOAT, y FLOAT, z FLOAT)
  9. الخطأ غالبا بسبب انك مررت الأرقمنتات في التايمر اخر سطر
  10. تقدر تختصر كل هذا table.insert(table, 1, value)
  11. وين مشكلتك بالضبط واطرح جدول players
  12. كودك مابيسوي اي فرق لان التيبل موجود اصلا وانت حاط IF NOT EXISTS اذا يبي يعدل على التيبل يقدر يمسحه وينشئه مرة ثانية مع الاضافات او ببساطة يستخدم ALTER TABLE
  13. جرب كذا local TiempoPr = getTickCount() addEvent("onPlayerSpray", true) addEventHandler("onPlayerSpray", root, function(rockets) local tick = getTickCount() if (tick - TiempoPr > 5000) then outputChatBox("Player #FFFFFF"..getPlayerName(source).." #FFFFFFhas shot #aacccc["..rockets.." #ffffffrockets in #ffffff"..math.floor((tick - TiempoPr) / 1000).." #ffffffseconds]", root, 255, 255, 255, true) TiempoPr = tick end end)
  14. حاول تعدل اسلوبك اذا تبي احد يساعدك المهم, سويت لك الكود على حسب الي فهمته منك ما جربته local tick = getTickCount() local from, to = test.moveX, 1; addEventHandler("onClientRender", root, function() local currentTick = getTickCount() local progress = (currentTick - tick) / 2000 local position = interpolateBetween(from, 0, 0, to, 0, 0, progress, "Linear") dxDrawText("FOR TESTING A SOMETHING ALPHA 1.0", sX*0.35-position, sY*0.15, 250, 250, tocolor(255, 255, 255, 255), 2.00, "default-build", "left", "center", false) if progress >= 1 then tick = currentTick from, to = to, from end end)
  15. Could you explain what is the problem ?
  16. local multiline = [[... multiline string ... ... ]]
  17. Here you go: characters = {"a", "b", "c"} function test(username) if string.find(username, "["..table.concat(characters, "").."]") then end end
  18. اتوقع هذا الي تبيه, جرب : allowedwps = { [1] = true, [2] = true, [3] = true, [5] = true, [6] = true, [7] = true, [8] = true, } addEventHandler("onClientPlayerWeaponSwitch", root, function(previous_weapon, next_weapon) if getElementData(localPlayer, "nodm") == true then if not allowedwps[next_weapon] then cancelEvent() local current_weapon = (next_weapon+1)%13 while current_weapon ~= next_weapon do if allowedwps[current_weapon] then setPedWeaponSlot(localPlayer, current_weapon) break end current_weapon = (current_weapon+1)%13 end end end end)
  19. function replaceText() local text = guiGetText(source) local replacedText = text:gsub("[^A-Za-z0-9%._@]", "") if text ~= replacedText then guiSetText(source, replacedText) end end addEventHandler("onClientGUIChanged", login_edit, replaceText, false)
  20. getTickCount interpolateBetween
  21. Which code were you using, maybe you used the first code that I gave you not the second.
  22. Sorry, I missed up a little bit on the previous code and I didn't notice. Use this code instead : addEventHandler("onResourceStart", resourceRoot, function() local accounts = getAccounts() local accountsList = {} for index = 1, #statsList do accountsList[statsList[index][1]] = {} end for index = 1, #accounts do local account = accounts[index] for index = 1, #statsList do local key = statsList[index][1] local data = exports["ZA-account"]:getAccountData(account, key) local name = exports["ZA-account"]:getAccountData(account, "nick") if tonumber(data) then table.insert(accountsList[key], {name, tonumber(data)}) end end end for index = 1, #statsList do local accountsCount = #accountsList[statsList[index][1]] local accounts = {} if accountsCount >= 1 then table.sort(accountsList[statsList[index][1]], function(a, b) return a[2] > b[2] end) accounts = {unpack(accountsList[statsList[index][1]], 1, math.min(20, accountsCount))} end statsList[index][4] = accounts end end)
  23. addEventHandler("onResourceStart", resourceRoot, function() local accounts = getAccounts() local accountsList = {} local keys = {} for index = 1, #statsList do accountsList[statsList[index][1]] = {} table.insert(keys, statsList[index][1]) end for index = 1, #accounts do local account = accounts[index] local toRemove = {} for index = 1, #keys do local key = keys[index] local data = exports["ZA-account"]:getAccountData(account, key) local name = exports["ZA-account"]:getAccountData(account, "nick") if tonumber(data) then table.insert(accountsList[key], {name, tonumber(data)}) if accountsList[key] >= 20 then table.insert(toRemove, index) end end end for index = 1, #toRemove do table.remove(keys, toRemove[index]) end end for index = 1, #statsList do table.sort(accountsList[statsList[index][1]], function(a, b) return a[2] > b[2] end) statsList[index][4] = accountsList[statsList[index][1]] end end)
×
×
  • Create New...