Jump to content

bounty script problem


kikos500

Recommended Posts

well i have asked this question before but i started now so i finished the kills script but i made the kills to detect any player who kills the other so the problem is i tried a lot of times to make it detect the guy who has bounty on but i failed there is the kills / bounty code

---- server.lua

  
 function findPlayer(namepart) 
    for i, player in ipairs(getElementsByType("player")) do 
        local name = getPlayerName(player) 
        if string.find(name:lower(), namepart:lower(), 1, true) then 
            return player, name 
        end 
    end 
    return false     
end 
  
function bounty(source, command, stat, amount) 
local player, playerName = findPlayer(stat) 
if player then 
local test = tonumber(amount) 
local cash = getElementData(source,"cash") 
if cash > test then 
if test >= 10000 then 
setElementData (source,"cash",cash - test,true) 
outputChatBox(getPla[size=85][/size]yerName(source).." Put Bounty On "..getPlayerName(player).."("..test.."$)",getRootElement(),255,255,0,true) 
end 
end 
end 
end 
addCommandHandler("bounty", bounty) 
  

-- kills_s

  
addEvent("onPlayerFinishDD") 
addEventHandler("onPlayerFinishDD", root, function(pRank) 
     
    triggerClientEvent(source, "getPlayerKiller", resourceRoot) 
end) 
  
addEvent("onClientPostKiller", true) 
addEventHandler("onClientPostKiller", resourceRoot, function(pKiller) 
    if (source ~= resourceRoot) then return end 
     
    local clientName = getPlayerName(client) 
     
    if ((pKiller) and (getElementType(pKiller) == "player")) then 
        local killerName = getPlayerName(pKiller) 
         
        outputChatBox(killerName.." has rekt "..clientName) 
    else 
        outputChatBox(clientName.." has died by his own! NOOB!") 
    end 
end) 
  

--- kills_c

  
local pKiller = nil 
  
addEventHandler("onClientVehicleCollision", root, function(hitElement) 
    if (source == getPedOccupiedVehicle(localPlayer)) then 
        if (getElementType(hitElement) == "vehicle") then 
            local hitPlayer = getVehicleOccupant(hitElement) 
             
            if ((hitPlayer) and (getElementType(hitPlayer) == "player")) then 
                pKiller = hitPlayer 
                 
            setTimer(function() pKiller = nil end, 5000,1) 
            end 
        end 
    end 
end) 
  
  
addEvent("getPlayerKiller", true) 
addEventHandler("getPlayerKiller", resourceRoot, function() 
    if (source ~= resourceRoot) then return end 
     
    triggerServerEvent("onClientPostKiller", resourceRoot, pKiller) 
end) 
  

I want the killer of the guy which has bounty on him to get the money

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