tom527103 Posted May 25, 2011 Share Posted May 25, 2011 im currently making a mmorpg i have a bank php script and i want donator intrest to be higher then normal players intrest $interest= $ir['bankmoney']/100*2 ; $interests=money_formatter($interest); $balance=money_formatter($ir['bankmoney']); ^^^ i want that changed so if ($ir['donatordays'] > 0) donator days are higher then 0 then its 100*6 but normal intrest is 100*2 i can upload more of the bank code if needed but need help with this one as cant figure it out i am a noob and learning so if u have a snippet for it would you be able to explain the code to make this work i do not expect to be spoonfed information but any help u could give would be great thanks Quote Link to comment https://forums.phpfreaks.com/topic/237478-mmorpg-help/ Share on other sites More sharing options...
mgoodman Posted May 25, 2011 Share Posted May 25, 2011 Shouldn't it be as simple as if ($ir['donatordays'] > 0) { $interest_rate = .06 } else { $interest_rate = .02 } Maybe I misunderstood your question, if so please let me know. Quote Link to comment https://forums.phpfreaks.com/topic/237478-mmorpg-help/#findComment-1220297 Share on other sites More sharing options...
tom527103 Posted May 25, 2011 Author Share Posted May 25, 2011 what i mean is $interest= $ir['bankmoney']/100*2 ; ^^ it still needs to have that part because that tells it the percent to give of the bank money its hard to explaine as my knowledge is limited on php i want that part to be like if ($ir['donatordays'] > 0) { $interest= $ir['bankmoney']/100*6 } else { $interest= $ir['bankmoney']/100*2 } ^^ but that doesnt work but i hope this gives u better understanding of what i mean Quote Link to comment https://forums.phpfreaks.com/topic/237478-mmorpg-help/#findComment-1220301 Share on other sites More sharing options...
gizmola Posted May 25, 2011 Share Posted May 25, 2011 tom please use code tags around your code. mgoodman's code would of course require you to multiply his variable * $ir['bankmoney'], but it's cleaner than replicating the equation twice. However with that said, your code works. If you're not seeing what you expect it is probably because $ir['donatordays'] > 0 is not evaluating to true even though you expect it to be. You need to determine why that is, using echo/print_r/ or var_dump of your variables. Otherwise it could be something else further in your routines that save the computed balance. Quote Link to comment https://forums.phpfreaks.com/topic/237478-mmorpg-help/#findComment-1220304 Share on other sites More sharing options...
tom527103 Posted May 25, 2011 Author Share Posted May 25, 2011 sorry i forgot i am very new to php how would i write a code to multiply his variable to bankmoney ? would you be able to give me a snippet please and explain what each part of the code does if u could possibly ? thanks Quote Link to comment https://forums.phpfreaks.com/topic/237478-mmorpg-help/#findComment-1220307 Share on other sites More sharing options...
gizmola Posted May 25, 2011 Share Posted May 25, 2011 if ($ir['donatordays'] > 0) { $interest_rate = .06 } else { $interest_rate = .02 } $interest= $ir['bankmoney'] * $interest_rate; This willl not fix your problem because your existing code is already valid. Like I said, you should add: var_dump($ir); Before your block and run the script and take a look at what is in the $ir array, making sure that the values are what you expect them to be. Quote Link to comment https://forums.phpfreaks.com/topic/237478-mmorpg-help/#findComment-1220311 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.