Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

Problem with my friend system


terabin
 Share

Recommended Posts

Hello,anyone can help-me? I having problems with my friend list…

This code send the friend list...

```

For i = 1 To MAX_FRIENDS

For i4 = 1 To MAX_PLAYERS '''''''

If GetPlayerName(i4) = Player(index).Friends(i).FriendName And Not Player(index).Friends(i).FriendName = vbNullString Then

Call SendDataTo(index, SUpdateFriendList & SEP_CHAR & Player(index).Friends(i).FriendName & SEP_CHAR & "(Online)" & END_CHAR)

End If

Next

Next

For i = 1 To MAX_FRIENDS

For i4 = 1 To MAX_PLAYERS

If Not GetPlayerName(i4) = Player(index).Friends(i).FriendName Then

Call SendDataTo(index, SUpdateFriendList & SEP_CHAR & Player(index).Friends(i).FriendName & SEP_CHAR & END_CHAR)

End If

Exit For

Next

Next

```

And this is my problem: ![](http://img4.imageshack.us/img4/3050/76181637.png)
Link to comment
Share on other sites

lol you have it going twice. Need to make it CHECK if the player is online.

My way of doing it would be adding a new piece in the PlayerRec Called

```

Online As Byte

```
Send that to all players that are friends with you.then

Replace your code with

```

For i = 1 to MAX_PLAYERS

If Player(I).Online = 1 Then

' Send update for the person is online

Else

'Send update for the person is offline

End If

```
idk though, that's just me xD

Im not exactly sure. plus the fact i haven't used EE for so long :/(from the network code you posted it looks like EE)
Link to comment
Share on other sites

Ok,a changed to this:

```

For i = 1 To MAX_FRIENDS

For i4 = 1 To MAX_PLAYERS '''''''

Player(index).Friends(i).Online = 0

If GetPlayerName(i4) = Player(index).Friends(i).FriendName And IsPlaying(i4) And Not Player(index).Friends(i).FriendName = vbNullString Then

Player(index).Friends(i).Online = 1

Else

Player(index).Friends(i).Online = 0

End If

If Player(index).Friends(i).Online = 1 Then

Call SendDataTo(index, SUpdateFriendList & SEP_CHAR & Player(index).Friends(i).FriendName & SEP_CHAR & "(Online)" & END_CHAR)

Else

Call SendDataTo(index, SUpdateFriendList & SEP_CHAR & Player(index).Friends(i).FriendName & SEP_CHAR & vbNullString & END_CHAR)

End If

Exit For

Next

Next

```

And the problem:

![](http://img32.imageshack.us/img32/2158/92136368.png)
Link to comment
Share on other sites

Here…?

```

If Player(index).Friends(i).Online = 1 Then

Call SendDataTo(index, SUpdateFriendList & SEP_CHAR & Player(index).Friends(i).FriendName & SEP_CHAR & "(Online)" & END_CHAR)

Else

Call SendDataTo(index, SUpdateFriendList & SEP_CHAR & Player(index).Friends(i).FriendName & SEP_CHAR & vbNullString & END_CHAR)

End If

```
Link to comment
Share on other sites

I resolved using this:

```

Dim TempStr As String

Dim TempIndex As Integer

For i = 1 To MAX_FRIENDS 'Percorre a lista de amigos

If Player(Index).Friends(i).FriendName <> vbNullString Then ' Se não houver nulos

TempStr = Player(Index).Friends(i).FriendName

For n = 1 To MAX_PLAYER 'Percorre a lista de jogadores online

If IsPlaying(n) Then

If GetPlayerName(n) = TempStr Then 'Se achar o nome pegar o Index

TempIndex = n

Exit For ' Quebrar o loop

End if

End if

Next

If TempIndex > 0 Then 'Se encontrar jogador online enviar

Call SendDataTo(index, SUpdateFriendList & SEP_CHAR & Player(index).Friends(i).FriendName & SEP_CHAR & "(Online)" & END_CHAR)

Else 'Se não encontrar jogador online enviar

Call SendDataTo(index, SUpdateFriendList & SEP_CHAR & Player(index).Friends(i).FriendName & SEP_CHAR & END_CHAR)

End If

Else 'Se houver nulo, enviar free slot

Call SendDataTo(index, SUpdateFriendList & SEP_CHAR & "Free Slot" & SEP_CHAR & END_CHAR)

End If

TempIndex = 0 'Zerar TempIndex para proxima procura

Next

```

The problem is the exit for.
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...