1LoL1 Posted September 7, 2015 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)
Tekken Posted September 7, 2015 Posted September 7, 2015 What ? Resources I made: attachToBones - A newer bone_attach. Simple Level system - Just a simple level system. Do not PM me for help with leaked scripts! I WILL NOT HELP YOU!
Addlibs Posted September 7, 2015 Posted September 7, 2015 if math.random(1,10) == 1 then --give bonus end Previously known as MrTasty.
1LoL1 Posted September 7, 2015 Author Posted September 7, 2015 if math.random(1,10) == 1 then --give bonus end what? this is random so luck.. i want to percent
Addlibs Posted September 7, 2015 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. Previously known as MrTasty.
1LoL1 Posted September 7, 2015 Author 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%
Addlibs Posted September 7, 2015 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 Previously known as MrTasty.
1LoL1 Posted September 7, 2015 Author 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
Tekken Posted September 7, 2015 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. Resources I made: attachToBones - A newer bone_attach. Simple Level system - Just a simple level system. Do not PM me for help with leaked scripts! I WILL NOT HELP YOU!
1LoL1 Posted September 7, 2015 Author 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)
JR10 Posted September 7, 2015 Posted September 7, 2015 Maybe because chance never equaled 2 in any of the 4 kills? It's random, you know. Business System viewtopic.php?f=108&t=35797 Notepad++ Syntax Highlighting & Auto Completion viewtopic.php?f=91&t=76726 SQLite Tutorial viewtopic.php?f=148&t=38203
1LoL1 Posted September 8, 2015 Author 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?.
JR10 Posted September 8, 2015 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? Business System viewtopic.php?f=108&t=35797 Notepad++ Syntax Highlighting & Auto Completion viewtopic.php?f=91&t=76726 SQLite Tutorial viewtopic.php?f=148&t=38203
1LoL1 Posted September 9, 2015 Author 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.
JR10 Posted September 9, 2015 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. Business System viewtopic.php?f=108&t=35797 Notepad++ Syntax Highlighting & Auto Completion viewtopic.php?f=91&t=76726 SQLite Tutorial viewtopic.php?f=148&t=38203
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