Apo Posted September 28, 2016 Share Posted September 28, 2016 (edited) hi guys please help me for fix my code if player killed by other player can use command 911 and setwanted for killer local cooldown = {} function onStealthKill(thePlayer,targetPlayer) outputChatBox("Stealth kill!", source) targetPlayer, targetPlayerName = exports.global:findPlayerByPartialNick(thePlayer, targetPlayer) outputChatBox("" .. getPlayerName(thePlayer) .. " has been stealth-killed by " .. getPlayerName(source) .. ".",thePlayer,100,155,100) call911[targetPlayer] = true cooldown[targetPlayer] = setTimer(timerEnd, 60000, 1, targetPlayer) addCommandHandler("911",function() if cooldown[targetPlayer] and isTimer(cooldown[targetPlayer]) then setPlayerWantedLevel ( source, 1 ) end end) end addEventHandler("onPlayerStealthKill", getRootElement(), onStealthKill) function timerEnd(thePlayer) if cooldown[thePlayer] and isTimer(cooldown[thePlayer]) then killTimer(cooldown[thePlayer]) cooldown[thePlayer] = nil end end Edited September 28, 2016 by Apo Link to comment
Gravestone Posted September 28, 2016 Share Posted September 28, 2016 14 minutes ago, Apo said: call911[targetPlayer] = true There is no call911 table. Link to comment
Walid Posted September 28, 2016 Share Posted September 28, 2016 try sth like this (untested i'm using the phone) local killer = {} function wasted(ammo, attacker, weapon, bodypart ) if (attacker and isElement(attacker) and attacker ~= source) then if (getElementType(attacker) == "player") then outputChatBox("" .. getPlayerName(source) .. " has been killed by " .. getPlayerName(attacker) .. ".",root,100,155,100) killer[source] = attacker end end end addEventHandler ( "onPlayerWasted", root, wasted ) function call911(player) if isElement(killer[player]) then setPlayerWantedLevel (killer[player],1) killer[player] = nil end end addCommandHandler("911",call911) Link to comment
Tails Posted September 28, 2016 Share Posted September 28, 2016 Correct me if I'm wrong but I think that killer[source] = attacker should be: killer[attacker] = attacker @Walid Source is the person that got wasted not the killer. Link to comment
Mr.Loki Posted September 28, 2016 Share Posted September 28, 2016 The [source] is just the key in the table to find the attacker for the player that was killed. If it was [attacker] then the player who killed someone could use the 911 cmd to get his self wanted. 1 Link to comment
Walid Posted September 29, 2016 Share Posted September 29, 2016 (edited) 14 hours ago, Tails said: Correct me if I'm wrong but I think that killer[source] = attacker should be: killer[attacker] = attacker @Walid Source is the person that got wasted not the killer. 14 hours ago, loki2143 said: The [source] is just the key in the table to find the attacker for the player that was killed. If it was [attacker] then the player who killed someone could use the 911 cmd to get his self wanted. ^ Edited September 29, 2016 by Walid Link to comment
Tails Posted September 29, 2016 Share Posted September 29, 2016 (edited) 15 hours ago, loki2143 said: The [source] is just the key in the table to find the attacker for the player that was killed. Oh yeah, I was looking at it the wrong way. The call911 function confused me, I didn't realize the player argument was the one executing the command, I thought it was for the killer, like you'd do /call911 killer. Haha my bad Edited September 29, 2016 by Tails 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