Jump to content

[Help] Respawn player when he died


Wumbaloo

Recommended Posts

Hi! I have a problem, this code won't work

function respawnDeadPlayer() 
        setPedAnimation(source, CRACK, crckdeth1, 9000, true) 
        outputChatBox("Vous êtes mort, vous allez respawn..") 
        fadeCamera(source, false, 7) 
        setTimer(respawnPlayerAfterDied, 10000, 1) 
end  
addEventHandler("onPlayerWasted", getRootElement(), respawnDeadPlayer) 
  
function respawnPlayerAfterDied() 
        local p = source 
        spawnPlayer(p, 1173.197265625, -1323.5419921875, 15.395062446594) 
        fadeCamera(p, true, 5) 
        outputChatBox("Vous avez respawn, bon jeu!") 
end 

It's a server side script, the console return me: "script.lua:11: Bad argument spawnplayer [expected player at argument 1, got nill]" same for 12.

I tried with "player", "source" but it don't work

The function respawnDeadPlayer work except the line 2, it doesn't return error in the console.

I have a question: How can I turn on/off a command? Like "/airbrake" to activate and /airbrake to desactivate, I think I can do this with a boolean value (true/false) but I don't know how exactly.

Sorry for my bad english, i hope you understand that and you can help me

Link to comment

it should be like this

function respawnDeadPlayer() 
        setPedAnimation(source, CRACK, crckdeth1, 9000, true) 
        outputChatBox("Vous êtes mort, vous allez respawn..",source,255,0,0) 
        fadeCamera(source, false, 7) 
        setTimer(respawnPlayerAfterDied, 10000, 1,source) 
end 
addEventHandler("onPlayerWasted", root, respawnDeadPlayer) 
  
function respawnPlayerAfterDied(p) 
        spawnPlayer(p, 1173.197265625, -1323.5419921875, 15.395062446594) 
        fadeCamera(p, true, 5) 
        outputChatBox("Vous avez respawn, bon jeu!",p,255,0,0) 
end 

Link to comment

Like this:

local state = false 
  
addCommandHandler("airbrake", 
    function(player, command) 
        state = not state 
        if state == true then 
            outputChatBox"Airbrake on" 
        elseif state == false then 
            outputChatBox"Airbrake off" 
        end 
    end 
) 

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