Jump to content

Image appears only when you die and respawn time


off

Recommended Posts

For the player spawn:
--client 
function onClientDied(killer, weapon, bodypart) 
    local thePlayer = getLocalPlayer() 
    triggerServerEvent('onPlayerDied', localPlayer, thePlayer) 
end 
addEventHandler ( "onClientPlayerWasted", getLocalPlayer(), onClientDied) 
  
--server 
addEvent('onPlayerDied', true) 
addEventHandler('onPlayerDied', getRootElement(), function ( thePlayer ) 
    setTimer(function() spawnPlayer(thePlayer, -2404.66943, -596.81165, 132.64844) end, 5000, 1) 
end) 

Set this "-2404.66943, -596.81165, 132.64844" to the position you want them to spawn and the '5000' after it ( again its in milliseconds )

Make sure you have them defined correctly in meta.xml. Like:

I would set it for all spawns. Not just for one.

Link to comment
Image:
function showClientImage() 
   local img = guiCreateStaticImage( 0, 500, 59, 58, "image.png", false ) 
   setTimer(function() destroyElement(img) end, 5000, 1) 
end 
addEventHandler ( "onClientPlayerWasted", getLocalPlayer(), showClientImage) 

Set the 5000 as you need ( its in milliseconds )

Thank you, it worked.

Link to comment
addEventHandler("onPlayerWasted", root, 
    function() 
        setTimer(spawn, 5000, 1, source) 
    end 
) 

You can add this to the image script if you wish or make it as a new file its client sided it should work timers in mil seconds or you can use this

local spawnpoint 
  
addEventHandler("onResourceStart", resourceRoot, 
    function() 
        spawnpoint = getRandomSpawnPoint() 
        resetMapInfo() 
        for i,player in ipairs(getElementsByType("player")) do 
            spawn(player) 
        end 
    end 
) 
  
function spawn(player) 
    if not isElement(player) then return end 
    if get("spawnreset") == "onSpawn" then 
        spawnpoint = getRandomSpawnPoint() 
    end 
    exports.spawnmanager:spawnPlayerAtSpawnpoint(player,spawnpoint,false) 
    repeat until setElementModel(player,math.random(312)) 
    fadeCamera(player, true) 
    setCameraTarget(player, player) 
    showChat(player, true) 
end 
  
function getRandomSpawnPoint () 
    local spawnpoints = getElementsByType("spawnpoint") 
    return spawnpoints[math.random(1,#spawnpoints)] 
end 
  
addEventHandler("onPlayerJoin", root, 
    function() 
        spawn(source) 
    end 
) 
  
addEventHandler("onPlayerQuit",root, 
    function () 
        if getPlayerCount() == 1 and get("spawnreset") == "onServerEmpty" then 
            spawnpoint = getRandomSpawnPoint() 
        end 
    end 
) 
  
  
  
  
  
addEventHandler("onPlayerWasted", root, 
    function() 
        setTimer(spawn, 5000, 1, source) 
    end 
) 

Link to comment
Its better than your attempt

Mine was not an attempt, its working, i tried it. He just never said he wants the player to spawn to a random position. Yours is just full of stupid things like repeat until, you have not specified any arguments for spawnPlayer, you have restartMapInfo() I dont even know why etc... No offense tho...

The code is:

  
function randomSpawn() 
    local tplayer = source 
    spawnPlaces = { 
    {10, 10, 10 }, -- Change them, you can also add more if you want to 
    {20, 20, 10 }, 
    {30, 30, 10 }, 
    } 
     
    local randomPlace = math.random(1, #spawnPlaces) 
    setTimer( function() spawnPlayer(tplayer, spawnPlaces[randomPlace][1],spawnPlaces[randomPlace][2], spawnPlaces[randomPlace][3]) end, 5000, 1) 
end 
addEventHandler('onPlayerWasted', getRootElement(), randomSpawn) 
  

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...