Jump to content

help


Apo

Recommended Posts

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 by Apo
Link to comment

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

O.o

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 by Walid
Link to comment
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 by Tails
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...