1LoL1 Posted September 7, 2015 Share Posted September 7, 2015 Hello how i can fix this when i want to 10% = give 1 bonus please can anyone help me? function math.percent(percent,maxvalue) if tonumber(percent) and tonumber(maxvalue) then local x = (maxvalue*percent)/100 return x end return false end addEvent("onZombieGetsKilled",true) addEventHandler("onZombieGetsKilled",getRootElement(), function (killer) if math.percent(10,100) then setElementData(killer, "F", getElementData(killer, "F") + 1) local killer = getPlayerName(killer) outputChatBox("+1 F", getRootElement(), 255, 0, 0, true) end end) Link to comment
1LoL1 Posted September 7, 2015 Author Share Posted September 7, 2015 What ? 10% chance will get bonus Link to comment
Addlibs Posted September 7, 2015 Share Posted September 7, 2015 if math.random(1,10) == 1 then --give bonus end Link to comment
1LoL1 Posted September 7, 2015 Author Share Posted September 7, 2015 if math.random(1,10) == 1 then --give bonus end what? this is random so luck.. i want to percent Link to comment
Addlibs Posted September 7, 2015 Share Posted September 7, 2015 10% chance will get bonus what? this is random so luck.. i want to percent Decide what you want, random chance, or percentage of some value to be a bonus. Link to comment
1LoL1 Posted September 7, 2015 Author Share Posted September 7, 2015 10% chance will get bonus what? this is random so luck.. i want to percent Decide what you want, random chance, or percentage of some value to be a bonus. 10% i find or get bonus. Now its 100% Link to comment
Addlibs Posted September 7, 2015 Share Posted September 7, 2015 If you do it to only occur if 1 is picked out of 10 possibilities, it is basically 1/10 chance, which is also known as 10%. if math.random(1,10) == 1 then --give bonus end Link to comment
1LoL1 Posted September 7, 2015 Author Share Posted September 7, 2015 If you do it to only occur if 1 is picked out of 10 possibilities, it is basically 1/10 chance, which is also known as 10%.if math.random(1,10) == 1 then --give bonus end this work but i have given always bonus. And when i want this: (10) == 5 then give bonus 10 = zombies 5 = give bonus Link to comment
Tekken Posted September 7, 2015 Share Posted September 7, 2015 function math.percent(procent, value) if (tonumber(procent) and tonumber(value)) then local p = (procent/100)*value; end return p; end Percent calculation. Link to comment
1LoL1 Posted September 7, 2015 Author Share Posted September 7, 2015 so this? but this not work i killed 4 zombies and i dont have bonus addEvent("onZombieGetsKilled",true) addEventHandler("onZombieGetsKilled",getRootElement(), function (killer) chance = math.random(0,4) if (chance == 2) then setElementData(killer, "F", getElementData(killer, "F") + 1) local killer = getPlayerName(killer) outputChatBox("F", getRootElement(), 255, 0, 0, true) end end) Link to comment
JR10 Posted September 7, 2015 Share Posted September 7, 2015 Maybe because chance never equaled 2 in any of the 4 kills? It's random, you know. Link to comment
1LoL1 Posted September 8, 2015 Author Share Posted September 8, 2015 Maybe because chance never equaled 2 in any of the 4 kills? It's random, you know. Yes i know but how i can when i killed 2 zombies of 4 i will give bonus?. Link to comment
JR10 Posted September 8, 2015 Share Posted September 8, 2015 Because your logic is a bit foggy, 2 zombies out of 4? So just after 2 zombie kills bonus should be given? Link to comment
1LoL1 Posted September 9, 2015 Author Share Posted September 9, 2015 Because your logic is a bit foggy, 2 zombies out of 4? So just after 2 zombie kills bonus should be given? Yes. or when i killed 50 zombies i give bonus. Link to comment
JR10 Posted September 9, 2015 Share Posted September 9, 2015 You need to specify a table for each milestone. On each kill, check the number of kills and give the bonus if the milestone exist in the table. 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