Jump to content

Pateryk

Members
  • Posts

    4
  • Joined

  • Last visited

Pateryk's Achievements

Vic

Vic (3/54)

0

Reputation

  1. Welcome to the Polish server DD/DM/Race. mtasa://94.23.251.227:22040 gameplay
  2. Witam.. Postaram sie jak najprosciej i zrozumiale przedstawic moj problem.. A wiec posiadam "dm_respawn"https://community.multitheftauto.com/index.php?p=resources&s=details&id=3667 z communuty i chodzi o to by przy kazdym pojawieniu sie pojazdu dawalo repaira.. Ponieważ jak pojazd sie pojawi z brakiem hp to pozniej sie spawni bez hp i wybucha co powoduje wielki spadek fps i dziwne zjawiska Niby prosto jest dodac funkcje repaira ale ja w tym zielony jestem, dlatego was prosze o pomoc. client local screen_width, screen_height = guiGetScreenSize() local RESPAWN_KEY = "space" local showRespawn = false local text = "#FF5500Press #FFFFFF"..RESPAWN_KEY.." #FF5500to respawn" local scale = 1.5 local font = "bankgothic" local textWidth = dxGetTextWidth(text:gsub("#%x%x%x%x%x%x", ""), scale, font) local fontHeight = dxGetFontHeight(scale, font) local color = tocolor(255, 128, 0, 255) setElementData(getLocalPlayer(), "respawn.playing", false, true) local running = false local vehicleData = {} local SAVE_INTER = 22500 local saveTimer = nil local reset = true -- reset timer local lastSaved = 0 -- When element data for the player changes, bind or unbind key. addEventHandler("onClientElementDataChange", getLocalPlayer(), function(dataName, oldValue) if(getElementType(source) ~= "player" or dataName ~= "state")then return end local newValue = getElementData(source, dataName) if(newValue == "dead")then reset =true setTimer(function() if(#vehicleData > 0 and running)then showRespawn = true setElementData(getLocalPlayer(), "respawn.playing", false, true) bindKey(RESPAWN_KEY, "up", respawn) end end, 3000, 1) else unbindKey(RESPAWN_KEY, "up", respawn) showRespawn = false setElementData(getLocalPlayer(), "respawn.playing", false, true) end if(newValue == "alive" and oldValue ~= "alive")then reset = false end end) -- respawn player, later add "checkpoints" function respawn() reset = false unbindKey(RESPAWN_KEY, "up", respawn) showRespawn = false setElementData(getLocalPlayer(), "respawn.playing", true, true) local index = #vehicleData local index2 = #vehicleData -- Save memory and go back to later saved positions if dying too fast. local timeWasted = math.floor((getTickCount() - lastSaved)/1000) if(timeWasted <= 7 and index > 1)then table.remove(vehicleData, index) index = #vehicleData outputDebugString("Vehicle data num: "..index.." removed respawn.") end outputDebugString("Respawning with vehicle data index: "..index) triggerServerEvent("onClientRequestRespawn", getLocalPlayer(), vehicleData[index]) if(index2 > 1 and index == index2)then table.remove(vehicleData, index) outputDebugString("Vehicle data num: "..index.." removed.") end end addEventHandler("onClientRender", getRootElement(), function() if(reset)then resetTimer(saveTimer) end -- Dont show text if player is not allowed to respawn. if not showRespawn then return end local x, y = screen_width/2 - textWidth/2, screen_height * 0.75 - fontHeight/2 dxDrawColoredText(text, x, y, screen_width, screen_height, color, scale, font) end) -- Save vehicle data, to later spawn with that data. function saveVehicleData() local vehicle = getPedOccupiedVehicle(getLocalPlayer()) if(not running or showRespawn or (not vehicle) or reset)then return end local mode = getElementModel(vehicle) if(mode == 425)then return end local lastSaved = getTickCount() local index = #vehicleData + 1 vehicleData[index] = {} local posX, posY, posZ = getElementPosition(vehicle) local rotX, rotY, rotZ = getElementRotation(vehicle) local velX, velY, velZ = getElementVelocity(vehicle) local turnVelX, turnVelY, turnVelZ = getVehicleTurnVelocity(vehicle) local health = getElementHealth(vehicle) local model = getElementModel(vehicle) -- Later add worldSpecialProperty too. vehicleData[index].posX = posX vehicleData[index].posY = posY vehicleData[index].posZ = posZ vehicleData[index].rotX = rotX vehicleData[index].rotY = rotY vehicleData[index].rotZ = rotZ vehicleData[index].velX = velX vehicleData[index].velY = velY vehicleData[index].velZ = velZ vehicleData[index].turnVelX = turnVelX vehicleData[index].turnVelY = turnVelY vehicleData[index].turnVelZ = turnVelZ vehicleData[index].health = health vehicleData[index].model = model vehicleData[index].dimension = getElementDimension(vehicle) vehicleData[index].nitro = nil local upgrades = getVehicleUpgrades(vehicle) for upgradeKey, upgradeValue in ipairs(upgrades) do if(tonumber(upgradeValue) >= 1008 and tonumber(upgradeValue) <= 1010)then vehicleData[index].nitro = tonumber(upgradeValue) end end outputDebugString("Vehicle data num: "..index.." saved.") end saveTimer = setTimer(saveVehicleData, SAVE_INTER, 0) function saveRespawnToSpawnpoint(player) local vehicle = getPedOccupiedVehicle(player) local index = #vehicleData + 1 vehicleData[index] = {} local spawn = getElementsByType("spawnpoint") local posX, posY, posZ = getElementData(spawn[1], "posX"), getElementData(spawn[1], "posY"), getElementData(spawn[1], "posZ") local rotX, rotY, rotZ = getElementData(spawn[1], "rotX"), getElementData(spawn[1], "rotY"), getElementData(spawn[1], "rotZ") local velX, velY, velZ = 0, 0, 0 local turnVelX, turnVelY, turnVelZ = 0, 0, 0 local health = getElementHealth(vehicle) local model = getElementData(spawn[1], "vehicle") -- Later add worldSpecialProperty too. vehicleData[index].posX = posX vehicleData[index].posY = posY vehicleData[index].posZ = posZ vehicleData[index].rotX = rotX vehicleData[index].rotY = rotY vehicleData[index].rotZ = rotZ vehicleData[index].velX = velX vehicleData[index].velY = velY vehicleData[index].velZ = velZ vehicleData[index].turnVelX = turnVelX vehicleData[index].turnVelY = turnVelY vehicleData[index].turnVelZ = turnVelZ vehicleData[index].health = health vehicleData[index].model = model vehicleData[index].dimension = getElementDimension(vehicle) end addEvent("onClientRaceStateChanging", true) addEventHandler("onClientRaceStateChanging", getRootElement(), function(newState, oldState) if(newState == "Running")then local state = tostring(getElementData(getLocalPlayer(), "state")) if(state == "waiting")then --[[ reset = false running = true vehicleData = {} saveRespawnToSpawnpoint(getLocalPlayer()) showRespawn = true setElementData(getLocalPlayer(), "respawn.playing", false, true) bindKey(RESPAWN_KEY, "up", respawn) --]] elseif(state == "alive" or state == "not ready")then reset = false running = true for i = 1, #vehicleData do table.remove(vehicleData, i) end vehicleData = {} saveVehicleData() end end if(newState == "PostFinish" or newState == "NoMap")then reset = true running = false unbindKey(RESPAWN_KEY, "up", respawn) showRespawn = false setElementData(getLocalPlayer(), "respawn.playing", false, true) end end) addEventHandler("onClientPlayerWasted", getLocalPlayer(), function() if(source ~= getLocalPlayer())then return end reset = true setElementData(getLocalPlayer(), "respawn.playing", false, true) setTimer(function() --local state = getElementData(getLocalPlayer(), "respawn.playing") or true if(#vehicleData > 0 and running)then showRespawn = true setElementData(getLocalPlayer(), "respawn.playing", false, true) bindKey(RESPAWN_KEY, "up", respawn) end end, 3000, 1) end) local unfreeze = {} addEvent("clientUnfreezeOnReady", true) addEventHandler("clientUnfreezeOnReady", getRootElement(), function(vehicle, vehData) -- source is the vehicle to unfreeze unfreeze.vehicle = vehicle unfreeze.health = vehData.health unfreeze.dim = vehData.dimension unfreeze.x, unfreeze.y, unfreeze.z = vehData.posX, vehData.posY, vehData.posZ unfreeze.vx, unfreeze.vy, unfreeze.vz = vehData.velX, vehData.velY, vehData.velZ unfreeze.tx, unfreeze.ty, unfreeze.tz = vehData.turnVelX, vehData.turnVelY, vehData.turnVelZ setElementFrozen(vehicle, false) addEventHandler("onClientRender", getRootElement(), unfreezeOnReady) end) function unfreezeOnReady() setElementHealth(unfreeze.vehicle, unfreeze.health) setElementPosition(unfreeze.vehicle, unfreeze.x, unfreeze.y, unfreeze.z) if(not isElementFrozen(unfreeze.vehicle))then setElementDimension(unfreeze.vehicle, unfreeze.dim) setElementVelocity(unfreeze.vehicle, unfreeze.vx, unfreeze.vy, unfreeze.vz) setVehicleTurnVelocity(unfreeze.vehicle, unfreeze.tx, unfreeze.ty, unfreeze.tz) removeEventHandler("onClientRender", getRootElement(), unfreezeOnReady) end end function dxDrawColoredText(text, left, top, right, bottom, color, scale, font, alignX, alignY, clip, wordBreak, postGUI) -- Making them optional. right = right or screen_width bottom = bottom or screen_height while(left < 0) do left = screen_width - math.abs(left) end while(top < 0) do top = screen_height - math.abs(top) end while(right < 0) do right = screen_width - math.abs(right) end while(bottom < 0) do bottom = screen_height -
  3. // :::.. Uszatek ..::: // SURVIVAL // Only DD // mtapolska.tk // 94.23.251.227:22040 Serwer posiada ciekawa opcje respawnu na DD ktora screenami nie dam rady pokazac ale zapraszam. Moze akurat komus przypadnie do gustu, szczegolnie tym co nie lubia czekac do konca rundy.
×
×
  • Create New...