Add Friend system
-
Hi I need help. Iām trying to figure out how to add a friend system where you can search for a username and add them etc. any help would be appreciated... :)
-
Wow, this is a difficult task...
If you are doing actual networking using HTTP requests or socket.io, you are going to need to learn a language called PHP and use a PHP server. I use 000filewebhost by Hostinger to create and manage my PHP server. This way, you can actually become friends with real players and interact with them. (You are probably not doing this, so I won't go into detail.)
If you are just making a simple project with pre-made or generated usernames, you just need to know how to manipulate arrays to get the desired result you want.
-
All usernames should be inside an array, let's call this array Users.
When searching for a name, you can loop through the entire array and check for usernames containing what you typed.
For example, if you typed
dog
, all usernames containingdog
should pop up.dog282
,somedog
anddoggy
are examples that follow this condition. Note that hyperPad that have a built-in feature to check if a text contains something, so you will need to make your own.So searching for
dog
should check for usernames in Users for keyworddog
.All results should be placed in an another array, let's call this Results. This is where all the desired usernames will be after a search.
After looping through Users, now you can loop through Results to get what you want to show. You can use
Get Array Count
to show the number of results or make a list appear.I know you have a lot of questions on what to do, but I don't know which ones you're going to ask. Feel free to ask me any questions! š