Jump to content

how to set this work


Sparrow

Recommended Posts

Posted

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?

Posted
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) 

Posted

thank you for this fast help.

to set the player who type this command frozen, I need to add this?

setTimer (setPedFrozen, 10000, 1, thePlayer) 

Posted (edited)
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
Posted
  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.

Posted

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

Posted
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

Posted

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) 

Posted
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) 

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

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