-
Posts
1,862 -
Joined
-
Days Won
8
Posts posted by Rockyz
-
-
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
- 1
-
-
13 hours ago, Tekken said:
Not sure as I also need to know how many lines etch label have.
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
-
2 hours ago, Tekken said:
The problem is that I have different size strings so that's a matter of knowing the exact spot, I think I will stay with the memo for now
That might help you
guiLabelGetFontHeight
-
استخدم
https://wiki.multitheftauto.com/wiki/Matrix
local forwardPosition = player.matrix.position + player.matrix.forward * 2
- 1
-
3 hours ago, Tekken said:
Try this one:
local t ={ {2450, -1670, 12}, {2455, -1670, 12}, {2460, -1670, 12} }; local markers = {}; addEventHandler("onResourceStart", reosurceRoot, function() for i,v in pairs(t) do markers[i] = createMarker(v[1], v[2], v[3], "cylinder", 2.5, 255, 255, 255); addEventHandler('onMarkerHit', markers[i], 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); end end);
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)
- 1
-
4 hours ago, amiz said:
vehicles\vehicles.lua:6: dbExec failed; (1) incomplete input
but I still have errors with the new script
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)
- 1
-
11 hours ago, amiz said:
vehicles\vehicles.lua:9: dbExec failed; (1) near "exist": syntax error
outputChatBox("type")function createVehicleForPlayer(player, command, model)local db = exports.db:getdbconnection()local x ,y ,z = getElementPosition(player)y = 5dbExec (db,"Create table if not exist vehicles id int, model int, x float, y float, z float")createVehicle(model, x, y, z)endaddCommandHandler("createvehicle", createVehicleForPlayer, false, false)addCommandHandler("createveh", createVehicleForPlayer, false, false)addCommandHandler("makeveh", createVehicleForPlayer, false, false)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)
-
56 minutes ago, xBeSoOo_ said:
كان فيه شي انا كاتبه غلط , نأسف علي الحشيش
local sounds = { --[["sound download link"]] 'https://g.top4top.io/m_1598i8jrg1.mp3', 'https://a.top4top.io/m_1592i0ypt1.mp3', } local song_N = 1 function onResourceStart() sound = playSound3D(sounds[1], 144.89999, -1939.3, 3.5) timerLen = 1000*getSoundLength(sound) setElementDimension(sound,0) setSoundMaxDistance(sound, 100) end addEventHandler("onClientResourceStart", resourceRoot, onResourceStart) addCommandHandler("sound", function () if isElement(sound) then destroyElement(sound) outputChatBox("تم اقاف الأغاني") end end) function next_s(song_N,sound,timerLen) if isElement(sound) then if song_N ~= #sounds then song_N = song_N +1 sound = playSound3D(sounds[song_N], 144.89999, -1939.3, 3.5) timerLen = 1000*getSoundLength(sound) else song_N = 1 sound = playSound3D(sounds[song_N], 144.89999, -1939.3, 3.5) timerLen = 1000*getSoundLength(sound) end end end setTimer(next_s,timerLen,0,song_N,sound,timerLen)
الخطأ غالبا بسبب انك مررت الأرقمنتات في التايمر اخر سطر
-
10 hours ago, Master_MTA said:
--it's look like table.remove but custom one --يعني انته بتعمل وظيفه جديده في كلاس التيبل اللي موجود من الاول في اللغه الاصليه --بس خاص بيك --for tb table --example inserOnTop can work on all table function table.insertOnTop(ta,value) local t={} table.insert(t,value) for k,v in ipairs(ta)do t[k]=v end return t end
---فنكشن جديد تقدر تستخدمه مع اي تيبل غالبا وهو يحطلك القيمه باول الجدول مب باخره بدال
table.insert
اللي يحط القيمه بنهاية الجدول بالتوفيق
تقدر تختصر كل هذا
table.insert(table, 1, value)
-
وين مشكلتك بالضبط
واطرح جدول players
-
1 hour ago, Sha67 said:
دام الجداول موجودة والمتغير معرًف مسبقاَ, الكود كذا مافيه أي خطأ مع العلم أنك مكرر الأسطر لأي سبب كان...
accountUsername عموماً حسب الصورة اللي أنت حاطها الجدول
بداخله, يعني هيكلة الجدول كالتالي :ء serial مافيه صف بإسم
executeSQLQuery("CREATE TABLE IF NOT EXISTS accountUsername (account TEXT,username TEXT)")
عدله وخليه كذا :
executeSQLQuery("CREATE TABLE IF NOT EXISTS accountUsername (account TEXT,username TEXT, serial TEXT)")
مع التنوية أنك لازم تعدل بعض الأكواد لأنك أضفت صف جديد ويمكن يسبب مشاكل, بس مع كودك إن شاء الله كل شي تمام.
كودك مابيسوي اي فرق لان التيبل موجود اصلا وانت حاط
IF NOT EXISTS
اذا يبي يعدل على التيبل يقدر يمسحه وينشئه مرة ثانية مع الاضافات او ببساطة يستخدم
ALTER TABLE
- 1
-
جرب كذا
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)
- 1
-
On 05/11/2019 at 14:42, xFabel said:
شسالفه مشكله ماحد يقدر يحله صعبه؟
حاول تعدل اسلوبك اذا تبي احد يساعدك
المهم, سويت لك الكود على حسب الي فهمته منك
ما جربته
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)
-
2 hours ago, xXGhostXx said:
Help me
Could you explain what is the problem ?
-
local multiline = [[... multiline string ... ... ]]
-
Here you go:
characters = {"a", "b", "c"} function test(username) if string.find(username, "["..table.concat(characters, "").."]") then end end
-
Use
triggerClientEvent
-
اتوقع هذا الي تبيه, جرب :
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)
-
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)
-
getTickCount interpolateBetween
-
10 hours ago, WASSIm. said:
Hi #,xiRocKyz sorry but your code complicated and is wrong its shows everything wrong on list anyway i fixed it and thank for your help
Which code were you using, maybe you used the first code that I gave you not the second.
-
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)
-
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)
If else not returning value
in Scripting
Posted
You could use callbacks to avoid that
an example from the wiki: