Jump to content

[Solved]Killing youself give you kills and money


Recommended Posts

Basically when I kill myself with a Greanade it gives me money and kills.

function player_Wasted ( ammo, attacker, weapon, bodypart ) 
    if ( attacker ) then 
        giveKill(attacker) 
        setkdr(attacker) 
        triggerClientEvent(source,"startRespawnShow",source,attacker,weapon) 
        giveDeath(source) 
        setkdr(source) 
        setCameraTarget(source,attacker) 
    else 
        triggerClientEvent(source,"startRespawnShow",source,source,0) 
        giveDeath(source) 
        setkdr(source) 
    end 
end 
addEventHandler ( "onPlayerWasted", getRootElement(), player_Wasted ) 

Edited by Guest
Link to comment

Still not working

This is the function for "giveKill"

function giveKill ( player ) 
    if getElementType(player) == "player" then 
        setElementData(player,"Kills",getElementData(player,"Kills") + 1) 
        local acc = getPlayerAccount(player) 
        if not isGuestAccount(acc) then 
            setAccountData(acc,"Kills",getElementData(player,"Kills") + 1) 
            local mo = getAccountData(getPlayerAccount(player),"Money") 
            setPlayerMoney(player,tonumber(mo) + 50) 
            setAccountData(acc,"Money",tonumber(mo) + 50) 
            setElementHealth(player, getElementHealth(player) + 35) 
        end 
    end 
end 

Link to comment

Try:

function player_Wasted ( ammo, attacker, weapon, bodypart ) 
    if attacker then 
        if attacker==source then 
            triggerClientEvent(source,"startRespawnShow",source,source,0) 
            giveDeath(source) 
            setkdr(source) 
        else 
            giveKill(attacker) 
            setkdr(attacker) 
            triggerClientEvent(source,"startRespawnShow",source,attacker,weapon) 
            giveDeath(source) 
            setkdr(source) 
            setCameraTarget(source,attacker) 
        end 
    else 
        triggerClientEvent(source,"startRespawnShow",source,source,0) 
        giveDeath(source) 
        setkdr(source) 
    end 
end 
addEventHandler ( "onPlayerWasted", getRootElement(), player_Wasted ) 

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