Jump to content

[SOLVED] With spawn/respawn script.


HeK

Recommended Posts

Hey guys i have made this Spawn/Respawn script, some issues i have is that on Spawn the player gets the guns, thats ok, but on respawn he has no guns anymore, anyway to fix that?

Another problem is that when he dies, i wanted it to have fadeCamera then he respawns, but it doesn't work.

My script:

-- Spawn Player on Plane 
function spawn(prevA, curA, autoLogin) 
        spawnPlayer ( source, -302.70001220703, 1437.9000244141, 835.70001220703, math.random (0,288), 0, 0 ) 
        giveWeapon ( source, 46, 1 ) -- Parachute 
        giveWeapon ( source, 25, 2500 ) -- Shotgun 
        giveWeapon ( source, 22, 2000 ) -- Colt 45 
        fadeCamera ( source, true ) 
        setCameraTarget ( source, source ) 
end 
addEventHandler( "onPlayerLogin", getRootElement(), spawn ) 
  
-- Respawn Player at Base 
addEventHandler( "onPlayerWasted", getRootElement( ), 
        function() 
                setTimer ( spawnPlayer, 5000, 1, source, -343.27581787109, 1537.6356201172, 75.5626, 180 ) 
        end 
) 

Edited by Guest
Link to comment
local guns =  
    { 
        [ 46 ] = 1, 
        [ 25 ] = 2500, 
        [ 22 ] = 2000 
    } 
  
-- Spawn Player on Plane 
function spawn ( prevA, curA, autoLogin ) 
    spawnPlayer ( source, -302.70001220703, 1437.9000244141, 835.70001220703, math.random (0,288), 0, 0 ) 
    fadeCamera ( source, true ) 
    setCameraTarget ( source, source ) 
end 
addEventHandler( "onPlayerLogin", getRootElement(), spawn ) 
  
-- Respawn Player at Base 
addEventHandler( "onPlayerWasted", getRootElement( ), 
    function ( ) 
        setTimer ( spawnPlayer, 5000, 1, source, -343.27581787109, 1537.6356201172, 75.5626, 180 ) 
    end 
) 
  
addEventHandler ( "onPlayerSpawn", root, 
    function ( ) 
        for weapon, ammo in pairs ( guns ) do 
            giveWeapon ( source, weapon, ammo ) 
        end 
    end 
) 

Link to comment

Thanks, i'll do that. I just need another thing, is there anyway to make the "first" spawn only for first time players, for example, first time player joins the server they start on the "plane" and then they jump etc, next time they login they are at the position they left.

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...