Jump to content

alex17"

Members
  • Posts

    163
  • Joined

  • Last visited

  • Days Won

    3

Everything posted by alex17"

  1. function ggPlayer () if getPlayerSerial (source) == "34A2E2ECE41E349CCA34FF84EE1" then setPlayerMuted(source, true) end end addEventHandler ( "onPlayerJoin", root, ggPlayer )
  2. if teamDM == DeathMatch then you have an if, if the condition is not met it will not spawn
  3. my bad addEventHandler("onPlayerWasted", root, function() local spawn23 = math.random(1, 3) local teamDM = getPlayerTeam(source) local player23 = source if teamDM == DeathMatch then if spawn23 == 1 then setTimer(function() spawnPlayer(player23, 206.875, 168.638671875, 1003.0234375, 150, 104, 3, 0, team23) giveWeapon(player23, 31, 500) end, 3000, 1) elseif spawn23 == 2 then setTimer(function() spawnPlayer(player23, 252.208984375, 185.451171875, 1008.171875, math.random(0, 360), 107, 3, 0, team23) giveWeapon(player23, 31, 500) end, 3000, 1) elseif spawn23 == 3 then setTimer(function() spawnPlayer(player23, 288.3740234375, 168.3642578125, 1007.171875, math.random(0, 360), 101, 3, 0, team23) giveWeapon(player23, 31, 500) end, 3000, 1) end end end )
  4. addEventHandler("onPlayerWasted", root, function() local spawn23 = math.random(1, 3) local teamDM = getPlayerTeam(source) local player23 = source if teamDM == DeathMatch then if spawn23 == 1 then setTimer(function() spawnPlayer(player23, 206.875, 168.638671875, 1003.0234375, 150, 104, 3, 0, team23) giveWeapon(Player23, 31, 500) end, 3000, 1) elseif spawn23 == 2 then setTimer(function() spawnPlayer(player23, 252.208984375, 185.451171875, 1008.171875, math.random(0, 360), 107, 3, 0, team23) giveWeapon(Player23, 31, 500) end, 3000, 1) elseif spawn23 == 3 then setTimer(function() spawnPlayer(player23, 288.3740234375, 168.3642578125, 1007.171875, math.random(0, 360), 101, 3, 0, team23) giveWeapon(Player23, 31, 500) end, 3000, 1) end end end )
  5. The arguments u: the absolute X coordinate of the top left corner of the section which should be drawn from image v: the absolute Y coordinate of the top left corner of the section which should be drawn from image usize: the absolute width of the image section vsize: the absolute height of the image section must be worked based on the original size in pixels of the image and not based on the size it will have on the screen local imgW, imgH = 200, 150 dxDrawImageSection(screenX - ScaleY(289), screenY - ScaleY(19), ScaleY(47), ScaleY(-(123*(fuel/100))), 0, 0, imgW, imgW * (fuel/100),"fuel.png", 0, 0, 0, tocolor(2,153,0,255), false) To get the image size, right click on the image / properties / details / see dimensions
  6. We still don't know how your missions are working, it would be easier if you provide us with the code. Likewise, I leave you a small example of how you could work it, although in my opinion it would be much easier if you worked everything on the server and not on the client. -- Server local day = getRealTime().monthday --- Set the server day addEventHandler("onPlayerLogin", root, function() if getRealTime().monthday ~= day then --- When a player connects, check if the day has changed day = getRealTime().monthday --- If it is another day, save it in the variable setAccountData(getPlayerAccount(source), "isMissionCompleted", false) -- resets the player's mission data triggerClientEvent(source, "createMissionMarker", source) --- send a trigger to the client to create the marker else -- If the day still does not change, check if the player has already completed the mission local isMissionCompleted = getAccountData(getPlayerAccount(source), "isMissionCompleted") if not isMissionCompleted then --- If the mission has not yet been completed, send a trigger to create the marker triggerClientEvent(source, "createMissionMarker", source) end end end ) --- When you complete the mission, send a trigger to the server to save the data addEvent("onMissionCompleted", true) addEventHandler("onMissionCompleted", root, function() setAccountData(getPlayerAccount(client), "isMissionCompleted", true) end) -- Client addEvent("createMissionMarker", true) addEventHandler("createMissionMarker", root, function() marker = createMarker(...) end)
  7. If they don't show us your code it is difficult to help you, first of all, how are you working on your missions on the server or on the client?
  8. You can use a variable and set it to true when someone starts the mission and false when it ends, when someone wants to start that mission they can only do so if the variable is false local isMissionStarted = false addEvent("requestStartMission", true) addEventHandler("requestStartMission", root, function() if not isMissionStarted then startMision() else outputChatBox("Mission not available right now", client, 255, 0, 0) end end ) function startMision() isMissionStarted = true end function stopMision() isMissionStarted = false end
  9. function checkisPlayerRunning(_, state) if state == "down" then addEventHandler("onClientKey", root, cancelControls) else removeEventHandler("onClientKey", root, cancelControls) end end bindKey("sprint", "up", checkisPlayerRunning) bindKey("sprint", "down", checkisPlayerRunning) function cancelControls(key, pressState) if key == "lctrl" or key == "mouse1" then -- block the use of either key cancelEvent(true) end end try this, maybe it will help I'm not too sure
  10. local scroll = 0 local maxItemsOnScreen = 8 local items = {} bindKey("mouse_wheel_down", "down", function() if scroll < (items - maxItemsOnScreen) then scroll = scroll + 1 end end ) bindKey("mouse_wheel_up", "down", function() if scroll > 0 then scroll = scroll - 1 end end ) function dxDrawInventory() for i = 1 + scroll, maxItemsOnScreen + scroll do if items[scroll] then dxDrawRectangle(...) ... ... end end end I leave you a fairly simple example of how you can do it.
  11. When you press a key, it can be control or mouse 1, but it can never be both at the same time.
  12. addEventHandler("onClientKey", root, function(key) if key == "lctrl" or key == "mouse1" then cancelEvent() end end )
  13. use the variable globally, this does not mean that you place it outside the function, just delete "local"
  14. trigging in the for is not the most appropriate, the best would be outside the for for i, k in ipairs(Bomb2) do if (isElementAttached(Bomb2[i])) then detachElements(Bomb2[i], helic[1]) plantedBombs = plantedBombs + 1 outputChatBox("Bomb has been successfully installed, Do the same with the rest!", root, 34, 139, 34) outputChatBox(plantedBombs) ---- This returns what it should return end end triggerClientEvent(player, "updatePlantedBombs", root, plantedBombs)
  15. addEventHandler("onPlayerWasted", root, function() local spawn = math.random(1, 3) local team = getPlayerTeam(source) local skin = getElementModel(source) local player = source if spawn == 1 then setTimer(spawnPlayer, 3000, 1, player, x, y, z, math.random(0, 360), skin, 0, 0, team) elseif spawn == 2 then setTimer(spawnPlayer, 3000, 1, player, x, y, z, math.random(0, 360), skin, 0, 0, team) elseif spawn == 3 then setTimer(spawnPlayer, 3000, 1, player, x, y, z, math.random(0, 360), skin, 0, 0, team) end end )
  16. You can combine it with another method. When the object starts moving, use processLineOfSight to detect if it will collide with a wall, then calculate the time it will collide and create the explosion as long as the colshape has not been activated. I'll leave you an example, I haven't tried it but let me know if it works for you or if it has any errors. local object local colshape local timer function ExplosiveObject() object = createObject(...) colshape = createColCuboid(...) attachElements(object, colshape) -- Move the object to a specific position with time and rotation effects moveObject(object, time, fx, fy, fz, frx, fry, frz) -- Calculate line of sight between two points local hit, hx, hy, hz, elementHit = processLineOfSight(x, y, z, fx, fy, fz, true, true, false, true, true) -- Check if there was a collision and an element was hit if hit and elementHit then -- If any coordinates are null, get the position of the hit element if not hx or not hy or not hz then hx, hy, hz = getElementPosition(elementHit) end -- Calculate the distance between two 3D points local dist1 = getDistanceBetweenPoints3D(x, y, z, fx, fy, fz) local dist2 = getDistanceBetweenPoints3D(x, y, z, hx, hy, hz) -- Calculate the time to create the explosion based on distances local time = (dist2 / dist1) * time -- Set a timer to create the explosion timer = setTimer(createExplosion_, time, 1) end -- Add event handlers to detect when the colshape is hit addEventHandler("onClientColShapeHit", colshape, onClientColShapeHit) -- Add event handlers to detect when the object stops moving addEventHandler("onClientObjectMoveStop", object, onClientObjectMoveStop) end -- Function to create an explosion at the position of the object function createExplosion_() local x, y, z = getElementPosition(object) createExplosion(x, y, z, 0) -- Create an explosion at position (x, y, z) end -- Event handler for when the colshape is hit function onClientColShapeHit() if timer and isTimer(timer) then killTimer(timer) end -- Call the function to create an explosion at the position of the object createExplosion_() -- Remove event handlers to prevent repetitions removeEventHandler("onClientColShapeHit", colshape, onClientColShapeHit) removeEventHandler("onClientObjectMoveStop", object, onClientObjectMoveStop) end -- Event handler for when the object stops moving function onClientObjectMoveStop() if timer and isTimer(timer) then killTimer(timer) end -- Remove the event handler to prevent repetitions removeEventHandler("onClientObjectMoveStop", object, onClientObjectMoveStop) end
  17. you can use a createColCuboid attached to the object and the onClientColShapeHit event to detect when it collides with a player use setDevelopmentMode and showcol to see the colshape
  18. addEventHandler("onPlayerWasted", root, function() local spawn = math.random(1, 3) local team = getPlayerTeam(source) local skin = getElementModel(source) if spawn == 1 then spawnPlayer(source, x, y, z, math.random(0, 360), skin, 0, 0, team) elseif spawn == 2 then spawnPlayer(source, x, y, z, math.random(0, 360), skin, 0, 0, team) elseif spawn == 3 then spawnPlayer(source, x, y, z, math.random(0, 360), skin, 0, 0, team) end end ) x, y , z change them to the spawn coordinates
  19. vehicle variable must be global Give us your code so we can help you better
  20. When markers are inside cause problems, the server side event doesn't always fire. I suggest you work on it in the client, you won't have this problem there. gate = createObject(980, 364.82147, 186.89452, 1019.98438) setElementInterior(gate, 3) bombMarker = createMarker(364.70267, 186.29311, 1019.98438 -0.5, "cylinder", 1, 255, 0, 0) setElementInterior(bombMarker, 3) addEventHandler("onClientMarkerHit", bombMarker, function(player) outputChatBox("ugh!") end)
  21. To detect the player you are using a distance less than 30, but the problem is that there are several players near you with a distance less than 30. Therefore, it will always take the last one on the list whose distance is less than 30 You should check who is closest and what is inside the player's camera. addEventHandler("onClientRender", root, function() local maxDistance = 30 for _, player in ipairs(...) ... if distance <= maxDistance and isElementOnScreen(player) then maxDistance = distance playerSelectedTarget = player end end end )
  22. It is not necessary to create the marker on the server and then do a trigger, it can work perfectly if you do everything on the client Marker = createMarker( 1508.814453125 , -1144.19921875 , 140.93536376953, "cylinder", 1, 255, 0, 0) addEventHandler("onClientMarkerHit", Marker, function(element, dim) if element == localPlayer and dim then if not dm_window then dm_window = guiCreateWindow(0.1556,0.1597,0.6375,0.6944,"Team-Panel",true) grove_button = guiCreateButton(10,108,162,165,"Team-1",false,dm_window) police_button = guiCreateButton(285,108,162,165,"Team-2",false,dm_window) teams_label = guiCreateLabel(159,44,145,47,"",false,dm_window) else guiSetVisible(dm_window, true) end showCursor(true) end end ) But if you still want to continue doing it with a server to client trigger, I'll leave you how to do it server Marker = createMarker( 1508.814453125 , -1144.19921875 , 140.93536376953, "cylinder", 1, 255, 0, 0) function openwindow(thePlayer, dim) local elementType = getElementType(thePlayer) if elementType == "player" and dim then triggerClientEvent(thePlayer,"opengui1window", thePlayer) end end addEventHandler("onMarkerHit", Marker, openwindow) client addEvent("opengui1window", true) addEventHandler("opengui1window", root, function() if not dm_window then dm_window = guiCreateWindow(0.1556,0.1597,0.6375,0.6944,"Team-Panel",true) grove_button = guiCreateButton(10,108,162,165,"Team-1",false,dm_window) police_button = guiCreateButton(285,108,162,165,"Team-2",false,dm_window) teams_label = guiCreateLabel(159,44,145,47,"",false,dm_window) else guiSetVisible(dm_window, true) end showCursor(true) end )
  23. spawnedSounds = {} function playZombieSounds() local ped = getElementsByType("ped") for theKey,peds in ipairs(ped) do if ped and isElement(peds) and isElementStreamedIn(peds) then local Zx,Zy,Zz = getElementPosition(peds) if not spawnedSounds[peds] or not isElement(spawnedSounds[peds] then spawnedSounds[peds] = playSound3D(zombiesounds[math.random(1,#zombiesounds)], Zx, Zy, Zz, false) end end end end setTimer(playZombieSounds,6000,0) addEventHandler("onClientPedWasted", root, function() if spawnedSounds[source] and isElement(spawnedSounds[source] then destroyElement(spawnedSounds[source]) spawnedSounds[source] = nil end end )
  24. It happens that when they register they have not played yet, therefore that data does not yet exist. To solve it you can do it in two ways. 1. Force to start for the first time with elementData at 0 addEventHandler("onPlayerLogin", root, function(pa, ca) local account = getPlayerAccount(source) if not isGuestAccount(account) then local health = getAccountData(account, "health") or 0 local armor = getAccountData(account, "armor") or 0 local water = getAccountData(account, "water") or 0 local food = getAccountData(account, "food") or 0 setElementHealth(source, health) setPlayerArmor(source, armor) setElementData(source, "water", water) setElementData(source, "food", food) end end) or directly in the hud set it to 0 if you don't already have those elementData function render() health = getElementHealth(localPlayer) armor = getPedArmor(localPlayer) water = getElementData(localPlayer, "water") or 0 food = getElementData(localPlayer, "food") or 0 money = getPlayerMoney(localPlayer) time = getRealTime() hour = time.hour minute = time.minute second = time.second ...
  25. para desconponer la tabla con el for en este caso debe usar pairs en vez ipairs , tambien toma en cosideración si el uso de isLineOfSightClear es necesario ya que es en parte lo que aumentara los bajones de fps cuando haya muchos peds , asi mismo tambien le añadiria una variable que te indique si la tabla tiene elementos para que el onClientRender siga ejecutandose o debe pararse, pequeñas cositas que aligeraran la carga a los fps addEventHandler( "onClientElementStreamOut", root, function () if NPCWeapon[source] then NPCWeapon[source] = nil end removeEventHandler("onClientRender", root, dxDrawImagenOnPed) addEventHandler("onClientRender", root, dxDrawImagenOnPed) end ) addEventHandler("onClientElementDestroy", root, function () if NPCWeapon[source] then NPCWeapon[source] = nil end end ) function dxDrawImagenOnPed)() local draw = false for _,PedWeapon in pairs(NPCWeapon) do if PedWeapon then draw = true local x, y, z = getElementPosition(PedWeapon) dxDrawImageOnWeapon(PedWeapon,TagWeapon) end end if not draw then removeEventHandler("onClientRender", root, dxDrawImagenOnPed) end end
×
×
  • Create New...