Jump to content

Hiding

Members
  • Posts

    63
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by Hiding

  1. Needed an extra showCursore(false) before the timer showCursor(true) if savedCursorX and savedCursorY then showCursor(false) -- here local screenX, screenY = guiGetScreenSize() setTimer(function() setCursorPosition(savedCursorX * screenX, savedCursorY * screenY) showCursor(true) end, 50, 1) end So now it looks good thank you guys
  2. Thank you, but same :~.. xd doesnt help
  3. As I mentioned, I already tried getCursorPosition and setCursorPosition, but it doesn't work — the cursor still starts from the center of the screen.. local function togglePanel() toggle = not toggle if toggle then if savedCursorX and savedCursorY then local screenX, screenY = guiGetScreenSize() setCursorPosition(savedCursorX * screenX, savedCursorY * screenY) end showCursor(true) else savedCursorX, savedCursorY = getCursorPosition() showCursor(false) end end bindKey("k", "down", togglePanel) Doesnt work this way
  4. Hi, When I use showCursor(true) to open a panel, the cursor appears in the center of the screen for a short moment, then instantly jumps to where it was before I closed the panel. I tried saving the last position using getCursorPosition() and restoring it with setCursorPosition(), but it doesn't help. Any idea how to prevent the cursor jumping from the center?
  5. Hi guys, my problem is that for some reason the slow element movement in map editor doesn't work properly, if I hold down the alt key it was working fine, but for some reason it doesn't work anymore, I reinstalled everything and it's still not woking I can set the slow element movement speed in the Movement tab of the settings, I set it to 0.001, but even if I move the object and hold the alt key, it doesn't slow down, it's as fast as normal movement.. Why is that? ** I found the problem, another script had a cancelEvent() on the lalt key.. XD
  6. Thank your for your reply. By the way, dxDrawRectangle should cover the full size of the screen. The other part, including dxDrawImage and everything inside window.drawHeaderInfos(), should be drawn using dxSetRenderTarget. I want the entire header to use dxSetRenderTarget. That's why I asked what the proper way to use it. If there are multiple hud elements (functions) one after the other, for example and pls don't rename "window" to "janela" bcs its hard to read that way
  7. Hi guys, I'm wondering how to use this dxCreateRenderTarget in a proper way. So i have this script: I'm trying to make a fade animation, when the window comes up and down, but nothing appears. Anyone can help me how to use this? local window = {} window.windowWidth = 600 window.headerHeight = 600 window.renderTarget.mainHeader = dxCreateRenderTarget(window.windowWidth, window.headerHeight, true) function window.drawHeader() dxSetRenderTarget(window.renderTarget.mainHeader, true) dxDrawRectangle(0, 0, screenWidth, screenHeight, tocolor(10, 10, 10, math_min(window.colors.alpha, 100))) dxDrawImage(window.headerX, window.headerY, window.windowWidth, window.headerHeight, textures.header_bg, 0, 0, 0, tocolor(30, 30, 30, math.min(window.colors.alpha, 250)), false) window.drawMatchScore() dxSetRenderTarget() end function window.drawHeaderInfos() -- ofc there is more data, but its not relevant dxDrawText(vsText, vsTextX, vsTextY, vsTextX, vsTextY, tocolor(230, 230, 230, window.colors.alpha), window.fonts.size, window.fonts.fontSize) end local function updateScoreboard() local now = getTickCount() local elapsedTime = now - window.fadeStartTime local progress = math_min(elapsedTime / window.fadeDuration, 1) window.currentAlpha = interpolateBetween( window.fadeStartAlpha, 0, 0, window.targetAlpha, 0, 0, progress, "Linear") window.colors.alpha = math_floor(window.currentAlpha) if window.renderTarget.mainHeader then dxDrawImage(window.headerX, window.headerY, window.windowWidth, window.headerHeight, window.renderTarget.mainHeader) end if progress == 1 and not window.isVisible and window.currentAlpha == 0 then removeEventHandler("onClientRender", root, updateScoreboard) window.isHandlerAdded = false end end local function toggleScoreboard(state) window.isVisible = state window.targetAlpha = state and 255 or 0 window.fadeStartTime = getTickCount() window.fadeStartAlpha = window.currentAlpha if not window.isHandlerAdded then addEventHandler("onClientRender", root, updateScoreboard) window.isHandlerAdded = true end end bindKey("H", "down", function() window.drawHeader() toggleScoreboard(true) end) bindKey("H", "up", function() toggleScoreboard(false) end)
  8. Actually the km data is saved in the memory local function initializePlayerData(player, km_driven) playerData[player] = { lastPosition = Vector3(getElementPosition(player)), distanceTraveled = km_driven * 1000, newDistance = 0, } end Only the final data that has been driven between login and quit will be saved in the db.
  9. Actually now I'm measuring the player's km on the server side, and I saving it when the player onPlayerQuit, but im using setTimer(function() ... end, 1000, 0) to measure it, can it be problem on the server, if it needs to save for example 10 players at the same time?
  10. Thank you for your answer, then what would be your suggestion? Because I use an onClientRender to measure the distance driven by the player in km, and I would like to save it to db when the player leaves the server to avoid unnecessary dbExec
  11. function onPlayerWasted() triggerServerEvent("someEvent", localPlayer, data / 1000) end addEventHandler("onClientPlayerWasted", root, onPlayerWasted) function onPlayerQuit() setTimer(function() triggerServerEvent("someEvent", localPlayer, data / 1000) end, 2000, 1) end addEventHandler("onClientPlayerQuit", root, onPlayerQuit) addEvent("someEvent", true) addEventHandler("someEvent", root, function(data) if not exports.login:isPlayerLoggedIn(source) then return end exports.login:updatePlayerStat(source, "stat", "stat", data) end) I would like to ask how can I make it so that when a player disconnects from the server, the data collected on the client side is sent to the server? It works fine with onClientPlayerWasted, but doesn't work with the onClientPlayerQuit, why?
  12. Ah, thank you for your response, I think I'll stick with the marker not being visible behind the object.
  13. Thanks for your answer, I know these thinks Let me write it down again, my question concerns how the arrow marker can be visible behind an object, the objects has 255 alpha, meaning it's not transparent, so I want my arrow marker to be visible even if there's an object front of it that obscures it.
  14. I know, my question was whether if there's an object in front of it, you can't see it, because that object obscures it. I want it to be visible even if there's an object front of it that obscures it.
  15. I would like to ask that is there any way for, let's say an arrow marker, to be visible behind another object? So that it's always visible, even if there's another object in front of it??
  16. I'm encountering an issue with my script where it prints 'playerName died' twice when a vehicle explodes. Interestingly, it works fine when I press enter or jump into the water; it only prints once. Any suggestions on how to handle explosions in this script? Also, any tips on optimizing the script for better efficiency would be appreciated. function onPlayerWasted(totalAmmo, killer) local playerName = getPlayerName(source) if isElement(killer) and getElementType(killer) == "player" then local killerName = getPlayerName(killer) local victimName = getPlayerName(source) if killer == source then -- suicide outputChatBox(playerName .. " died") else outputChatBox(killerName .. " killer " .. victimName) end else outputChatBox(playerName .. " died") end end addEventHandler("onPlayerWasted", root, onPlayerWasted)
  17. So first I have to apply a blink image for example?
  18. Hello, I know that in race resource there is a function called showBlipsAttachedTo(elem, bShow) from util_server.lua, and I was wondering how can I use it on client side like this? So my main goal here is to set the specific player's blip to invisible addEventHandler("setPlayerVisibility", root, function(player) local vehicle = getPedOccupiedVehicle(player) local cameraTarget = getCameraTarget() if vehicle then if cameraTarget == vehicle then ... else exports.race:showBlipsAttachedTo(vehicle, false) end end end)
  19. Hi, I want to remove every smoke from the car, engine smoke, explodion smoke, etc. My question is why just not removing the smoke? texShader = dxCreateShader ( "texreplace.fx" ) function removeSmoke() engineRemoveShaderFromWorldTexture(texShader,"collisionsmoke") engineRemoveShaderFromWorldTexture(texShader,"smoke") engineRemoveShaderFromWorldTexture(texShader,"smoke5") engineRemoveShaderFromWorldTexture(texShader,"smoke4") engineRemoveShaderFromWorldTexture(texShader,"smokeII_3") engineRemoveShaderFromWorldTexture(texShader,"fireball6") end addEventHandler("onClientResourceStart", root, removeSmoke)
  20. Hi, I want to remove every smoke from the car, engine smoke, explodion smoke, etc. My question is why just not removing the smoke? texShader = dxCreateShader ( "texreplace.fx" ) function removeSmoke() engineRemoveShaderFromWorldTexture(texShader,"collisionsmoke") engineRemoveShaderFromWorldTexture(texShader,"smoke") engineRemoveShaderFromWorldTexture(texShader,"smoke5") engineRemoveShaderFromWorldTexture(texShader,"smoke4") engineRemoveShaderFromWorldTexture(texShader,"smokeII_3") engineRemoveShaderFromWorldTexture(texShader,"fireball6") end addEventHandler("onClientResourceStart", root, removeSmoke)
  21. Hello guys, I was wondering how can I approach this: so if a player presses the f button, and if it was the source, who pressed the button then it should say "you pressed the button" otherwise "playername pressed the f button". My question is how can i get the owner of the presser? So if I press the F button then I should know that it was by me, but for others they should know that it was also me. I hope it's clear I need the the source's localPlayer on server side. (I guess) -- client side bindKey("f", "down", function() local vehicle = getPedOccupiedVehicle(localPlayer) if vehicle then triggerServerEvent("onPlayerToggledInvisibility", localPlayer, vehicle, localPlayer) end end) -- server side function onPlayerToggledInvisibility(vehicle, localPlayer) if vehicle then if source == localPlayer then outputChatBox("you pressed the f button") else outputChatBox(getPlayerName(source) .. "pressed the f button") end end end addEvent("onPlayerToggledInvisibility", true) addEventHandler("onPlayerToggledInvisibility", root, onPlayerToggledInvisibility)
×
×
  • Create New...