Where is /how is the server sending the info about health/mana realtime or where/how is the client requesting this data realtime. The goal is to read from the database how many points the battle team has, and put this in a window. I have team battles done, if you care to see it:
Code:
Sub Data_TeamBattle(ByRef rbuf As DataBuffer, ByVal UserIndex As Integer)
Dim i As Long
Dim mapnum As Integer 'map with least
Dim n As Integer 'number of players
Dim team1 As Integer
Dim team2 As Integer
Dim myteam As Integer
'get most populated battlemap
DB_RS.Open "SELECT * FROM battlemap ORDER BY players desc"
Do
mapnum = DB_RS!Map
n = DB_RS!players
DB_RS.MoveNext
Loop Until n <= 2 'max players
DB_RS!players = DB_RS!players + 1
mapnum = DB_RS!Map
DB_RS!team1 = mapnum * 3
DB_RS!team2 = mapnum * 3 + 1
DB_RS.Update
DB_RS.Close
'Join lowest amount team to balance out
DB_RS.Open "SELECT * FROM battlemap WHERE `map`='" & mapnum & "'"
team1 = DB_RS!team1players
team2 = DB_RS!team2players
If team1 > team2 Then
myteam = DB_RS!team2
DB_RS!team2players = DB_RS!team2players + 1
Else
myteam = DB_RS!team1
DB_RS!team1players = DB_RS!team1players + 1
End If
DB_RS.Update
DB_RS.Close
'Update users team
DB_RS.Open "SELECT * FROM users WHERE `name`='" & UserList(UserIndex).Name & "'"
DB_RS!team = myteam
DB_RS.Update
DB_RS.Close
User_WarpChar UserIndex, mapnum, 1, 1
End Sub
Sub Data_TeamBattle_Leave(ByRef rbuf As DataBuffer, ByVal UserIndex As Integer)
Dim n As Integer 'number of players
Dim currmap As Integer 'map user is on right now
Dim myteam As Integer
currmap = UserList(UserIndex).Pos.Map
'remove player from team
DB_RS.Open "SELECT * FROM users WHERE `name`='" & UserList(UserIndex).Name & "'"
myteam = DB_RS!team
DB_RS!team = 0
DB_RS.Update
DB_RS.Close
If myteam / 3 = currmap Then
DB_RS.Open "SELECT * FROM battlemap where `map`='" & currmap & "'"
DB_RS!players = DB_RS!players - 1
DB_RS!team1players = DB_RS!team1players - 1
DB_RS.Update
DB_RS.Close
Else
DB_RS.Open "SELECT * FROM battlemap where `map`='" & currmap & "'"
DB_RS!players = DB_RS!players - 1
DB_RS!team2players = DB_RS!team2players - 1
DB_RS.Update
DB_RS.Close
End If
User_WarpChar UserIndex, 16, 14, 4
End Sub