Jump to content


  • Content Count

  • Joined

  • Last visited

  • Days Won



Expires: Never (Permanent)

Joshy last won the day on May 6

Joshy had the most liked content!

Community Reputation

2,902 Rainbow

About Joshy

  • Rank
    Do the right thing

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. I've never seen anyone refer to DC as WA. I'm sure it's for the state. Surprisingly: I've never been there, but my working counterparts are also there and I am sure I will get to visit soon. Maybe I'll ask you for advice. Good luck with the move.
  2. Cool. Another place to post pictures
  3. This thread is either trusted only or something has gone seriously wrong when only staff is responding to it. I'm not trusted, and so I'm thinking it's the second half. If I were in your shoes, then I'd be responding and giving feedback to Suggestions and even revisit the topics in Closed. It wouldn't surprise me if a lot of suggestions were too early for their deserved glory, and you'll win twice by making your members feel more involved and valuable to the community. People are not responding because these prominent likelihoods: (a) they feel like they've already told you, (b) they feel like you wont value what you tell them, (c) you don't have active members, or (d) they are happy as it is. I would add an extra tier of perks only available for the low population servers that few play on. We already know people will buy the universal perks good for all servers and the forums on your bread and butter servers (so don't make it available on all servers), but how to convince the others... It's without a doubt, that cost really helps, and we've seen this with sales if you're on top of it and hit at the right time. I would add server specific perks for a lower cost to see if you can boost the low population servers, and this would give the Server Managers there more control instead of clumping a lot perks together into a server almost nobody plays on. I've seen several threads in earlier times about a "Point" system that weighs your activity and contribution to the community. Think of it like signing up for a membership or getting one of those stamp cards at a restaurant, and they reward you with something after so many visits or dollar spent; hell: Give them something special during events such as a holiday or their birthday. This use to be really big talk in CS:S Surf RPG DM in terms of game activity and score although I'm not sure if the threads have any visibility at all (I remember Disturbed_one writing something about it-- his was specific for game performance, but my comment here is much more broad). Don't put all the weight on money and give back to members who contribute or return to the community. Their play time helps your servers. Their forum activity helps the community. Their participation in events help. Referrals to recruit new members. Discord/TS activity. Etc. Nothing specific in mind... I would try it with a few small things and let the system grow or evolve into its eventual best forms. Good luck.
  4. I'm beginning to think you work for the company I work for, or at least contracted by them, but there are a lot of big companies in the areas you've been visiting. edit: Didn't want to double post or bump an old post, but just returned from Denver myself. I didn't know they had bald eagles out there- saw them out there, and they weren't in containment. Check out W Stetson Pl, Denver, CO 80123. It's a residential area, but they're known to be out in that area and my girlfriend managed to find it online. Took this picture with my own camera and even though they were kind of far you could see them really well with your own eyes.
  5. Please look for Staff threads regarding Shout box bans and Telemetry. Telemetry has several "proof of concepts." The only thing ever proven to past leadership is the concept of massive regret, and the likelihood of losing members before the cycle is repeated and additional bans are issued. The fact that this has repeated on Discord should be further evidence and proof of this concept. The ban in place was not made by one person alone (namely myself), and it's not based on one particular event such as a heated discussion with Jerry Hat Trick. I am considered extremely modest when issuing bans or punitive actions... they're only meant to be a remedy or learning experience, and this was a wonderful alternative compared to a well-deserved permanent ban.
  6. Arrays

    I covered last time how to run parts of your program conditionally, and how to loop through it repeatedly instead of retyping the same code over and over again. These next tools will help improve the legibility of your code and its elegance. We previously looked at conditions with two prominent outcomes: (1) It's true, or (2) it's false. What if you have many conditions or options to choose from? Something like below: You could approach this using the brute force method you are already familiar with by cascading many if-else statements together, and it would work. #include <stdio.h> int main() { int userSelection; printf("Choose a case [1-5]: "); scanf("%i", &userSelection); if(userSelection == 1) { printf("You chose 1."); } else if(userSelection == 2) { printf("You chose 2."); } else if(userSelection == 3) { printf("You chose 3."); } else if(userSelection == 4) { printf("You chose 4."); } else if(userSelection == 5) { printf("You chose 5."); } else { printf("Not a valid case!"); } return 0; } Wouldn't it be nice if there was an alternative way to do this without so many if-else... something a little more straightforward rather than checking through each condition? Something like below? Let us pretend the user only wanted to run case 1. Switch case is your solution, and the syntax is pretty easy. The code here will give you the same output as the earlier cascading if-else. Try running both to see for yourself. You begin each case with "case" followed by the integer (ie. 0, 1, 2... 99) or a character (ie. 'a', 'b'... 'y', 'Y'), and you end each section with "break." If you don't use "break", then it'll run both that particular case and the one(s) below it until it hits a "break" or the end. #include <stdio.h> int main() { int userSelection; printf("Choose a case [1-5]: "); scanf("%i", &userSelection); // userSelection can only be an integer or a single character switch(userSelection) { case 1: printf("You chose 1."); break; case 2: printf("You chose 2."); break; case 3: printf("You chose 3."); break; case 4: printf("You chose 4."); break; case 5: printf("You chose 5."); break; default: printf("Not a valid case!"); } return 0; } This could even ease up the pain of having multiple conditions running the same code. Earlier: You may have noticed that the user selection was case-sensitive. If the user selected lowercase 'y' and you had typed in capital 'Y' into your code for the condition, then it would have not ran that code. You would have to cascade two conditional statements using what I have given you before. printf("Yes or no? [y/n]: "); scanf("%c", &userSelection); if(userSelection == 'y') { printf("The user selected yes."); } else if(userSelection == 'Y') { printf("The user selected yes."); } else { printf("The user selected no."); } // I'm purposefully neglecting to use || (OR) to make a point here This could be made equivalently by using switch case: printf("Yes or no? [y/n]: "); scanf("%c", &userSelection); switch(userSelection) { case 'y': case 'Y': printf("The user selected yes."); break; default: printf("The user selected no."); } Lets run that earlier example of adding numbers using a switch case instead of if-else. You can copy and paste this, and it shouldn't surprise you that it runs exactly the same. #include <stdio.h> int main() { // Declaration and initial values int count = 0, numX = 0, numY = 0; char userSelection; printf("Would you like to add numbers? [y/n]: "); scanf("%c", &userSelection); switch(userSelection) { case 'y': case 'Y': printf("How many numbers would you like to add?: "); scanf("%i", &count); for(int i = 0; i < count; i++) { // User interface printf("Input number to add: "); scanf("%i", &numX); numY = numY + numX; } // Output printf("The sum is: %i", numY); break; case 'n': case 'N': printf("Exiting program."); break; default: printf("You did not select 'y' or 'n'!"); printf("\nExiting program."); } return 0; } The variables you have been working on have only been able to hold one item. It's time for you to expand into the next dimension. It's time for... 1-D? That's it? The strategies and concepts here will work the same way for multi-dimensional sets, but you can still achieve a lot with 1-D compared to working with a single item. Have you ever used Excel or some spreadsheet? Arrays are exactly the same thing. You can hold a set of numbers or characters in a single variable we call an array, and each item or element in the array has a corresponding "index." The above picture is literally from open office (the open source version of Microsoft office). As you can see in the first array I have the second item '2' selected, and the array has a size of 5 items (1, 2, 3, 4, and 5). I made another array with 5 items in it too (3, 7, 8, 10, and 11). One of the more tricky things with arrays is how the computer interprets it. The computer wants to start things at zero (0) instead of one (1), and so an array of 5 items will run through index 0, 1, 2, 3, and 4. The equivalent second item in Array1 would therefore be in index '1' (because '1' is the second index coming after '0').: // The declaration is the name of the array, followed by its [size], and the elements inside of it {element1, element2... } int Array1[5] = {1, 2, 3, 4, 5}; // This would print the second element "2". // The first element in this array is Array1[0] contains a "1"... // ... and the thid element in this array is Array1[2] contains a "3". printf("%i", Array1[1]); Lets try another array just to get a feel for it. #include <stdio.h> int main() { char name[6] = {'J', 'o', 's', 'h', 'y'}; for(int i=0; i<6; i++) { printf("%c", name[i]); } return 0; } Now that we are seeing you can use switch instead of if-else for a large selection, and that you can loop through your arrays instead of using multiple variables, lets explore some other ways to repeat tasks without having to rewrite code multiple times. Learning about functions is SUPER helpful for repeating tasks. This is probably an area of focus if you're interested in developing, and so I suggest paying special attention here and running through the examples if you can. Without functions: The concept of your code will look a lot like below: Implementing functions in your code will have you write that operation only one time although you can use it many times throughout your code As you can see: This is much more elegant and you wont have to rewrite your code over and over again. One could argue, that you could use a loop instead, but imagine if your operation involved some type of loop or you wanted to perform this operation in several loops. This would become a mess. Sometimes you use functions not just to prevent repeating code, but to also make your code legible or easy to understand. Here's an example of a code using a mathematical operation: #include <stdio.h> int main() { int a = 2, b = 3, c = 0; int power(int base, int exponent); // you have to declare your functions too c = power(a, b); printf("%i to the power of %i = %i", a, b, c); return 0; } // <-- End of main program // type name(arguments) <-- Beginning of your function called "power" int power(int base, int exponent) { // base^exponent int output = 1; for(int i=0; i<exponent; i++) { output = output*base; } // this is the output when you call it in the main function return output; } And another example where multiple functions are involved. We'll pretend I want to round numbers to the nearest 10th using another function. #include <stdio.h> int main() { int a = 2, b = 2, c = 0, d = 0; int power(int base, int exponent), round10(int inputNumber); // you have to declare your functions too! c = power(a, b); printf("%i to the power of %i = %i", a, b, c); // Now we will round this number to the nearest 10 d = round10(c); printf("\nRounding to nearest 10th: %i -> %i", c, d); return 0; } // type name(arguments) int power(int base, int exponent) { // base^exponent int output = 1; for(int i=0; i<exponent; i++) { output = output*base; } // this is the output when you call it in the main function return output; } // end of power // beginning of another function called "round10" int round10(int number) { // This function rounds the input number to the nearest multiple of 10 int R = 0, output = 0; // Modulo "%" tells you the "remainder" (R) after something is divided // For example 7%5 is 2. R = number%10; if(R < 5) { // Subtract the remainder rounding DOWN output = number - R; } else { // Add whatever you need to get to then next 10th output = number + (10-R); } return output; } Maybe the function above seems harder than just directly typing in the equation. Lets take a look at some data array examples and use a function that helps us finds the maximum value inside of the array. Using a function makes it easy for me to call "max(arguments)" and so my code is easy to understand, and I don't have to use so many loops to get the job done. #include <stdio.h> int main() { int someArray[5] = {0, 1, 12, 3, 18}, dataSet[7] = {1, 101, 5, 1, 1, 0, 12}, randomNumbers[3] = {3, 2, 1}; int max(int arg[], int size); printf("%i", max(someArray, 5)); printf("\t%i", max(dataSet, 7)); printf("\t%i", max(randomNumbers, 3)); return 0; } int max(int array[], int sizeArray) { // Find maximum value in array[] of a given size // Arbitrarily low value int maxValue = 0; for(int i=0;i<sizeArray; i++) { if(array[i] > maxValue) { // If new value is bigger than old, then set new value to maxValue maxValue = array[i]; } } // This is the output of our function return maxValue; } This stuff was pretty heavy, wasn't it? You could still copy and paste a lot of the code above just to get a feel for it, and to again massage the code or use it as a framework for something else of interest. Here's what I recommend trying: Take that summing example and make a switch that allows the user to select an operation (adding, subtracting, multiply, divide...), and make each option a function such that you have something like this: int add(int X, int Y), multiply; // declare your functions int userSelection; printf("1. Add\n"); printf("2. Multiply\n"); //.. printf("Choose an operation: "); scanf("%i", &userSelection) switch(userSelection) { case 1: add(X, Y); break; case 2: multiply(); break; //.. } return 9001; } // <-- end main int add(int X, int Y) { int outputValue; return X + Y; } int multiply( //.. Try a multi-dimensional array. This is the strategy: // name[row][column] = {elements} someArray[][] = {item1, item2, item3}, // a comma before next row {item4, item5, item6}; Conceptually: Interestingly: You could continue using this style of thinking into 3-D and beyond (4-D, 5-D, ... , 100-D). Try a function that returns a character or a void (one without a return) char someFunction(int argument) { char output; switch(argument) { case 1: output = 'a'; break; //.. } return output; } // void function void otherFunction(char argument2) { //.. } Make a sorting function ie. takes in an array and rearranges all the items in ascending or descending order (I recommend nested loops)
  7. This is a follow up for those of you who are more advanced than my first tutorial: We will cover conditions and looping here. I will post a lot such that you can copy and try to massage the code again, and so don't worry if this is a little bit confusing. Just try running and see what happens. A condition is exactly as it sounds: A part of the program will only run if it satisfies a condition. Lets do an example: If you give me $5, then I will do your homework. If you don't give me $5, then I wont do your homework. The programming equivalent to this is the following: #include <stdio.h> int main() { // Declaration char userSelection; // Here is where the user can choose whether or not to give $5 printf("Give Joshy $5 to do your homework? [y/n]: "); scanf("%c", &userSelection); if(userSelection == 'y') { // The user selected 'y' for yes, and so this will run printf("Joshy will do your homework."); } else { // This will run if the user types in anything other than 'y' printf("Joshy will NOT do your homework."); } return 0; } You should be noticing in the above the conditional statement is inside of the if() piece. if(condition) { // Runs if the condition is true } else { // Runs if the condition is not true } There are many other types of "logical" conditions such as the following: != is NOT EQUAL. == EQUAL TO > Greater than >= Greater than or equal to < Less than <= Less than or equal to && AND (both conditions must be true) || OR (one of the conditions must be true) This is just logic, which I am assuming you would know. Here are some examples: // AND example if(someCondition == 1 && anotherCondition == 1) { //.. both conditions must be true to run } // OR example if(someCondition == 1 || anotherCondition == 0) { //.. only one of these conditions needs to be true to run } // Is 5 "less than or equal to 10"? int test = 5; if(test <= 10) { // This one WILL run because 5 <= 10 printf("Yes."); } else { // This one will NOT run printf("No."); } Some common PITFALLS to take note of: It is common for beginners to accidentally use a single equal sign "=" instead of two of them "==", which will not work for checking conditions. A single equal sign "=" will literally set the variable to equal that value. DO NOT USE THE FOLLOWING: if(test = 5) //<-- This is a MISTAKE! Used "=" instead of "==". { //.. } It is a mistake to put a semicolon at the end of a condition or loop. DO NOT USE THE FOLLOWING: if(condition); // <-- this is a MISTAKE! You do not want a semicolon here { // Nothing in here will run... ever... } You CAN use the condition as a bypass without the else statement if you would like. #include <stdio.h> int main() { char bypass; printf("Would you like to skip the next part of this program? [y/n]: "); scanf("%c", &bypass); // if the bypass does not equal to 'y' (yes), then run this code if(bypass != 'y') { printf("You did not skip this part of the program.\n"); } printf("This always runs unconditionally."); return 0; } You might use this in parts of development such as checking if someone has a certain amount of HP, if the player is on a certain team, if the player is in a group like Admin or VIP, or if the targeted player is even online. One of the benefits to programming is taking care of repetitive tasks really quickly. A way for us to take advantage of this is through using loops. The two prominent loops are "for" and "while" loops. For loops run for a set number of times, and its format is along the lines of: int firstNumber = 0, lastNumber = 10; // Counting up from zero to 9. for(int i=firstNumber; i<lastNumber; i++) { // Example of a repetive task printf("%i\n", i); } // This can be done equivalently with for(int i=0; i<10; i++){.. // The above loop will only run from 0 to 9, which is 10 times or 10 "iterations" While loops run until its condition is broken. ageJoshy = 1; // my age will be the condition while(ageJoshy < 18) { printf("Joshy is just a child.\n"); // This increments my age ageJoshy = ageJoshy + 1; // You could also use ageJoshy++; } printf("Joshy is no longer a child."); Some people use "do while" loops, which only guarantees the while loop will run the first time (regardless of the condition) and runs like a regular while loop afterwards; however: I do not plan to confuse you further by talking more about it, and it is not used often- just know that it's available if there is ever a time you may need something like that. You can read about it if you're interested (reference). Another confusing but commonly used strategy is "nested loops." It's much like the movie inception except you've got a loop within a loop, and sometimes (multiple) loops within a loop. I recommend running this one below just to see what it does. #include <stdio.h> int main() { for(int row = 0; row<10; row++) { // This will run through all the columns before going to the next row for(int column = 0; column<10; column++) { printf("Row: %i, Column: %i\n", row, column); // You could make it count by replacing the above with the following line printf("%i\n", column + 10*row); } } return 0; } // This will print out elements of a 10 by 10 array or "matrix." A nested loop conceptually: Let us see what we can make of all this using our earlier program from the first thread. The original program only allowed the user to enter a set amount of numbers to add. Lets make it such that the user can choose how many numbers to add! We'll also give the user an option to exit out of the program if they did not want to add numbers. You can copy and paste this just to get a feel for it. #include <stdio.h> int main() { // Declaration and initial values int count = 0, numX = 0, numY = 0; char userSelection; printf("Would you like to add numbers? [y/n]: "); scanf("%c", &userSelection); if (userSelection == 'y') { printf("How many numbers would you like to add?: "); scanf("%i", &count); for(int i = 0; i < count; i++) { // User interface printf("Input number to add: "); scanf("%i", &numX); numY = numY + numX; } // Output printf("The sum is: %i", numY); } else { printf("Exiting program."); } return 0; } Here's what I recommend trying next: Give the user the option to try other operations such as multiplication ie. printf("1. Add"); printf("\n2. Subtract"); printf("\n3. Multiply"); printf("\nSelect an operation: "); scanf("%i", &userSelection); if(userSelection == 1) { // The user picked option 1. Add numZ = numX + numY; } if(userSelection == 2) { // The user picked option 2. Subtract numZ = numX - numY; } //.. Try having that "nested for loop" print even numbers only, or make it count down instead of up. Try a "nested while loop" counter. If you get stuck in a run time error, then an easy way to exit is to use "CTRL+C" just like the copy shortcut. Make a guessing game where the user wins if they guess the correct number. Try copying any of the code above using for loops and remake an equivalent code using while loops instead Example for loop version: for(int i=0; i<10; i++) { printf("My name is Joshy.\n"); } Example while loop version: //Equivalent version using while loop below int i = 0; while(i < 10) { printf("My name is still Joshy.\n"); i++; } Use different conditions Example condition: if(joshyIsCool == 1) { printf("Joshy is cool."); } Its equivalent condition: if(joshyIsCool != 0) { printf("Joshy is cool."); } Follow up in the next thread to learn more:
  8. Badges

    Great suggestion ( ͡° ͜ʖ ͡°) I've been trying to recover my old programming guides (the first set of guides I did not stage in a word document, and so I do not have it saved elsewhere). I was very skeptical when I saw the updates and some unusual movement I often preach against, but some of these are good updates- badges have been needing some attention for a long while. I still see a lot of things I don't like, but overall it's okay. Keep up the good work.
  9. My friend, Ron, recently passed away from this, but I knew him better in real life and less about his gaming life. Some advice I received from my professor when a close friend passed away a while ago was to live two lives: One for ourselves, and one in continuation and honour of our loved ones. I'm beginning to many lives, but I'll do the best that I can. I'm sorry for your loss.
  10. Saint Patrick's day I wish I noticed that cool Sharkpedo thing!
  11. Any chance on recovering these guides? I do regularly reference these guides to others outside of GFL.
  • Create New...