Jump to content

addKill()


Recommended Posts

Why the kills don't increment?

No error in the debugscirpt

function addKill(totalAmmo, killer) 
local account = getPlayerAccount(killer) 
local kills = getAccountData(account, "KillsOn10Peds") 
if kills then 
    if not kills == 10 then 
        setAccountData(account, "KillsOn10Peds", tonumber(kills + 1)) 
    elseif kills == 10 then 
        outputChatBox(chat.."#ff0000Compliments! You completed the mission '#ffffffKilling <3#ff0000', you reicive 1 medal and 200$!", killer, 255,255,255, true) 
        local cash = getAccountData(account, "cash") 
        local medals = getAccountData(getPlayerAccount(killer), "cash") 
        setAccountData(account, "medals", cash + 1) 
        setAccountData(account, "cash", medals + 200) 
        setScoresInBoard() 
        stopMission(killer) 
    end 
end 
end 
addEventHandler("onPedWasted", getRootElement(), addKill) 

Link to comment
function addKill(totalAmmo, killer) 
    local account = getPlayerAccount(killer) 
    local kills = getAccountData(account, "KillsOn10Peds") 
    if not kills then 
          setAccountData(account, "KillsOn10Peds", 0) 
    end 
    if  kills ~= 10 then 
            setAccountData(account, "KillsOn10Peds", tonumber(kills + 1)) 
     elseif kills == 10 then 
            outputChatBox(chat.."#ff0000Compliments! You completed the mission '#ffffffKilling <3#ff0000'#ff0000, you recieve 1 medal and 200$!", killer, 255,255,255, true) 
            local cash = getAccountData(account, "cash") 
            local medals = getAccountData(account, "cash") 
            if not cash then setAccountData(account, "cash", 0) 
            if not medals then setAccountData(account, "medals", 0) 
            setAccountData(account, "medals", cash + 1) 
            setAccountData(account, "cash", medals + 200) 
            setScoresInBoard() 
            stopMission(killer) 
        end 
    end 
addEventHandler("onPedWasted", getRootElement(), addKill) 

no problemo

Link to comment

Ty, it works, but:

Another problem: so, when i start the mission, i kill 10 peds but i can't finish the mission whit 11 kills too, i restart the mode, i restart the mission, i restart the res and when i kill 10 peds the mission finish... why?

Link to comment

Do you want to reset the number of kills each time you start the mission?

Yes? !!

function addKill(totalAmmo, killer) 
    local account = getPlayerAccount(killer) 
    local kills = getAccountData(account, "KillsOn10Peds") 
    setAccountData(account, "KillsOn10Peds", 0) 
    if  kills ~= 10 then 
            setAccountData(account, "KillsOn10Peds", tonumber(kills + 1)) 
     elseif kills == 10 then 
            outputChatBox(chat.."#ff0000Compliments! You completed the mission '#ffffffKilling <3#ff0000'#ff0000, you recieve 1 medal and 200$!", killer, 255,255,255, true) 
            local cash = getAccountData(account, "cash") 
            local medals = getAccountData(account, "cash") 
            if not cash then setAccountData(account, "cash", 0) 
            if not medals then setAccountData(account, "medals", 0) 
            setAccountData(account, "medals", cash + 1) 
            setAccountData(account, "cash", medals + 200) 
            setScoresInBoard() 
            stopMission(killer) 
        end 
    end 
addEventHandler("onPedWasted", getRootElement(), addKill) 

no problemo

Link to comment
Do you want to reset the number of kills each time you start the mission?

Yes? !!

function addKill(totalAmmo, killer) 
    local account = getPlayerAccount(killer) 
    local kills = getAccountData(account, "KillsOn10Peds") 
    setAccountData(account, "KillsOn10Peds", 0) 
    if  kills ~= 10 then 
            setAccountData(account, "KillsOn10Peds", tonumber(kills + 1)) 
     elseif kills == 10 then 
            outputChatBox(chat.."#ff0000Compliments! You completed the mission '#ffffffKilling <3#ff0000'#ff0000, you recieve 1 medal and 200$!", killer, 255,255,255, true) 
            local cash = getAccountData(account, "cash") 
            local medals = getAccountData(account, "cash") 
            if not cash then setAccountData(account, "cash", 0) 
            if not medals then setAccountData(account, "medals", 0) 
            setAccountData(account, "medals", cash + 1) 
            setAccountData(account, "cash", medals + 200) 
            setScoresInBoard() 
            stopMission(killer) 
        end 
    end 
addEventHandler("onPedWasted", getRootElement(), addKill) 

no problemo

Ok thanks, but now i have this problem, i can finish the mission, when i start it, i restart the resource, i kill 10 peds and the mission can finish, if i don't restart the res i can't finish it T_T

Ty, it works, but:

Another problem: so, when i start the mission, i kill 10 peds but i can't finish the mission whit 11 kills too, i restart the mode, i restart the mission, i restart the res and when i kill 10 peds the mission finish... why?

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