Rob Janes Posted January 14, 2011 Author Share Posted January 14, 2011 This is just a quick way to check to see if a person on your friend list is online. This is under the presumption that your friend list is a string array for your character, ie Friends(MAX_FRIENDS).Anyway, someone was asking about how to compare to see if someone is online, this is a simple server side loop that will compare a string to all the users online and if it's a match, do something…```Public Const MAX_FRIENDS = 10Public strFriendName(MAX_FRIENDS) As StringPublic Sub CheckFriends()'VariablesDim LoopFriend As IntegerDim LoopUsers As IntegerDim tmpUserName As StringDim tmpFriendName As String'The first loop, will look through our friend list array (10) aboveFor LoopFriend = 1 To MAX_FRIENDS 'Load the Friend's name into Memory so we can compare it when we loop through users tmpFriendName = strFriendName(LoopFriend) 'Now that we're checking the friend, lets compare this friend string to every player online and if it found a match...make it do whatever For LoopUsers = 1 To MAX_PLAYERS 'Is the User Playing If IsPlaying(loopuser) Then 'Get the Users Player Name tmpUserName = GetPlayerName(loopuser) If tmpUserName = tmpFriendName Then 'Congrats! Your friend is online! Do something here! End If 'Closing the IsPlaying() End If 'Next User Online Next LoopUsers'Next friend in your arrayNext LoopFriendEnd Sub``` Link to comment Share on other sites More sharing options...
Rob Janes Posted January 14, 2011 Author Share Posted January 14, 2011 Note: This isn't something you can just plug into the engine and get working, but the loop is a tutorial on how to loop through all the users connected and see if someone is online. Do with it what you will. Link to comment Share on other sites More sharing options...
Thor7 Posted January 14, 2011 Share Posted January 14, 2011 Nice one mate :)That will come in very handy in later developments!Also good job on Artifact, used to play it a while back and got total hooked! >_<Good tut tho dude!Thanks Link to comment Share on other sites More sharing options...
crzyone9584 Posted January 14, 2011 Share Posted January 14, 2011 Well thanks for this. Works perfectly in my new friend system I changed it a little. But its pretty nice. Link to comment Share on other sites More sharing options...
Drummerpete Posted January 14, 2011 Share Posted January 14, 2011 There are more efficient searches than that… Link to comment Share on other sites More sharing options...
Rob Janes Posted January 14, 2011 Author Share Posted January 14, 2011 There most likely are ;) I'm still new to the Eclipse Engine it's just an easy way to quickly search through all of the users online. I'm sure there's probably a feature already in the engine that would cut down the process quite a bit. Ce La Vie.One thing I've learned over the years. You will always find ways to streamline and improve functions and still get the same end result just with shorter and cleaner code however, is it worth your time redesigning a function to get the same results if that time could be spent on another more important function? To this day I still have to look at a piece of code and say "Ok, it works. Done. Leave it alone, it works…No seriously...stop looking at it....It works, you don't need to tweak it...move on already..." Link to comment Share on other sites More sharing options...
Rob Janes Posted January 14, 2011 Author Share Posted January 14, 2011 By the way, thanks on the comment about Artifact, it's been online almost 13 years now, it's population is slowly getting smaller sadly, only 30-40 people online at any given time now, thankfully though, still enough subscribers to keep paying the bills. I've started some advertising campaigns which are becoming fairly costly for Artifact, but we'll see, hopefully it brings in new players. To encourage 'indies' out there, Artifact has made enough money over the years to pay for a house in full. Just an FYI to encourage people not to give up on their dreams! Link to comment Share on other sites More sharing options...
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