JanKy Posted October 1, 2017 Share Posted October 1, 2017 (edited) Hi guys, So, someone helped me make an handcuff function, but it has some issues. Like, if someone dies handcuffed he has that effect even when he respawns. putAnotherPlayerInCuffsS = function(playa) if not getElementData(playa,"inCuffs") and not getElementData(playa,"isDead") and getElementData(source,"Handcuffs") >= 1 then setElementData(source,"Handcuffs",getElementData(source,"Handcuffs")-1) setPedAnimation(playa,"ped","IDLE_tired",-1,true,false,false) toggleAllControls(playa,false,true,false) toggleControl(playa,"jump",false) setElementData(playa,"inCuffs",true) outputChatBox("You were handcuffed for 90 seconds!",playa,150,50,100) setTimer(function(player) if isElement(player) then if getElementData(player,"inCuffs") then setElementData(player,"inCuffs",false) if not getElementData(player,"inComa") then toggleAllControls(player,true) setPedAnimation(player,false) end end end end, 90000, 1,playa) end end addEvent("putAnotherPlayerInCuffs", true) addEventHandler("putAnotherPlayerInCuffs", getRootElement(), putAnotherPlayerInCuffsS) Also, i wanted to make it last like 5 minutes, or 15, but if i change that, it doest work anymore. EDIT: It works for 5 minutes now, but im still not sure about 15. And i was thinking about adding some keys for the handcuffs. Any ideas? Thanks in advance. Edited October 1, 2017 by JanKy Link to comment
Tekken Posted October 1, 2017 Share Posted October 1, 2017 This may fix: putAnotherPlayerInCuffsS = function(playa) if not getElementData(playa, "inCuffs") and not getElementData(playa, "isDead") and getElementData(source, "Handcuffs") >= 1 then setElementData(source, "Handcuffs", getElementData(source, "Handcuffs") - 1); setPedAnimation(playa, "ped", "IDLE_tired", -1, true, false, false); toggleAllControls(playa, false, true, false); toggleControl(playa, "jump", false); setElementData(playa, "inCuffs", true); outputChatBox("You were handcuffed for 90 seconds!", playa, 150, 50, 100); setTimer(function(player) if isElement(player) then if getElementData(player, "inCuffs") then setElementData(player, "inCuffs", false); if not getElementData(player,"inComa") then toggleAllControls(player, true); setPedAnimation(player, false); end end end end, 15*60000, 1, playa); --Edit here for as many mins as you want! end end addEvent("putAnotherPlayerInCuffs", true); addEventHandler("putAnotherPlayerInCuffs", root, putAnotherPlayerInCuffsS); addEventHandler("kilLDayZPlayer", root, function(player) setElementData(player, "inCuffs", false); toggleAllControls(player, true); setPedAnimation(player, false); end); It really depends on how is your death function called on most DayZ servers it's called kilLDayZPlayer Good luck. Link to comment
JanKy Posted October 1, 2017 Author Share Posted October 1, 2017 (edited) Its kilLDayZPlayer on my gamemode too, but it didnt removed the effect after i died. Also, i fixed the 15 min problem. Apparently, after you handcuff someone you cant handcuff them again. This and, you cant handcuff multiple players at the same time. Can this be fixed too? EDIT : Yep, i tested. For some reason, you can handcuff a person once in a lifetime, even tho you have multiple handcuffs on you. Edited October 1, 2017 by JanKy Link to comment
Tekken Posted October 2, 2017 Share Posted October 2, 2017 (edited) local playersInCuffs = {}; --this is where players in cuffs will be stored. addEvent("putAnotherPlayerInCuffs", true); function putAnotherPlayerInCuffsS(playa) if not getElementData(playa, "inCuffs") and not getElementData(playa, "isDead") and (getElementData(source, "Handcuffs") >= 1) then setElementData(source, "Handcuffs", (getElementData(source, "Handcuffs") - 1)); setPedAnimation(playa, "ped", "IDLE_tired", -1, true, false, false); toggleAllControls(playa, false, true, false); toggleControl(playa, "jump", false); setElementData(playa, "inCuffs", true); outputChatBox("You were handcuffed for 90 seconds!", playa, 150, 50, 100); playersInCuffs[playa] = setTimer(function(player) if isElement(player) then setElementData(player, "inCuffs", false); if not getElementData(player,"inComa") then toggleAllControls(player, true); setPedAnimation(player, false); end end end, 15*60000, 1, playa); --Edit here for as many mins as you want! end end addEventHandler("putAnotherPlayerInCuffs", root, putAnotherPlayerInCuffsS); addEventHandler("onPlayerWasted", root, function() if isTimer(playersInCuffs[source]) then killTimer(playersInCuffs[source]); end setElementData(source, "inCuffs", false); toggleAllControls(source, true); setPedAnimation(source, false); toggleControl(playa, "jump", true); end); About the Handcuff once in a lifetime I suspect when you uncuff them you forget to clear the data and the server sees them as already handcuffed even they are not. Also I just realized you only need onPlayerWasted for when player dies. You may post the full script? Edited October 2, 2017 by Tekken 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