#Paper Posted May 6, 2011 Share Posted May 6, 2011 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
qaisjp Posted May 6, 2011 Share Posted May 6, 2011 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
#Paper Posted May 6, 2011 Author Share Posted May 6, 2011 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
qaisjp Posted May 6, 2011 Share Posted May 6, 2011 line 4 is changed line 5 is changed and a few lines added Link to comment
qaisjp Posted May 6, 2011 Share Posted May 6, 2011 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
#Paper Posted May 7, 2011 Author Share Posted May 7, 2011 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
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now