Jump to content

Reward for killing


zzx

Recommended Posts

I made a script, if anyone killed another player with his hunter, he will get 200$

but only with hunter.

local reward = 200 
  
function kill ( ammo, killer, killerweapon, bodypart ) 
    local vehicle = getPedOccupiedVehicle ( killer ) 
    if isPedInVehicle ( killer ) and getElementModel ( vehicle ) == 425 then 
    givePlayerMoney ( source, reward ) 
            outputChatBox ("#ff8800[REWARD] #ffffffYou have killed "..getPlayerName..( source )" ..and rewarded $".. tostring ( reward ), root, 0, 255, 0, true ) 
        end 
    end 
addEventHandler ( "onPlayerWasted", getRootElement(), kill ) 

help please

Link to comment
local reward = 200 
  
function kill ( ammo, killer, killerweapon, bodypart ) 
    local vehicle = getPedOccupiedVehicle ( killer ) 
    local veh = getVehicleID(vehicle) 
    if isPedInVehicle ( killer ) and veh == 425 then 
    givePlayerMoney ( killer, reward ) 
            outputChatBox ("#ff8800[REWARD] #ffffffYou have killed "..getPlayerName..( source )" ..and rewarded $".. tostring ( reward ), killer, 0, 255, 0, true ) 
        end 
    end 
addEventHandler ( "onPlayerWasted", getRootElement(), kill ) 

Link to comment
local reward = 200 
  
function kill ( ammo, killer, killerweapon, bodypart ) 
    local vehicle = getPedOccupiedVehicle ( killer ) 
    local veh = getVehicleID(vehicle) 
    if isPedInVehicle ( killer ) and veh == 425 then 
    givePlayerMoney ( killer, reward ) 
            outputChatBox ("#ff8800[REWARD] #ffffffYou have killed "..getPlayerName..( source )" ..and rewarded $".. tostring ( reward ), killer, 0, 255, 0, true ) 
        end 
    end 
addEventHandler ( "onPlayerWasted", getRootElement(), kill ) 

This won't work, first, getVehicleID is a deprecated function, second, you're defining the vehicle without checking whether the killer is a player.

This should work i guess:

local reward = 200 
  
function kill ( ammo, killer, killerweapon, bodypart ) 
    if ( getElementType ( killer ) == "vehicle" ) then 
        if ( getElementModel ( killer ) == 425 ) then 
            local controller = getVehicleController ( killer ) 
            givePlayerMoney ( controller, reward ) 
            outputChatBox ("#ff8800[REWARD] #ffffffYou have killed " .. getPlayerName ( source ) .. " and rewarded $" .. reward, controller, 255, 255, 255, true ) 
        end 
    end 
end 
addEventHandler ( "onPlayerWasted", getRootElement(), kill ) 

Link to comment
local reward = 200 
  
function kill ( ammo, killer, killerweapon, bodypart ) 
    local vehicle = getPedOccupiedVehicle ( killer ) 
    local veh = getVehicleID(vehicle) 
    if isPedInVehicle ( killer ) and veh == 425 then 
    givePlayerMoney ( killer, reward ) 
            outputChatBox ("#ff8800[REWARD] #ffffffYou have killed "..getPlayerName..( source )" ..and rewarded $".. tostring ( reward ), killer, 0, 255, 0, true ) 
        end 
    end 
addEventHandler ( "onPlayerWasted", getRootElement(), kill ) 

This won't work, first, getVehicleID is a deprecated function, second, you're defining the vehicle without checking whether the killer is a player.

This should work i guess:

local reward = 200 
  
function kill ( ammo, killer, killerweapon, bodypart ) 
    if ( getElementType ( killer ) == "vehicle" ) then 
        if ( getElementModel ( killer ) == 425 ) then 
            local controller = getVehicleController ( killer ) 
            givePlayerMoney ( controller, reward ) 
            outputChatBox ("#ff8800[REWARD] #ffffffYou have killed " .. getPlayerName ( source ) .. " and rewarded $" .. reward, controller, 255, 255, 255, true ) 
        end 
    end 
end 
addEventHandler ( "onPlayerWasted", getRootElement(), kill ) 

My bad, this one should work yeah.

Link to comment
  • Moderators
Yeah, i thought of that, but the hunter can never be without a controller when it kills someone, that's impossible :P

You sure about that? :idea:

local vehicles = getElementsByType("vehicle") 
for i=1, #vehicles do 
    local vehicle = vehicles[i] 
    setElementVelocity ( vehicle,0,0, 30 ) 
end 
  
setTimer(function() 
    local vehicles = getElementsByType("vehicle") 
    for i=1, #vehicles do 
        local vehicle = vehicles[i] 
        setElementVelocity ( vehicle,0,0, -30 ) 
    end      
end,1000,1) 

If you have low hp and you get rammed by a falling hunter? :P

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