Jump to content

FLUSHBICEPS

Members
  • Posts

    100
  • Joined

  • Last visited

  • Days Won

    4

Everything posted by FLUSHBICEPS

  1. FLUSHBICEPS

    Help me

    You are trying to access the table with climaHora variable replace setWeatherHour function with this function setWeatherHour() local hour = getRealTime().hour local weather = weatherHour[hour] setWeather(weather) end
  2. u can cancel the event of entering that vehicle then using setPedAnimation -- car_doorlocked anim And setTimer(warpPedIntoVehicle, 1000, ..)
  3. server side function woodCut(thePlayer) local one = math.random(#table) local x = table[one][1] local y = table[one][2] local z = table[one][3] marker = createMarker(x, y, z-1, "cylinder", 2.0, 0, 255, 0) blip = createBlipAttachedTo(marker, 22) setElementVisibleTo(blip, getRootElement(), false) setElementVisibleTo(blip, thePlayer, true) setElementVisibleTo(marker, getRootElement(), false) setElementVisibleTo(marker, thePlayer, true) outputChatBox("now Wood Man"..x..y..z, thePlayer, 0, 255, 255) check(thePlayer) end function check(thePlayer) addEventHandler("onMarkerHit", marker, function(hitElement, matchingDimension) if hitElement == thePlayer and matchingDimension then outputChatBox("Hitted", hitElement, 0, 255, 255) destroyElement(marker) destroyElement(blip) woodCut(thePlayer) end end ) end check() func ain’t taking the player who triggered the event into account also Ive added a few checks which ensures that whoever hits the marker will start working, which is ur issue client side function hitMarkerWindow(hitElement, matchingDimension) if hitElement == localPlayer and matchingDimension then window = guiCreateWindow(0.35, 0.35, 0.35, 0.30, "wood job", true) memo = guiCreateMemo(0.10, 0.20, 0.80, 0.4, "this is wood cutting job", true, window) accept = guiCreateButton(0.10, 0.75, 0.22, 0.14, "Accept Job", true, window) leave = guiCreateButton(0.35, 0.75, 0.22, 0.14, "Leave Job", true, window) close = guiCreateButton(0.60, 0.75, 0.22, 0.14, "Close", true, window) showCursor(true) guiMemoSetReadOnly(memo, true) end end addEventHandler("onClientMarkerHit", getJobMarker, hitMarkerWindow)
  4. local default = {} local drift = { -- ur drift handling properties } function applydrift() local veh = getPedOccupiedVehicle(localPlayer) if veh and getVehicleController(veh) == localPlayer then sethandling(veh, drift) end end function revertdefault() local veh = getPedOccupiedVehicle(localPlayer) if veh and getVehicleController(veh) == localPlayer then local model = getElementModel(veh) sethandling(veh, default[model]) end end function sethandling(veh, handlingData) for prop, val in pairs(handlingData) do setVehicleHandling(veh, prop, val) end end function onEnter(_, seat) if source and seat == 0 then local vehModel = getElementModel(source) if not default[vehModel] then default[vehModel] = getVehicleHandling(source) end end end addEventHandler("onClientPlayerVehicleEnter", localPlayer, onEnter) bindKey("lshift", "down", applydrift) bindKey("lshift", "up", revertdefault) so basically it’s drifting with shift by holding it, u need to change the drift handling properties local drift = { ["mass"] = 1400, ["turnMass"] = 4000, ["dragCoeff"] = 2.2, ["tractionMultiplier"] = 0.65, ["tractionLoss"] = 0.85, ["tractionBias"] = 0.52, ["brakeDeceleration"] = 8.17, ["brakeBias"] = 0.52, ["suspensionForceLevel"] = 1.2, ["suspensionDamping"] = 0.08, ["suspensionHighSpeedDamping"] = 0.0, ["suspensionUpperLimit"] = 0.28, ["suspensionLowerLimit"] = -0.16, ["suspensionFrontRearBias"] = 0.45, ["suspensionAntidiveMultiplier"] = 0.0, ["steeringLock"] = 40.0 } Didn’t try but they might do the job but still ya need to adjust them
  5. You got syntax error function convert ( number ) return tonumber(string.format("%.1f", number)) end
  6. in the resource with the function u need to add the function to the exports in meta.xml <export function="firstFunction" type="server" /> in the second resource use the call function to access the exported function local oneResource = getResourceFromName("one-resource") local result = call(oneResource, "firstFunction", arg1, arg2, ...) just make sure one resource is running before calling its functions from second resource
  7. afaik not all .fxp files may work properly but use engineImportTXD to load the effects file
  8. addEventHandler("onClientClick", root, function(button, state, absoluteX, absoluteY) if button == "left" and state == "down" then if isRendering and isCursorShowing() then local panelX, panelY, buttonHeight, sidebarWidth, screenScale = createWindow() for i, buttonData in ipairs(settingsTitles) do local buttonX = panelX + 4 local buttonY = panelY + (i - 1) * (buttonHeight + 2) local buttonWidth = sidebarWidth - 8 local buttonHeight = 50 * screenScale if absoluteX >= buttonX and absoluteX <= buttonX + buttonWidth and absoluteY >= buttonY and absoluteY <= buttonY + buttonHeight then activeButton = i end end elseif not isCursorShowing() then local panelX, panelY, buttonHeight, sidebarWidth, screenScale = createWindow() end end end) function handleButtonCloseWindow(button, state, absoluteX, absoluteY) if button == "left" and state == "down" then local _ , _ , _ , _ , _ , closeButtonWidth, closeButtonHeight, closeButtonX, closeButtonY = createWindow() if absoluteX >= closeButtonX and absoluteX <= closeButtonX + closeButtonWidth and absoluteY >= closeButtonY and absoluteY <= closeButtonY + closeButtonHeight then isRendering = false showCursor(false) removeEventHandler("onClientRender", root, createWindow) end end end addEventHandler("onClientClick", root, handleButtonCloseWindow) local function addBindKey() isRendering = not isRendering if (isRendering) then addEventHandler("onClientRender", root, createWindow) showCursor(true) else showCursor(false) removeEventHandler("onClientRender", root, createWindow) end end bindKey("F1", "down", addBindKey)
  9. u can solve this by checking if the cursor is already showing when onClientClick is triggered addEventHandler("onClientClick", root, function(button, state, absoluteX, absoluteY) if button == "left" and state == "down" then if not isCursorShowing() then -- Added this line local panelX, panelY, buttonHeight, sidebarWidth, screenScale = createWindow() for i, buttonData in ipairs(settingsTitles) do local buttonX = panelX + 4 local buttonY = panelY + (i - 1) * (buttonHeight + 2) local buttonWidth = sidebarWidth - 8 local buttonHeight = 50 * screenScale if absoluteX >= buttonX and absoluteX <= buttonX + buttonWidth and absoluteY >= buttonY and absoluteY <= buttonY + buttonHeight then activeButton = i end end end -- Added this line end end) function handleButtonCloseWindow(button, state, absoluteX, absoluteY) if button == "left" and state == "down" then local _ , _ , _ , _ , _ , closeButtonWidth, closeButtonHeight, closeButtonX, closeButtonY = createWindow() if absoluteX >= closeButtonX and absoluteX <= closeButtonX + closeButtonWidth and absoluteY >= closeButtonY and absoluteY <= closeButtonY + closeButtonHeight then isRendering = false showCursor(false) removeEventHandler("onClientRender", root, createWindow) end end end addEventHandler("onClientClick", root, handleButtonCloseWindow) local function addBindKey() isRendering = not isRendering if (isRendering) then addEventHandler("onClientRender", root, createWindow) showCursor(true) else showCursor(false) removeEventHandler("onClientRender", root, createWindow) end end bindKey("F1", "down", addBindKey)
  10. Bro what lol -- locate ur internal db db = dbConnect("sqlite", "internal.db") dbExec(db, "CREATE TABLE IF NOT EXISTS player_login_data (playerID INTEGER PRIMARY KEY, lastLoginDate TEXT)") function savePlayerLoginDate(playerID) local currentDate = os.date("%Y-%m-%d") dbExec(db, "INSERT OR REPLACE INTO player_login_data (playerID, lastLoginDate) VALUES (?, ?)", playerID, currentDate) end function getLastLoginDate(playerID, callback) dbQuery( function(qh) local result = dbPoll(qh, 0) if result and #result > 0 then callback(result[1]["lastLoginDate"]) else callback(false) end end, db, "SELECT lastLoginDate FROM player_login_data WHERE playerID=?", playerID ) end function onLastLoginCommandHandler(playerSource, command, playerID) if not playerID then outputChatBox("Usage: /lastlogin [playerID]", playerSource) return end getLastLoginDate(tonumber(playerID), function(lastLoginDate) if lastLoginDate then outputChatBox("Player ID " .. playerID .. " last logged in on: " .. lastLoginDate, playerSource) else outputChatBox("No login data found for player ID " .. playerID, playerSource) end end) end addCommandHandler("lastlogin", onLastLoginCommandHandler) addEventHandler("onPlayerLogin", root, function() local playerID = getElementData(source, "account:id") savePlayerLoginDate(playerID) end) Add the script to your mtaserver.conf
  11. seems like the issue with ur code is that the "isMouseInPosition" function and the "onClientClick" event are inside the "onClientRender" event u should move them out of the "onClientRender" event and make sure that they are only called when "DutyPanel" is true local sx, sy = guiGetScreenSize() local relx, rely = sx / 1920, sy / 1080 local DutyPanel = false local MenuPoints = {0.35, 0.20} color1 = tocolor(30, 40, 50, 255) function isMouseInPosition(x, y, width, height) if (not isCursorShowing()) then return false end local sx, sy = guiGetScreenSize() local cx, cy = getCursorPosition() local cx, cy = (cx * sx), (cy * sy) return ((cx >= x and cx <= x + width) and (cy >= y and cy <= y + height)) end addEventHandler("onClientRender", root, function() if (DutyPanel) then if not (getElementData(localPlayer, "Duty")) then -- Panel for Duty Felvétel dxDrawRectangle(sx * (MenuPoints[1]), sy * (MenuPoints[2]), sx * .3, sy * .5, tocolor(50, 60, 70, 230)) dxDrawRectangle(sx * (MenuPoints[1]), sy * (MenuPoints[2]), sx * .3, sy * 0.08, tocolor(20, 30, 40, 255)) else -- Panel for Duty leadása dxDrawRectangle(sx * (MenuPoints[1]), sy * (MenuPoints[2]), sx * .3, sy * .5, tocolor(50, 60, 70, 230)) dxDrawRectangle(sx * (MenuPoints[1]), sy * (MenuPoints[2]), sx * .3, sy * 0.08, tocolor(20, 30, 40, 255)) end -- Button dxDrawRectangle(sx * .4, sy * .4, sx * .2, sy * 0.080, color1) dxDrawText("Duty Felvételi Panel", sx * .800, sy * .4, sx * .2, sy * 0.080, tocolor(200, 200, 200, 255), relx * 4, rely * 4, "default-bold", "center", "center", false, false, false) -- Check if the mouse is hovering over the button if isMouseInPosition(sx * .4, sy * .4, sx * .2, sy * 0.080) then color1 = tocolor(80, 90, 100, 255) else color1 = tocolor(30, 40, 50, 255) end end end ) addEventHandler("onClientClick", root, function(button, state) if (DutyPanel) then if (button == "left" and state == "down") then if isMouseInPosition(sx * .4, sy * .4, sx * .2, sy * 0.080) then triggerServerEvent("Dutyon", root) DutyPanel = false end end end end ) addEvent("OpenDutyPanel", true) addEventHandler("OpenDutyPanel", root, function() if not (DutyPanel) then DutyPanel = true else outputChatBox("#961f17[RENDSZER]: #ffffffMár menűbe vagy!", 0, 0, 0, true) end end ) function ShowCursor() if not isCursorShowing() then showCursor(true) else showCursor(false) end end bindKey("m", "Down", ShowCursor)
  12. local models = { 411, 478, 240 -- add as many models here as you want, and the code will work without any other changes } local displayVehicle, index -- declaring variables as local ahead of time allows to get the speed benefits of `local` while having variables accessible thoughout the current script file (not accessible in other scripts of the same resource though) local function updateDisplayVehicle() if (isElement(displayVehicle)) then -- to prevent generating errors when the vehicle doesn't exist destroyElement(displayVehicle) -- delete the existing vehicle if it exists end local vehModel = models[index] -- get the vehicle model corresponding to the current index displayVehicle = createVehicle(vehModel, 2154.45996, -1153.21362, 23.87550) -- spawns a vehicle with the correct vehicle model end updateDisplayVehicle() local function tryChangeIndex(newIndex) if (models[newIndex]) then -- if the given index is valid (i.e. table `models` contains a value for that index) index = newIndex -- set current index to the given index updateDisplayVehicle() -- and update the currently spawned vehicle end end local function nextVehicle() tryChangeIndex(index + 1) end bindKey("arrow_r", "down", nextVehicle) local function previousVehicle() tryChangeIndex(index - 1) end bindKey("arrow_l", "down", previousVehicle)
  13. FLUSHBICEPS

    CL31 Error

    might be corrupt or something, get that file from internet and replace it then try again
  14. "Root" is the main script file of a resource that can access everything in MTA it has access to all functions and resources it can create and manipulate elements such as vehicles players and objects and "Source" is the specific element that triggered an event when a player joins a server, "Source" refers to that player. When the resource starts, "Root" refers to the main script file. --this is the root element function onstart() outputChatBox("Resource started!", root, 255, 255, 0) end addEventHandler("onResourceStart", resourceRoot, onstart) --this is an event handler that uses source function playerjoin() outputChatBox(getPlayerName(source).." has joined the server!", root, 0, 255, 0) end addEventHandler("onPlayerJoin", root, playerjoin) lets say in the code above the "onstart" function is executed when the resource is started, and it uses root to refer to the root element of the resource and the "playerjoin" function is executed whenever a player joins the server and it uses the source keyword to refer to the player who triggered the event, take a look in here that might help ya https://wiki.multitheftauto.com/wiki/Event_Source_Element
  15. If you use the default resource for kill messages then yes
  16. FLUSHBICEPS

    Nil a value

    you should check if Players not nil before using it in the trigger call Server addEvent("setTurboSound", true) addEventHandler("setTurboSound", getRootElement(), function (vehicle, turboLevel, players) if isElement(vehicle) and turboLevel and players and #players > 0 then triggerClientEvent(players, "setTurboSound", vehicle, turboLevel) end end) Client local x, y, z = getElementPosition(pedveh) local players = getElementsWithinRange(x, y, z, 100, "player") if #players > 0 then local turboLevel = getElementData(pedveh, "vehicle.tuning.Turbo") or 0 if turboLevel >= 4 then playSound("files/turbo.mp3") triggerServerEvent("setTurboSound", localPlayer, pedveh, turboLevel, players) end end The change I made in the server code is to add an extra check to make sure that the players variable is not nil before trying to get its length with #players In the client I added a line to get the current position of the vehicle using getElementPosition this is needed to properly filter the nearby players with getElementsWithinRange I also added an extra check to make sure that there are players found before triggering the server event
  17. - Create a marker at the desired location using the createMarker function - Use addEventHandler to create an event handler function that will be called when the marker is triggered - Use the setElementPosition function in the event handler function to move the player and vehicle to the desired location
  18. you will need to modify your script to detect when there’s a headshot hit it can be done using onClientPlayerDamage event function hitmark(attacker, weapon, bodypart, loss) if (bodypart == 9) then -- 9 represents the head -- Show headshot hitmark end end addEventHandler("onClientPlayerDamage", localPlayer, hitmark)
  19. function bet(player, cmd, amount) amount = tonumber(amount) if not amount or amount <= 0 then outputChatBox("Invalid bet amount.", player, 255, 0, 0, true) return end local money = getPlayerMoney(player) if money < amount then outputChatBox("You don't have enough money to make that bet.", player, 255, 0, 0, true) return end local win = math.random(0, 1) == 1 if win then givePlayerMoney(player, amount*2) outputChatBox("You won your bet of $" .. amount .. "!", player, 0, 255, 0, true) else takePlayerMoney(player, amount) outputChatBox("You lost your bet of $" .. amount .. ".", player, 255, 0, 0, true) end end addCommandHandler("bet", bet)
  20. You can use "setPedCanBeKnockedOffBike" function but its server sided, also there is no such function "setElementGravity" at least not on MTA there are setVehicleGravity and setPedGravity server-side: function teleportVehicle(player, command, x, y, z) if not isPedInVehicle(player) then outputChatBox("You must be in a vehicle to use this command.", player, 255, 0, 0) return end local playervehicle = getPedOccupiedVehicle(player) if not x or not y or not z then outputChatBox("Usage: /tp [X] [Y] [Z]", player, 255, 0, 0) return end x = tonumber(x) y = tonumber(y) z = tonumber(z) if not x or not y or not z then outputChatBox("Invalid coordinates.", player, 255, 0, 0) return end triggerClientEvent(player, "onClientTeleportVehicle", player, x, y, z) outputChatBox("Vehicle teleported to coordinates: "..x..", "..y..", "..z, player, 0, 255, 0) end addCommandHandler("tp", teleportVehicle) client-side: function tp(x, y, z) local player = getLocalPlayer() local playervehicle = getPedOccupiedVehicle(player) setElementPosition(playervehicle, x, y, z) setPedCanBeKnockedOffBike(player, false) setTimer(function() setPedCanBeKnockedOffBike(player, true) end, 1000, 1) end addEvent("onClientTeleportVehicle", true) addEventHandler("onClientTeleportVehicle", root, teleportVehicle) don't mind the command and all the error handling I've built it to try it tho, I wanted to see if to set its Gravity will fix it
  21. FLUSHBICEPS

    Nitro value

    function drawNitroBar() local vehicle = getPedOccupiedVehicle(localPlayer) if isElement(vehicle) and getVehicleUpgradeOnSlot (vehicle, 8) then local nosLevel = getVehicleNitroLevel(vehicle) local screenWidth, screenHeight = guiGetScreenSize() local barWidth = 200 local barHeight = 20 local barX = (screenWidth - barWidth) / 2 local barY = 20 local nosPercent = math.floor(nosLevel * 100) local textX = barX + (barWidth / 2) local textY = barY local textSize = 1 local textColor = tocolor(255, 255, 255, 255) local textFont = "default" local textAlignment = "center" r = nosPercent >= 100 and 0 or nosPercent >= 80 and 0 or nosPercent >= 50 and 255 or nosPercent >= 30 and 255 or nosPercent >= 20 and 200 or 150 g = nosPercent >= 100 and 255 or nosPercent >= 80 and 200 or nosPercent >= 50 and 165 or nosPercent >= 30 and 0 or nosPercent >= 20 and 0 or 0 b = nosPercent >= 100 and 0 or nosPercent >= 80 and 0 or nosPercent >= 50 and 0 or nosPercent >= 30 and 0 or nosPercent >= 20 and 0 or 0 dxDrawRectangle(barX, barY, barWidth, barHeight, tocolor(0, 0, 0, 128)) dxDrawRectangle(barX, barY, barWidth * nosLevel, barHeight, tocolor(r, g, b, 192)) dxDrawText(nosPercent.."%", textX, textY, textX, textY, textColor, textSize, textFont, textAlignment) end end addEventHandler("onClientPreRender", root, drawNitroBar) pretty sure u wanted it like that
  22. Lmao that’s a thread from 2019
×
×
  • Create New...