Jump to content

FLUSHBICEPS

Members
  • Posts

    100
  • Joined

  • Last visited

  • Days Won

    4

Everything posted by FLUSHBICEPS

  1. local blips = { {x = 0, y = 0, z = 0, dimension = 0}, {x = 1, y = 1, z = 1, dimension = 0}, {x = 2, y = 2, z = 2, dimension = 1} } local function createBlips() for _, blipData in ipairs(blips) do local blip = createBlip(blipData.x, blipData.y, blipData.z, 0, 2, 255, 0, 0, 255, 0, 500) setElementDimension(blip, blipData.dimension) end end local function refreshBlips() for _, blip in ipairs(getElementsByType("blip")) do destroyElement(blip) end createBlips() end addEventHandler("onClientElementDimensionChange", localPlayer, function(dimension) refreshBlips() end) createBlips()
  2. local function createBlips() if getElementDimension(localPlayer) == 0 then local blip = createBlip(1181.1982421875, -1324.736328125, 13.58, 22, 2, 255, 0, 0, 255, 0, 300) setElementDimension(blip, 0) elseif getElementDimension(localPlayer) == 4950 then local blip = createBlip(1837.7470703125, -1682.0029296875, 29.1171875, 48, 2, 255, 0, 0, 255, 0, 300) setElementDimension(blip, 4950) elseif getElementDimension(localPlayer) == 5051 then local blip = createBlip(etc, etc, etc) setElementDimension(blip, 5051) end end local function refreshBlips() for _, blip in ipairs(getElementsByType("blip")) do destroyElement(blip) end createBlips() end addEventHandler("onClientResourceStart", resourceRoot, createBlips) addEventHandler("onClientElementDimensionChange", localPlayer, refreshBlips) It refreshes the blips whenever the player's dimension changes so basically it's keeping track of where the player is in the game dimension and updating the blips to reflect that hoped ive helped
  3. you will need to modify the script to use the dbExec function instead of dbQuery.
  4. local function createBlips() if getElementDimension(localPlayer) == 0 then local blip = createBlip(1181.1982421875, -1324.736328125, 13.58, 22, 2, 255, 0, 0, 255, 0, 300) setElementDimension(blip, 0) elseif getElementDimension(localPlayer) == 4950 then local blip = createBlip(1837.7470703125, -1682.0029296875, 29.1171875, 48, 2, 255, 0, 0, 255, 0, 300) setElementDimension(blip, 4950) elseif getElementDimension(localPlayer) == 5051 then local blip = createBlip(etc, etc, etc) setElementDimension(blip, 5051) end end addEventHandler("onClientResourceStart", resourceRoot, createBlips)
  5. In mta there's no official rule against using color codes to make your nickname invisible but it can still be seen as a way of messing with other players. If someone is using an invisible nickname to act up and be inappropriate it's a valid reason for an admin to ban them each server has its own set of rules so it's up to you to decide what behavior deserves a ban If the player feels like he got banned unjustly, he can try to talk it out with you or appeal the ban
  6. either source or randomP is nil in the following lines: triggerClientEvent(source, "getRandPlayer", source, randomP) and ui["playerWon"] = dxDrawText(tostring(getPlayerName(randomP)), x*860, y*242,0,0, tocolor(255, 255, 255, 255), 1, playerFont) You need to make sure that source and randomP are valid player elements before using them.
  7. local sound = playSound("path/to/sound.mp3") local targetAltitude = 1000 addEventHandler("onClientRender", root, function() local x, y, z = getElementPosition(getLocalPlayer()) local groundY = getGroundPosition(x, z) local altitude = y - groundY if altitude >= targetAltitude then playSound(sound) end end )
  8. local serial = getPlayerSerial (getLocalPlayer()) local allowedSerials = { -- List of allowed serials "12345678901234567890123456789012", "23456789012345678901234567890123", "34567890123456789012345678901234" } function isSerialAllowed(serial) for i, allowedSerial in ipairs(allowedSerials) do if serial == allowedSerial then return true end end return false end addEventHandler("onClientResourceStart", resourceRoot, function() if not isSerialAllowed(serial) then -- Kick the player if their serial is not allowed kickPlayer("Your serial is not on the whitelist.") else -- Connect to the server if the serial is allowed -- Replace "server.example.com" with the address of your server triggerServerEvent("connectToServer", resourceRoot, "server.example.com") end end ) addEvent("connectToServer", true) addEventHandler("connectToServer", root, function(serverAddress) -- Connect the player to the specified server -- Replace "serverPassword" with the password for your server connect(serverAddress, "serverPassword") end )
  9. --server-side code addEvent("doAnimation", true) addEvent("onTargetSelected", true) -- added trigger for player targeting addEventHandler("onTargetSelected", root, function(target) setPedAnimation(target, "CRACK", "crckdeth2", -1, false, false, false, false) setTimer( function() setPedAnimation(target) end, 10000, 1 ) -- stop animation after 10 seconds end ) --client-side code local playerSelectedTarget local targetMarker = createMarker( 0, 0, 10000, "arrow", 1.5, 255, 0, 0 ) addEventHandler("onClientRender", root, function() if ( getKeyState("mouse2") == true ) then local x,y,z = getElementPosition(localPlayer) for k,target in ipairs(getElementsByType("player",root,true)) do if not ( target == localPlayer ) then local px,py,pz = getElementPosition(target) local distance = getDistanceBetweenPoints3D( px, py, pz, x, y, z ) if ( distance < 10 ) then --target distance playerSelectedTarget = target triggerServerEvent("onTargetSelected", root, playerSelectedTarget) -- trigger server event end end end if isElement(playerSelectedTarget) then local tx,ty,tz = getElementPosition(playerSelectedTarget) setElementPosition( targetMarker, tx, ty, tz+3 ) end else if isElement(playerSelectedTarget) then setElementPosition( targetMarker, 0, 0, 10000 ) end end end )
  10. try to update the graphics card driver, Repair the mta installation, Connect to a different server, check ur internet connection, Install an older version of MTA it can be ur antivirus blocking a dll and if you got 32 bit windows it can be that ran out of address address check this link https://forum.multitheftauto.com/topic/78081-32-bit-windows-crashing/
  11. --server side local npc local infernus function startNPC(player) local x, y, z = getElementPosition(player) npc = createPed(0, x, y, z) infernus = createVehicle(411, x, y, z) warpPedIntoVehicle(npc, infernus) triggerClientEvent(player, "switchToThirdPerson", player, npc) bindKey(player, "w", "down", function() setControlState(npc, "accelerate", true) end) bindKey(player, "s", "down", function() setControlState(npc, "brake_reverse", true) end) bindKey(player, "a", "down", function() setControlState(npc, "steer_left", true) end) bindKey(player, "d", "down", function() setControlState(npc, "steer_right", true) end) end function stopNPC(player) removePedFromVehicle(npc) destroyElement(infernus) triggerClientEvent(player, "switchToFirstPerson", player) unbindKey(player, "w", "down") unbindKey(player, "s", "down") unbindKey(player, "a", "down") unbindKey(player, "d", "down") end function handleCommand(player, command, parameters) if player ~= localPlayer then return end if command == "npc" then if parameters == "start" then startNPC(player) elseif parameters == "stop" then stopNPC(player) end end end addCommandHandler("npc", handleCommand) --client side function switchToThirdPerson(player, npc) setCameraTarget(npc) end function switchToFirstPerson() setCameraTarget(localPlayer) end addEvent("switchToThirdPerson", true) addEventHandler("switchToThirdPerson", root, switchToThirdPerson) addEvent("switchToFirstPerson", true) addEventHandler("switchToFirstPerson", root, switchToFirstPerson) if i understood what u need so this is the script for u make sure to check it again since I didn’t try it also I’m not sure if you can use setCameraTarget on an npc but u can always remove it so usin wasd keys, the player can control an NPC in a vehicle. When controlling the NPC, it toggles the camera view between u and the npc the command to spawn the npc and vehicle(infernus) is /npc start and /npc stop to remove them
  12. --server-side code addEvent("doAnimation", true) addEventHandler("doAnimation", root, function(target) setPedAnimation(target, "CRACK", "crckdeth2", -1, false, false, false, false) setTimer( function() setPedAnimation(target) end, 10000, 1 ) -- stop animation after 10 seconds end ) --client-side code local playerSelectedTarget local targetMarker = createMarker( 0, 0, 10000, "arrow", 1.5, 255, 0, 0 ) addEventHandler("onClientRender", root, function() if ( getKeyState("mouse2") == true ) then local x,y,z = getElementPosition(localPlayer) for k,target in ipairs(getElementsByType("player",root,true)) do if not ( target == localPlayer ) then local px,py,pz = getElementPosition(target) local distance = getDistanceBetweenPoints3D( px, py, pz, x, y, z ) if ( distance < 10 ) then --target distance playerSelectedTarget = target triggerServerEvent("doAnimation", root, playerSelectedTarget) -- trigger server event end end end if isElement(playerSelectedTarget) then local tx,ty,tz = getElementPosition(playerSelectedTarget) setElementPosition( targetMarker, tx, ty, tz+3 ) end else if isElement(playerSelectedTarget) then setElementPosition( targetMarker, 0, 0, 10000 ) end end end )
  13. -- ... --# Blips local radarAreas = getElementsByType("radararea") for k, v in ipairs(radarAreas) do -- Get the size of the radar area local x1, y1, z1, x2, y2, z2 = getRadarAreaSize(v) -- Ensure that x1, y1, z1, x2, y2, z2 are all numbers if type(x1) == "number" and type(y1) == "number" and type(z1) == "number" and type(x2) == "number" and type(y2) == "number" and type(z2) == "number" then -- Calculate the minimum and maximum values for x, y, z local minX, minY, minZ = math.min(x1, x2), math.min(y1, y2), math.min(z1, z2) local maxX, maxY, maxZ = math.max(x1, x2), math.max(y1, y2), math.max(z1, z2) -- Calculate the width, height, and depth local width, height, depth = maxX - minX, maxY - minY, maxZ - minZ -- Calculate the center x, y, and z values local cx, cy, cz = (minX + maxX) / 2, (minY + maxY) / 2, (minZ + maxZ) / 2 -- Get the rotation of the radar area local rot = getElementRotation(v) -- Draw the lines for the radar area dxDrawMaterialLine3D(cx - width / 2, cy - height / 2, cz, cx + width / 2, cy - height / 2, cz, rt, 2, tocolor(255, 0, 0), cx, cy, cz, rot) dxDrawMaterialLine3D(cx + width / 2, cy - height / 2, cz, cx + width / 2, cy + height / 2, cz, rt, 2, tocolor(255, 0, 0), cx, cy, cz, rot) dxDrawMaterialLine3D(cx + width / 2, cy + height / 2, cz, cx - width / 2, cy + height / 2, cz, rt, 2, tocolor(255, 0, 0), cx, cy, cz, rot) dxDrawMaterialLine3D(cx - width / 2, cy + height / 2, cz, cx - width / 2, cy - height / 2, cz, rt, 2, tocolor(255, 0, 0), cx, cy, cz, rot) end end
  14. This error occurs because sortedTable[2][1] or sortedTable[3][1] returns nil when there are no players and you are attempting to call getPlayerName on a nil value function getTopThree() sortedTable = {} for player, damage in pairs(damageTable) do if isElement(player) then local team = getPlayerTeam(player) table.insert(sortedTable, {player, damage}) end end table.sort(sortedTable, function(a, b) return a[2] > b[2] end) local t1, t2, t3 = {}, {}, {} t1 = {getPlayerName(sortedTable[1][1]), sortedTable[1][2]} or {"N/A", "0"} t2 = {getPlayerName(sortedTable[2][1]), sortedTable[2][2]} or {"N/A", "0"} if sortedTable[2] then t3 = {getPlayerName(sortedTable[3][1]), sortedTable[3][2]} or {"N/A", "0"} if sortedTable[3] then triggerClientEvent(root, "showTopZDamage", root, t1, t2, t3) end This ensures that t2 and t3 are only assigned if the sortedTable array contains enough elements avoiding the error
  15. -- settings.lua SOME_SETTINGS = {} SOME_SETTINGS.WINDOW = { X = 0, Y = 0, WIDTH = 300, HEIGHT = 300, NAME = "TITLE", RELATIVE = false } -- client.lua include("settings.lua") guiCreateWindow (SOME_SETTINGS.WINDOW.X, SOME_SETTINGS.WINDOW.Y, SOME_SETTINGS.WINDOW.WIDTH, SOME_SETTINGS.WINDOW.HEIGHT, SOME_SETTINGS.WINDOW.NAME, SOME_SETTINGS.WINDOW.RELATIVE)
  16. addEventHandler("onVehicleEnter", root, function(player, seat) if source:getModel() == 416 then setElementData(source, "canDriveOnWater", true) end end) addEventHandler("onVehicleExit", root, function(player, seat) if source:getModel() == 416 and getElementData(source, "canDriveOnWater") then setElementData(source, "canDriveOnWater", false) setVehicleHandling(source, "dragCoeff", 0.2) end end) addEventHandler("onVehicleMove", root, function() local vehicle = source if getElementData(vehicle, "canDriveOnWater") then local x, y, z = getElementPosition(vehicle) if getWaterLevel(x, y, z) > z then setVehicleOnGround(vehicle) setVehicleHandling(vehicle, "dragCoeff", 10) else setVehicleHandling(vehicle, "dragCoeff", 0.2) end end end) My apologies I did a mistake with the event, I’ve replaced it with my onVehicleMove now it should work literally sometimes I forget it’s for MTA addEventHandler("onVehicleEnter", root, function(player, seat) if getElementModel(source) == 416 then setElementData(source, "canDriveOnWater", true) end end) addEventHandler("onVehicleExit", root, function(player, seat) if getElementModel(source) == 416 and getElementData(source, "canDriveOnWater") then setElementData(source, "canDriveOnWater", false) if getVehicleHandling(source)["dragCoeff"] then setVehicleHandling(source, "dragCoeff", 0.2) end end end) addEventHandler("onVehicleMove", root, function() local vehicle = source if getElementData(vehicle, "canDriveOnWater") then local x, y, z = getElementPosition(vehicle) local waterZ = getWaterLevel(x, y, z) if waterZ and waterZ > z then setElementPosition(vehicle, x, y, waterZ) if getVehicleHandling(vehicle)["dragCoeff"] then setVehicleHandling(vehicle, "dragCoeff", 10) end else if getVehicleHandling(vehicle)["dragCoeff"] then setVehicleHandling(vehicle, "dragCoeff", 0.2) end end end end)
  17. my fault I’ve made that quick asf xd function onResourceStart() setWorldSoundEnabled(19, false) setWorldSoundEnabled(24, false) addEventHandler("onClientPlayerWeaponFire", localPlayer, function() local weapon = getPedWeapon(localPlayer) if weapon == 24 then playSound("sounds/m4fire.wav", false) elseif weapon == 24 then playSound("sounds/deaglefire.wav", false) end end) end addEventHandler("onClientResourceStart", resourceRoot, onResourceStart)
  18. addEventHandler("onVehicleEnter", root, function(player, seat) if source:getModel() == 416 then setElementData(source, "canDriveOnWater", true) end end) addEventHandler("onVehicleExit", root, function(player, seat) if source:getModel() == 416 and getElementData(source, "canDriveOnWater") then setElementData(source, "canDriveOnWater", false) setVehicleHandling(source, "dragCoeff", 0.2) end end) addEventHandler("onClientPreRender", root, function() for i, vehicle in ipairs(getElementsByType("vehicle")) do if getElementData(vehicle, "canDriveOnWater") then local x, y, z = getElementPosition(vehicle) if getWaterLevel(x, y, z) > z then setVehicleOnGround(vehicle) setVehicleHandling(vehicle, "dragCoeff", 10) else setVehicleHandling(vehicle, "dragCoeff", 0.2) end end end end) not tested tho
  19. local speed = 20 local buoyancy = 1.5 local drag = 1 function swimVehicle() local player = localPlayer local vehicle = getPedOccupiedVehicle(player) if vehicle and getElementModel(vehicle) == 407 then local x, y, z = getElementPosition(vehicle) local level = getWaterLevel(x, y, z) if z < level then setElementData(vehicle, "buoyancy", buoyancy) setElementData(vehicle, "vehicleDrag", drag) setElementData(vehicle, "centerOfMass", {0, 0, -1}) setVehicleHandling(vehicle, "engineAcceleration", speed) else setElementData(vehicle, "buoyancy", 0) setElementData(vehicle, "vehicleDrag", 0) setVehicleHandling(vehicle, "engineAcceleration", 0) end end end addEventHandler("onClientRender", root, swimVehicle)
  20. Try exports.bone_attach:attachElementToBone(wheelbarrow, localPlayer, 0.75, -0.25, 0, 0, 0, 90)
  21. setWorldSoundEnabled(19, false) setWorldSoundEnabled(24, false) addEventHandler("onPlayerWeaponFire", root, function() local weapon = getPedWeapon(source) if weapon == 24 then playSound("sounds/m4fire.wav", false) elseif weapon == 24 then playSound("sounds/deaglefire.wav", false) end end) just an example for deagle and m4 sounds you can add the weapons you do like to replace
  22. Maybe try connecting to other servers to see if it’s the server issue if not it can be your internet, your firewall that causes connection timeout try disabling it
  23. MTA does not directly support reading zip files containing character skins the skins must be in a format that MTA can read like TXD or DFF files but If you want to reduce the resource size you could use texture compression techniques or other methods to reduce the file size of the skins, but converting them to a zip file is not an option hoped I helped
  24. In the first case creating and hiding a GUI outside of the main function makes managing the elements easier. To alter the visibility of the gui and its elements use the guiSetVisible function Now the second example is appropriate if you only need to create the GUI once but if you need to show and hide the GUI multiple times, creating it outside the function is more efficient. If you built the GUI inside the function each time it was called, your script would run slower and consume more resources the GUI elements can be managed in both cases because they are global variables that can be referenced from anywhere in the code.
×
×
  • Create New...