Menu
Forums
All threads
Latest threads
New posts
Trending threads
New posts
Search forums
Trending
What's new
New posts
New profile posts
Latest activity
Members
Current visitors
New profile posts
Search profile posts
Upgrades
Log in
Register
What's new
Search
Search
Search titles only
By:
All threads
Latest threads
New posts
Trending threads
New posts
Search forums
Menu
Log in
Register
Navigation
Install the app
Install
More options
Contact us
Close Menu
Forums
Server Development
Habbo Retros
Habbo Q&A
Diamond Exchange won't work [PLUSEMU]
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
<blockquote data-quote="JayC" data-source="post: 389643" data-attributes="member: 36373"><p>[CODE]switch (Split[0])</p><p> { // Checks what type of exchange furni we're dealing with</p><p> default:</p><p> {</p><p> Session.GetHabbo().Credits += Value;</p><p> Session.SendMessage(new CreditBalanceComposer(Session.GetHabbo().Credits));</p><p></p><p> break;</p><p> }</p><p> case "DFD": // Updates a users diamonds instead of credits.</p><p> {</p><p> Session.GetHabbo().Diamonds += Value;</p><p> Session.SendMessage(new HabboActivityPointNotificationComposer(Session.GetHabbo().Diamonds, 0, 5));</p><p></p><p> break;</p><p> }</p><p> }[/CODE]</p><p></p><p>C# is short circuit evaluation meaning that when it comes to something that is true, it will run it. Your default statement needs to appear last in the switch. Reason being is exactly because of the short circuit evaluation. When the program executes and it runs that switch statement its going to say oh default, everything goes in default and I can run that. It will run the default.</p><p></p><p>THE ONLY EXCEPTION TO THIS ABOVE STATEMENT IS THIS:</p><p>(I think this is true, I have never personally tried this with C#)</p><p>if you want something to execute REGARDLESS of what the case is you can put your default statement first but do not BREAK! Meaning that it will execute the default statement and then go through the cases and find the one that best matches.</p><p></p><p>Personally I would change it so that the case statement did not use default for credits, it would use default as a return. That way if somehow someone scripted to redeem furni it wouldn't give them credits or throw a bug <img src="/styles/default/xenforo/smilies/emojione/smile.png" class="smilie" loading="lazy" alt=":)" title="Smile :)" data-shortname=":)" /></p><p></p><p>ALSO with switch statements instead of break you can say</p><p>goto '{case number}';</p><p>that will make that case execute <img src="/styles/default/xenforo/smilies/emojione/smile.png" class="smilie" loading="lazy" alt=":)" title="Smile :)" data-shortname=":)" /> Makes jumping around a case statement really nice.</p><p></p><p>Best of Luck!</p></blockquote><p></p>
[QUOTE="JayC, post: 389643, member: 36373"] [CODE]switch (Split[0]) { // Checks what type of exchange furni we're dealing with default: { Session.GetHabbo().Credits += Value; Session.SendMessage(new CreditBalanceComposer(Session.GetHabbo().Credits)); break; } case "DFD": // Updates a users diamonds instead of credits. { Session.GetHabbo().Diamonds += Value; Session.SendMessage(new HabboActivityPointNotificationComposer(Session.GetHabbo().Diamonds, 0, 5)); break; } }[/CODE] C# is short circuit evaluation meaning that when it comes to something that is true, it will run it. Your default statement needs to appear last in the switch. Reason being is exactly because of the short circuit evaluation. When the program executes and it runs that switch statement its going to say oh default, everything goes in default and I can run that. It will run the default. THE ONLY EXCEPTION TO THIS ABOVE STATEMENT IS THIS: (I think this is true, I have never personally tried this with C#) if you want something to execute REGARDLESS of what the case is you can put your default statement first but do not BREAK! Meaning that it will execute the default statement and then go through the cases and find the one that best matches. Personally I would change it so that the case statement did not use default for credits, it would use default as a return. That way if somehow someone scripted to redeem furni it wouldn't give them credits or throw a bug :) ALSO with switch statements instead of break you can say goto '{case number}'; that will make that case execute :) Makes jumping around a case statement really nice. Best of Luck! [/QUOTE]
Insert quotes…
Verification
Post reply
Forums
Server Development
Habbo Retros
Habbo Q&A
Diamond Exchange won't work [PLUSEMU]
Top