Jump to content

how to set this work


Sparrow

Recommended Posts

today I di "/kill" command script and I want it kill the player in 10secs when he type /kill

I do this

function killMe (thePlayer) 
    if (thePlayer) then 
        setTimer (killMe, 10000, 1) 
        outputChatBox("You will be killed in 10 seconds.", thePlayer, 255, 0, 0) 
        killPed (thePlayer) 
    end 
end 
addCommandHandler ("kill", killMe) 

and it didn't kill him after 10secs, it kill him when he type /kill :oops:

any help on this?

Link to comment
function killMe (thePlayer) 
    if (thePlayer) then 
        setTimer (killPed, 10000, 1, thePlayer) 
        outputChatBox("You will be killed in 10 seconds.", thePlayer, 255, 0, 0) 
    end 
end 
addCommandHandler ("kill", killMe) 

Link to comment
function killMe (thePlayer) 
    outputChatBox("You will be killed in 10 seconds.", thePlayer, 255, 0, 0) 
    setTimer(function(thePlayer)     
    killPed(thePlayer) 
end, 10000, 1) 
end 
addCommandHandler ("kill", killMe) 
setTimer (killMe, 1000, 1) 

Edited by Guest
Link to comment
  function killMe (thePlayer) 
        if (thePlayer) then 
            setTimer (killPed, thePlayer) 
            outputChatBox("You will be killed in 10 seconds.", thePlayer, 255, 0, 0) 
        end 
    end 
    addCommandHandler ("kill", killMe) 
    setTimer (killMe, 10000, 1) 

@Klesh, what you did is wrong.

@Sparrow, setPedFrozen is deprecated so use this setElementFrozen instead.

Link to comment

i know it was fixed already.

you say ('the code was fixed') then why you post this Oo

function killMe (thePlayer) 
    outputChatBox("You will be killed in 10 seconds.", thePlayer, 255, 0, 0) 
    setTimer(function(thePlayer)    
    killPed(thePlayer) 
end, 10000, 1) 
end 
addCommandHandler ("kill", killMe) 
setTimer (killMe, 1000, 1) 

just read this (Red Note) https://wiki.multitheftauto.com/wiki/SetPedFrozen

Link to comment
function killMe (thePlayer) 
    outputChatBox("You will be killed in 10 seconds.", thePlayer, 255, 0, 0) 
    setTimer(function(thePlayer)     
    killPed(thePlayer) 
end, 10000, 1) 
end 
addCommandHandler ("kill", killMe) 
setTimer (killMe, 1000, 1) 

this didn't work also it didn't froze the player.

error : bad argument @ 'killPed' line 4

Link to comment

setElementFrozen should be as this?

function killMe (thePlayer) 
    if (thePlayer) then 
        setElementFrozen (thePlayer) 
        setTimer (killPed, 10000, 1, thePlayer) 
        outputChatBox("You will be killed in 10 seconds.", thePlayer, 255, 0, 0) 
    end 
end 
addCommandHandler ("kill", killMe) 

Link to comment
function killMe (thePlayer) 
    if (thePlayer) then 
        setElementFrozen (thePlayer, true) 
        setTimer (killPed, 10000, 1, thePlayer) 
        outputChatBox("You will be killed in 10 seconds.", thePlayer, 255, 0, 0) 
    end 
end 
addCommandHandler ("kill", killMe) 

Link to comment
addCommandHandler ("kill", 
function (thePlayer) 
    if (thePlayer) then 
        setElementFrozen (thePlayer, true) 
        setTimer (killPed, 10000, 1, thePlayer) 
        outputChatBox("You will be killed in 10 seconds.", thePlayer, 255, 0, 0) 
    end 
end) 
     
function unfrozen() 
    setElementFrozen (thePlayer, false)--This returns the player to his normal state 
end 
addEventHandler("onPlayerSpawn", getRootElement(), unfrozen) 

That will prevent's to you to getfrozen player before get killed.

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