Sparrow Posted January 26, 2012 Share Posted January 26, 2012 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 any help on this? Link to comment
SDK Posted January 26, 2012 Share Posted January 26, 2012 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
Sparrow Posted January 26, 2012 Author Share Posted January 26, 2012 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) Link to comment
Klesh Posted January 26, 2012 Share Posted January 26, 2012 (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 January 26, 2012 by Guest Link to comment
TAPL Posted January 26, 2012 Share Posted January 26, 2012 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
Klesh Posted January 26, 2012 Share Posted January 26, 2012 I didn't see setElementFrozen, where is it? Also, the code was fixed, see again. Link to comment
TAPL Posted January 26, 2012 Share Posted January 26, 2012 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
Klesh Posted January 26, 2012 Share Posted January 26, 2012 Cuz i fixed later, the code you copy is the old one! Link to comment
Sparrow Posted January 26, 2012 Author Share Posted January 26, 2012 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
BriGhtx3 Posted January 26, 2012 Share Posted January 26, 2012 and the timer in line 8 is totally wrong. You need arguments for the function! Link to comment
Sparrow Posted January 26, 2012 Author Share Posted January 26, 2012 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
Sparrow Posted January 26, 2012 Author Share Posted January 26, 2012 error: Bad argument @ 'setElementFrozen' Link to comment
Xeno Posted January 26, 2012 Share Posted January 26, 2012 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
Sparrow Posted January 26, 2012 Author Share Posted January 26, 2012 thank you xeno, it's working. Link to comment
Klesh Posted January 26, 2012 Share Posted January 26, 2012 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
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now