Jump to content

onPlayerWasted Timer


Recommended Posts

What would be the easiest way to set a time for this function? (Also, if you spot any errors feel free to point them out!)

This script works, however when I add a timer, it gives me errors that it couldn't find the 'source' element. Whereas it works without the timer!

function revivePlayer() 
    local money = getPlayerMoney(source) 
    spawnPlayer(source, x, y, z) 
    setCameraTarget(source, source) 
    fadeCamera(source, true) 
    outputChatBox("You have been killed, a fee of $100 has been deducted from your account.", source) 
    setPlayerMoney(source, (tostring(money) - 100)) 
end 
addEventHandler("onPlayerWasted", root, revivePlayer) 

Thanks

Link to comment

Something like this;

function revivePlayer() 
    setTimer( function() 
    spawnPlayer(source, x, y, z) 
    setCameraTarget(source, source) 
    fadeCamera(source, true) 
    outputChatBox("You have been killed, a fee of $100 has been deducted from your account.", source) 
    setPlayerMoney(source, (getPlayerMoney(source) - 100)) 
    end, 3000, 1) 
end  
addEventHandler("onPlayerWasted", root, revivePlayer) 

Link to comment
Something like this;
function revivePlayer() 
    setTimer( function() 
    spawnPlayer(source, x, y, z) 
    setCameraTarget(source, source) 
    fadeCamera(source, true) 
    outputChatBox("You have been killed, a fee of $100 has been deducted from your account.", source) 
    setPlayerMoney(source, (getPlayerMoney(source) - 100)) 
    end, 3000, 1) 
end  
addEventHandler("onPlayerWasted", root, revivePlayer) 

Yes, any error?

Link to comment
function revivePlayer(player) 
    if player then 
        if isElement(player) then 
            spawnPlayer(player, x, y, z) 
            setCameraTarget(player, player) 
            fadeCamera(player, true) 
            outputChatBox("You have been killed, a fee of $100 has been deducted from your account.", player) 
            setPlayerMoney(player, (getPlayerMoney(player) - 100)) 
            return 
        end 
    end 
    if source then 
        setTimer(revivePlayer,3000,1,source) 
    end 
end  
addEventHandler("onPlayerWasted", root, revivePlayer) 

Kind of an ugly workaround, no idea why the timer in the previous comments are not working. Try this one

Link to comment

Okay,

I've changed it up again! But nothing happens at all now...

function JoinHandler (player) 
    if player then  
        if isElement(player) then 
    spawnPlayer(player, x, y, z) 
    setCameraTarget(player, player) 
    fadeCamera(player, true) 
    outputChatBox("Welcome to our newest server, unfortunately, it is still under development. Please visit later.", player) 
        return 
        end 
    end 
end 
  
function settheTimer() 
    setTimer ( JoinHandler, 1000, 1 ) 
end 
addEventHandler("onPlayerJoin", root, settheTimer) 

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