Jump to content

koragg

Members
  • Posts

    731
  • Joined

  • Last visited

  • Days Won

    2

Everything posted by koragg

  1. Here goes. So I wasted ~ 1 hour and did the following things: Cliend-side stuff: visual = { -- Standard Settings, 0 = off -- ["plate"] = string.sub(getPlayerName(localPlayer):gsub('#%x%x%x%x%x%x', ''), 1, 8), } ------------------------------------------------------------------------------------------------------------------------- function visual_ButtonHandler() if source == GUIEditor.button["plate"] then local nr = guiGetText(GUIEditor.edit["plate"]) if not nr then outputChatBox("Please insert a string to use as your licence plate before clicking ok.") return end if nr == nil or nr == "" or nr == " " or nr == " " or nr == " " or nr == " " or nr == " " or nr == " " or nr == " " or nr == " " then outputChatBox("Your licence plate cannot be empty. Changed to default one. ") nr = string.sub(getPlayerName(localPlayer):gsub('#%x%x%x%x%x%x', ''), 1, 8) end local veh = getPedOccupiedVehicle(localPlayer) if veh then if getElementData(localPlayer, "LoggedIn") ~= true then outputChatBox("You need to register and login in order to set a custom licence plate!", 255, 153, 0, true) return end setVehiclePlateText(veh, nr) setElementData(localPlayer, "savedPlate", nr) setElementData(localPlayer, "plate", nr) visual["plate"] = nr v_setSaveTimer() end end end end addEventHandler("onClientGUIClick", resourceRoot, visual_ButtonHandler) ------------------------------------------------------------------------------------------------------------------------- function visual_LoadSettings() for w, c in pairs(visual) do -- Move settings to visual table -- local theChild = xmlFindChild( v_loadXML, w, 0 ) if not theChild then local theChild = xmlCreateChild( v_loadXML, w ) xmlNodeSetValue( theChild, c ) end if w ~= "nitrocolor" and w ~= "plate" then -- nitrocolor is not a number value local val = xmlNodeGetValue( theChild ) visual[w] = tonumber(val) else local val = xmlNodeGetValue( theChild ) visual[w] = val end if w == "plate" then local veh = getPedOccupiedVehicle(localPlayer) setElementData(localPlayer, "savedPlate", c) setElementData(localPlayer, "plate", c) local pltTxt = c if getElementData(localPlayer, "LoggedIn") ~= true then pltTxt = string.sub(getPlayerName(localPlayer):gsub('#%x%x%x%x%x%x', ''), 1, 8) end if veh then setVehiclePlateText(veh, pltTxt) end end end setVisualGUI() end addEventHandler("onClientResourceStart", resourceRoot, visual_LoadSettings) ------------------------------------------------------------------------------------------------------------------------- addEvent("changePlateOnLogout", true) function changePlateOnLogout(veh, pltTxt) if veh and pltTxt then setVehiclePlateText(veh, pltTxt) end end addEventHandler("changePlateOnLogout", root, changePlateOnLogout) ------------------------------------------------------------------------------------------------------------------------- addEvent("changePlateOnLogin", true) function changePlateOnLogin(veh, pltTxt) if veh and pltTxt then setVehiclePlateText(veh, pltTxt) end end addEventHandler("changePlateOnLogin", root, changePlateOnLogin) ------------------------------------------------------------------------------------------------------------------------- addEvent("changePlateOnNickChange", true) function changePlateOnNickChange(veh, pltTxt) if veh and pltTxt then setVehiclePlateText(veh, pltTxt) end end addEventHandler("changePlateOnNickChange", root, changePlateOnNickChange) ------------------------------------------------------------------------------------------------------------------------- function setVisualGUI() for f, u in pairs(visual) do if f == "plate" then if u ~= nil or u ~= "" or u ~= " " or u ~= " " or u ~= " " or u ~= " " or u ~= " " or u ~= " " or u ~= " " or u ~= " " then guiSetText(GUIEditor.edit["plate"], u) local veh = getPedOccupiedVehicle(localPlayer) if veh then if getElementData(localPlayer, "LoggedIn") ~= true then outputChatBox("You need to register and login in order to set a custom licence plate!", 255, 153, 0, true) return end setVehiclePlateText(veh, u) setElementData(localPlayer, "savedPlate", u) setElementData(localPlayer, "plate", u) visual["plate"] = u end else local plate local veh = getPedOccupiedVehicle(localPlayer) if veh then plate = getVehiclePlateText(veh) end if plate then guiSetText(GUIEditor.edit["plate"], plate) end end end end end Server-side stuff: addEvent("onMapStarting", true) function setLicencePlate() setTimer(function() for k,v in ipairs(getElementsByType("player")) do local account = getPlayerAccount(v) if account and isGuestAccount(account) then return end local veh = getPedOccupiedVehicle(v) local plateText = getElementData(v, "plate") if veh and plateText and plateText ~= nil then setVehiclePlateText(veh, plateText) end end end, 50, 1) end addEventHandler("onMapStarting", root, setLicencePlate) addEventHandler("onPlayerSpawn", root, setLicencePlate) addEventHandler("onPlayerJoin", root, setLicencePlate) ------------------------------------------------------------------------------------------------------------------------- function onPlayerLogout() local vehicle = getPedOccupiedVehicle(source) local newPlate = string.sub(getPlayerName(source):gsub('#%x%x%x%x%x%x', ''), 1, 8) triggerClientEvent(root, "changePlateOnLogout", source, vehicle, newPlate) end addEventHandler("onPlayerLogout", root, onPlayerLogout) ------------------------------------------------------------------------------------------------------------------------- function onPlayerLogin() local newPlate local vehicle = getPedOccupiedVehicle(source) local savedPlate = getElementData(source, "savedPlate") if savedPlate then newPlate = string.sub(savedPlate:gsub('#%x%x%x%x%x%x', ''), 1, 8) else newPlate = string.sub(getPlayerName(source):gsub('#%x%x%x%x%x%x', ''), 1, 8) end triggerClientEvent(root, "changePlateOnLogin", source, vehicle, newPlate) end addEventHandler("onPlayerLogin", root, onPlayerLogin) ------------------------------------------------------------------------------------------------------------------------- function onPlayerChangeNick(oldNick, newNick) local account = getPlayerAccount(source) local savedPlate = getElementData(source, "savedPlate") if savedPlate and account and not isGuestAccount(account) then return end local vehicle = getPedOccupiedVehicle(source) local newPlate = string.sub(newNick:gsub('#%x%x%x%x%x%x', ''), 1, 8) triggerClientEvent(root, "changePlateOnNickChange", source, vehicle, newPlate) end addEventHandler("onPlayerChangeNick", root, onPlayerChangeNick) ------------------------------------------------------------------------------------------------------------------------- function onPlayerLogin() local playeraccount = getPlayerAccount(source) if playeraccount then if not isGuestAccount(playeraccount) then setElementData(source, "LoggedIn", true) else setElementData(source, "LoggedIn", false) end end end addEventHandler("onPlayerLogin", root, onPlayerLogin) Obviosly this is just the part for the plates (there is a :~load of code for other settings in the resource). For me - it works. No bugs, no problems. But would it be synced to all other players is my question? Like, when I change my licence plate to a custom one from the GUI, would a player next to me or spectating me see the updated custom plate? If anyone can take a look at the above lines and tell me, I'd appreciate it.
  2. Bummer, that's what I thought too. Will be harder to sync than I though
  3. I found this function on the wiki and my question is: If I set my licence plate client-side from a GUI text box, would it show updated for other players spectating me or not? https://wiki.multitheftauto.com/wiki/SetVehiclePlateText
  4. I may be wrong but I've never seen triggerServerEvent be used like this, assigned to a variable.
  5. He gave another line as the error to me
  6. OK, first of all, you misspelled "getPlayerMaxAviableSlots()". Should be "getPlayerMaxAvailableSlots()" Try this: if itemName and (getPlayerCurrentSlots() + getItemSlots(itemName) <= getPlayerMaxAviableSlots()) then local col = getElementData(getLocalPlayer(), "currentCol") if #getElementsWithinColShape(col, "player") > 1 or getNetworkStats().packetlossLastSecond > 1 then return end end
  7. setElementDoubleSided(road1, true)
  8. Also the final value can be negative as well sometimes so don't worry about it
  9. Negative results are fine because you still have calculations left. What you did is correct, you just need to continue until the only thing left between the commas are numbers and nothing else.
  10. For duck's sake, this will take me days to edit ._. But I can explain what you have to do So, here goes: You have this at top: local sX,sY = guiGetScreenSize() Then you have something like this a looot of times: dxDrawImage(loginX+sX*0.02-375,loginY+sY*0.275+100,sX*0.05,sY*0.04,"loginImage/switchBackground.png",0,0,0,tocolor(255,255,255,loginData.loginAlpha)) Every variable has a number value. So for example, the value of 'loginX' is 'sX*0.6'. But the value of 'sX' is 1366 since that's your X resolution. So it will look like this: loginX = 1366*0.6 which is same as loginX = 819.6 You just need to replace all words with their values so it will become so much easier to understand everything (it's so for me atleast). So now you need to make the 'loginX' be same on all resolutions. Make like this: local sX, sY = guiGetScreenSize() local x, y = sX/1366, sY/768 and now 'loginX' will look like this: loginX = 819.6*x You need to convert everything like this to fit it on any resolution. I never liked working with words/variables instead of the actual values so for me replacing each variable with it's (calculated) number value is much easier. Good luck and be prepared to waste a lot of time on this since your script has so many variables in the dxText lmao. Pro Tip: If you're tired - stop, play MTA, watch a movie, do something else. When we're tired we make silly mistakes which are (in your case) really hard to spot afterwards as there is a lot of code. Better fix it for a few weeks but not have problems than to fix it for 3 days and be full of errors that are super hard to trace. That line I used as example will look like this: local sX, sY = guiGetScreenSize() local x, y = sX/1366, sY/768 dxDrawImage(471.92*x, 503.2*y, 68.3*x, 30.72*y, "loginImage/switchBackground.png", 0, 0, 0, tocolor(255, 255, 255, loginData.loginAlpha))
  11. There's nothing wrong in using and editing other servers' scripts. If you found them on the Internet that's not stealing, it's using. You don't take any credit for them but are just having fun. What someone said above me is correct though: we won't help with leaked scripts (but everybody knows a guy who knows a guy whose cousin's sister's boyfriend knows lua ). Using them is not a crime, telling others that you made them is.
  12. There're a few variables that seem undefined. Can you post the complete script? Things like 'loginData' and 'sX' I don't know from where they come and can't be sure what they do.
  13. Ah i see. I'll give you some code in a few hours. Just tell me on what resolution did you make it look perfect.
  14. I think my way is a bit easier, 2nd reply:
  15. Anytime Once you have the things in the places you want them to be you'll need to make it look good on any screen resolution but that's a bit tricky so you could post your code and I'll do it for you. If there are animations in the login panel that's another thing though
  16. Try to fix it yourself the following way: Everywhere where you see a line similar to dxDrawText("Login",loginX+shadowScale,loginY+shadowScale,loginX+sX*0.2,loginY+sY*0.15,tocolor(0,0,0,loginData.loginAlpha),loginData.fontScale*0.25,loginData.font,"right","center",true,false,false) try to add or withdraw some numbers until you have the text/image in the correct position. So for example in the above line try to make it like this: dxDrawText("Login",loginX+shadowScale+200, loginY+shadowScale+300, loginX+sX*0.2+150, loginY+sY*0.15+250, tocolor(0, 0, 0, loginData.loginAlpha), loginData.fontScale*0.25, loginData.font, "right", "center", true, false, false) As you see I added some numbers (+200, etc.) to each value and this way the text or image will move somewhere else on the screen. Try to play around with it like that until you find the sweat spot for the buttons and text. One thing to remember is: First value after the "Login" string is the X coordinate of the text on the screen (left or right). The value after the X one is the Y value (up or down). The 3rd value is the X coordinate of the text's boundarybox and the 4th value is the Y coordinate of the boundarybox. Now, what's a boundary box? Well let's just say that if the boundary box of the text is too small on the X side (left or right) then the text will move to a new line when it reaches the end of the boundary box. Example: if the boundary box is too small the text won't show as "Login" on a single line but instead on the first line it will be "Log" and the "in" part will be moved to another line. Here's some really useful descriptions that will help you understand things better. And remember, play around and you'll get the hang of it https://wiki.multitheftauto.com/wiki/DxDrawText https://wiki.multitheftauto.com/wiki/DxDrawImage
  17. Should really stop editing scripts at 3am The next day i always fix it heh
  18. Fixed addEvent('onMapStarting', true) function onNewMapStart() local map = g_Map if map == exports.mapmanager:getRunningGamemodeMap() then return end local mapName = getResourceInfo(map, "name") local resourceName = getResourceName(map) -- Delete map's ghost file if fileExists(":raceghost/ghosts/"..resourceName..".ghost") then fileDelete(":raceghost/ghosts/"..resourceName..".ghost") outputServerLog("Ghost record for "..resourceName.." deleted!") end -- Delete map's delay time local sql = executeSQLQuery("SELECT * FROM mapinterims WHERE mapname = ?", resourceName) if #sql > 0 then executeSQLQuery("DELETE FROM mapinterims WHERE mapname=?", resourceName) outputServerLog("Delay time for "..resourceName.." deleted!") end -- Delete map's toptimes local map_name = {} local mode = 'Sprint' map_name['race maptimes '..mode..' ' .. (getResourceInfo(map, 'name' ) or getResourceName(map))] = map local map_table = executeSQLQuery("SELECT tbl_name FROM sqlite_master WHERE tbl_name LIKE 'race maptimes %' ") for k, v in ipairs(map_table) do local mapTable = v.tbl_name if map_name[mapTable] then local mapTimes = executeSQLQuery("SELECT playerName FROM ?", mapTable) for i, t in ipairs(mapTimes) do executeSQLQuery("DELETE FROM ? WHERE playerName=?", mapTable, t.playerName) end end end local deleteMap = deleteResource(resourceName) if not deleteMap then outputChatBox("Error: Map cannot be deleted.", g_P, 255, 255, 255, true) canUseCommand = true g_Map = nil g_P = nil removeEventHandler('onMapStarting', root, onNewMapStart) return end outputChatBox("#00FFFFMap '#00FF00"..mapName.."#00FFFF' deleted by #FFFFFF"..addTeamColor(g_P).."#00FFFF!", root, 255, 255, 255, true) exports.IRC:outputIRC("Map '"..mapName.."' deleted by "..addTeamColor(g_P):gsub('#%x%x%x%x%x%x', '').."!") refreshResources() local mapscenter = getResourceFromName("mapscenter") if mapscenter then if getResourceState(mapscenter) == "running" then triggerEvent("updateMaps", root, true) end end local maptops = getResourceFromName("maptops") if maptops then if getResourceState(maptops) == "running" then restartResource(maptops, true) end end local cwmanagersmapspanel = getResourceFromName("clanwarmanagersmapspanel") if cwmanagersmapspanel then if getResourceState(cwmanagersmapspanel) == "running" then triggerEvent("updateCWManagersMaps", root, true) end end local modsmapspanel = getResourceFromName("moderatorsmapspanel") if modsmapspanel then if getResourceState(modsmapspanel) == "running" then triggerEvent("updateModsMaps", root, true) end end refreshResources() canUseCommand = true g_Map = nil g_P = nil removeEventHandler('onMapStarting', root, onNewMapStart) end ------------------------------------------------------------------------------------------------------------------------- canUseCommand = true g_Map = nil g_P = nil ------------------------------------------------------------------------------------------------------------------------- function delmap(p) local playeraccount = getPlayerAccount (p) local accountname = getAccountName(playeraccount) if isGuestAccount(playeraccount) then return end if isObjectInACLGroup ("user." .. accountname, aclGetGroup("Admin")) or isObjectInACLGroup ("user." .. accountname, aclGetGroup("MapManagers")) then if not canUseCommand then outputChatBox("Error: Cannot use command. An admin has already deleted this map.", p, 255, 255, 255, true) return end local map = exports.mapmanager:getRunningGamemodeMap() if not map then outputChatBox("Error: No map is currently running.", p, 255, 255, 255, true) return end outputChatBox("Deleting current map at the start of next one!", root, 255, 0, 0, true) g_Map = map g_P = p addEventHandler('onMapStarting', root, onNewMapStart) canUseCommand = false end end addCommandHandler('deletemap', delmap) ------------------------------------------------------------------------------------------------------------------------- function addTeamColor(player) local playerTeam = getPlayerTeam ( player ) if ( playerTeam ) then local r,g,b = getTeamColor ( playerTeam ) local n1 = toHex(r) local n2 = toHex(g) local n3 = toHex(b) if r <= 16 then n1 = "0"..n1 end if g <= 16 then n2 = "0"..n2 end if b <= 16 then n3 = "0"..n3 end return "#"..n1..""..n2..""..n3..""..getPlayerNametagText(player) else return getPlayerNametagText(player) end end ------------------------------------------------------------------------------------------------------------------------- function toHex(n) local hexnums = {"0","1","2","3","4","5","6","7", "8","9","A","B","C","D","E","F"} local str,r = "",n%16 if n-r == 0 then str = hexnums[r+1] else str = toHex((n-r)/16)..hexnums[r+1] end return str end Lines 20-33
  19. I don't know how to view SQL tables
  20. Hello, I have a little problem. I want when I type /deletemap everything connected to it to be deleted along with it (ghosts, delays, tops). But I get an error when it tries to delete the map's toptimes. Error is this: Database query failed: no such table: 'race maptimes Sprint LS Tour'. How can I fix this? I want all of the map's toptimes to get deleted alongside all the other things. Here's full code: addEvent('onMapStarting', true) function onNewMapStart() local map = g_Map if map == exports.mapmanager:getRunningGamemodeMap() then return end local mapName = getResourceInfo(map, "name") local resourceName = getResourceName(map) if fileExists(":raceghost/ghosts/"..resourceName..".ghost") then fileDelete(":raceghost/ghosts/"..resourceName..".ghost") outputServerLog("Ghost record for "..resourceName.." deleted!") end local sql = executeSQLQuery("SELECT * FROM mapinterims WHERE mapname = ?", resourceName) if #sql > 0 then executeSQLQuery("DELETE FROM mapinterims WHERE mapname=?", resourceName) outputServerLog("Delay time for "..resourceName.." deleted!") end local topsTable = getModeAndMap('Sprint', mapName) local topsSql = executeSQLQuery('SELECT playerName AS topName FROM '..qsafetablename(topsTable)) if type(topsSql) == 'table' and #topsSql > 0 then executeSQLQuery("DELETE FROM ? WHERE mapname=?", qsafetablename(topsTable), resourceName) end local deleteMap = deleteResource(resourceName) if not deleteMap then outputChatBox("Error: Map cannot be deleted.", g_P, 255, 255, 255, true) canUseCommand = true g_Map = nil g_P = nil removeEventHandler('onMapStarting', root, onNewMapStart) return end outputChatBox("#00FFFFMap '#00FF00"..mapName.."#00FFFF' deleted by #FFFFFF"..addTeamColor(g_P).."#00FFFF!", root, 255, 255, 255, true) exports.IRC:outputIRC("Map '"..mapName.."' deleted by "..addTeamColor(g_P):gsub('#%x%x%x%x%x%x', '').."!") refreshResources() local mapscenter = getResourceFromName("mapscenter") if getResourceState(mapscenter) == "running" then restartResource(mapscenter) end local maptops = getResourceFromName("maptops") if getResourceState(maptops) == "running" then restartResource(maptops) end local cwmanagersmapspanel = getResourceFromName("clanwarmanagersmapspanel") if getResourceState(cwmanagersmapspanel) == "running" then restartResource(cwmanagersmapspanel) end local moderatorsmapspanel = getResourceFromName("moderatorsmapspanel") if getResourceState(moderatorsmapspanel) == "running" then restartResource(moderatorsmapspanel) end canUseCommand = true g_Map = nil g_P = nil removeEventHandler('onMapStarting', root, onNewMapStart) end ------------------------------------------------------------------------------------------------------------------------- canUseCommand = true g_Map = nil g_P = nil ------------------------------------------------------------------------------------------------------------------------- function delmap(p) local playeraccount = getPlayerAccount (p) local accountname = getAccountName(playeraccount) if isGuestAccount(playeraccount) then return end if isObjectInACLGroup ("user." .. accountname, aclGetGroup("Admin")) or isObjectInACLGroup ("user." .. accountname, aclGetGroup("MapManagers")) then if not canUseCommand then outputChatBox("Error: Cannot use command. An admin has already deleted this map.", p, 255, 255, 255, true) return end local map = exports.mapmanager:getRunningGamemodeMap() if not map then outputChatBox("Error: No map is currently running.", p, 255, 255, 255, true) return end outputChatBox("Deleting current map at the start of next one!", root, 255, 0, 0, true) g_Map = map g_P = p addEventHandler('onMapStarting', root, onNewMapStart) canUseCommand = false end end addCommandHandler('deletemap', delmap) ------------------------------------------------------------------------------------------------------------------------- function addTeamColor(player) local playerTeam = getPlayerTeam ( player ) if ( playerTeam ) then local r,g,b = getTeamColor ( playerTeam ) local n1 = toHex(r) local n2 = toHex(g) local n3 = toHex(b) if r <= 16 then n1 = "0"..n1 end if g <= 16 then n2 = "0"..n2 end if b <= 16 then n3 = "0"..n3 end return "#"..n1..""..n2..""..n3..""..getPlayerNametagText(player) else return getPlayerNametagText(player) end end ------------------------------------------------------------------------------------------------------------------------- function toHex(n) local hexnums = {"0","1","2","3","4","5","6","7", "8","9","A","B","C","D","E","F"} local str,r = "",n%16 if n-r == 0 then str = hexnums[r+1] else str = toHex((n-r)/16)..hexnums[r+1] end return str end ------------------------------------------------------------------------------------------------------------------------- function getModeAndMap(gMode, mapName) return 'race maptimes '..gMode..' '..mapName end ------------------------------------------------------------------------------------------------------------------------- function qsafetablename(s) return qsafestring(s) end ------------------------------------------------------------------------------------------------------------------------- function qsafestring(s) return "'"..safestring(s).."'" end ------------------------------------------------------------------------------------------------------------------------- function safestring(s) return s:gsub("(['])", "''") end My attempt at deleting the toptimes is between lines 19 and 23 (utilities between 114 and 128). Would appreciate some help, cheers
  21. From what I've seen there's a different txd and dff for each neon color. And no coronas created in the resource i use (and in his is same as i tried it before).
  22. Neon tubes are seen fully only when it's dark. Not sure why but there's nothing connected with time in the neon scripts. It just is like that.
  23. Which is why i keep mine decompiled in folders. If security means so much pain in the ass if i wanna edit it then no thanks But awesome resource for those who need it
  24. Doesn't this function work only on online streams? Never seen it being used on mp3 files.
×
×
  • Create New...