Fortress Forever

Fortress Forever (https://forums.fortress-forever.com/index.php)
-   Lua (https://forums.fortress-forever.com/forumdisplay.php?f=44)
-   -   Headshot reward lua? (https://forums.fortress-forever.com/showthread.php?t=18339)

Bridget 12-04-2008 02:33 AM

Headshot reward lua?
 
Can someone conjure some lua code for me that awards a player's team 10 points if he or she makes a successful (resulting in death) headshot on an enemy?

EDIT: Preferably 10 points for a regular kill and 20 for a headshot?

squeek. 12-04-2008 04:37 AM

This code is untested. It should give 20 team points per headshot (10 for regular kill, 10 bonus for headshots).

Code:

TEAM_POINTS_PER_KILL = 10
BONUS_TEAM_POINTS_PER_HEADSHOT = 10

player_onheadshot( shot_entity, shooter_entity )
        if IsPlayer(shooter_entity) then
                local player = CastToPlayer(shooter_entity)
                local team = player:GetTeam()
                team:AddScore(BONUS_TEAM_POINTS_PER_HEADSHOT)
        end
end

player_killed( player, damageinfo )
        -- Entity that is attacking
        local attacker = damageinfo:GetAttacker()

        -- If no attacker do nothing
        if not attacker then
                return
        end

        -- If attacker not a player do nothing
        if not IsPlayer(attacker) then
                return
        end

        local playerAttacker = CastToPlayer(attacker)
        local weapon = damageinfo:GetInflictor():GetClassName()

        -- If attacked by sniper rifle, add points
        if weapon == "ff_weapon_sniperrifle" then
                local team = playerAttacker:GetTeam()
                -- Add score to team
                team:AddScore(TEAM_POINTS_PER_KILL)
        end
end



All times are GMT. The time now is 05:32 AM.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2024, vBulletin Solutions, Inc.